diff -ruN simscan-1.4.0-factory/simscan.c simscan-1.4.0-patched/simscan.c --- simscan-1.4.0-factory/simscan.c 2007-10-29 10:15:05.000000000 -0400 +++ simscan-1.4.0-patched/simscan.c 2007-11-23 01:42:46.000000000 -0500 @@ -102,6 +102,7 @@ int str_rstr(register char *h,register char *n); char *replace(char *string, char *oldpiece, char *newpiece); int DebugFlag = 0; +int DebugFiles = 0; /* To/From address processing globals */ #define MAX_RCPT_TO 255 @@ -168,6 +169,7 @@ int InClamHeaders; int check_clam(); int is_clam(char *clambuf); +void log_clam(char *clambuf); #endif /* Attachment scanning globals */ @@ -266,6 +268,11 @@ if ( (tmpstr=getenv("SIMSCAN_DEBUG"))!=NULL ) { DebugFlag = atoi(tmpstr); } + + /* Set the "leave temp files alone" flag */ + if ( (tmpstr=getenv("SIMSCAN_DEBUG_FILES"))!=NULL ) { + DebugFiles = atoi(tmpstr); + } #ifdef ENABLE_ATTACH init_attach(); @@ -811,10 +818,12 @@ } /* remove the working files */ - if ( remove_files(workdir) == -1 ) { - exit_clean(EXIT_400); + if ( DebugFiles < 2 ) { + if ( remove_files(workdir) == -1 ) { + exit_clean(EXIT_400); + } } - + /* pass qmail-queue's exit status on */ _exit(WEXITSTATUS(qstat)); @@ -967,6 +976,7 @@ InClamHeaders = 1; memset(buffer,0,sizeof(buffer)); while((file_count=read(0,buffer,BUFFER_SIZE))>0) { + if ( DebugFlag > 2 ) log_clam(buffer) ; if ( InClamHeaders == 1 ) { is_clam(buffer); } @@ -993,6 +1003,35 @@ return(-1); } +void log_clam(char *clambuf) +{ + char *p ; + int needh = 1 ; + + p = clambuf ; + while ( *p ) + { + if ( *p != '\r' ) + { + if ( needh ) + { + fputs ( "simscan: clamdscan: " , stderr ) ; + needh = 0 ; + } + + fputc ( *p , stderr ) ; + + if ( *p == '\n' ) + needh = 1 ; + } + + p++ ; + } + + if ( ! needh ) + fputc ( '\n' , stderr ) ; +} + int is_clam(char *clambuf) { int i,j,k; @@ -1608,7 +1647,8 @@ */ void exit_clean( int error_code ) { - remove_files(workdir); + if ( DebugFiles < 1 ) + remove_files(workdir); if ( DebugFlag > 0 ) { fprintf(stderr, "simscan: exit error code: %d\n", error_code); }