diff -urNb qpopper4.0.5/popper/main.c qpopper4.0.5_logfile1/popper/main.c --- qpopper4.0.5/popper/main.c Fri Mar 21 14:47:17 2003 +++ qpopper4.0.5_logfile1/popper/main.c Tue Mar 25 13:52:04 2003 @@ -194,6 +194,8 @@ BOOL debug = FALSE; FILE *trace_file = NULL; char *trace_name = NULL; +FILE *logfile_file= NULL; +char *logfile_name= NULL; char msg_buf [ 2048 ] = ""; FILE *msg_out = NULL; FILE *err_out = NULL; @@ -336,7 +338,7 @@ /* * See if debug or trace options specified */ - i = getopt ( Qargc, Qargv, "b:BcCdD:e:f:FkK:l:L:p:RsSt:T:uUvy:z:" ); + i = getopt ( Qargc, Qargv, "b:BcCdD:e:f:FkK:l:L:o:p:RsSt:T:uUvy:z:" ); while ( i != EOF ) { switch ( i ) @@ -345,6 +347,16 @@ debug = TRUE; break; + case 'o': + logfile_name = strdup ( optarg ); + logfile_file = fopen ( optarg, "a" ); + if ( logfile_file == NULL ) + err_dump ( HERE, "Unable to open log file \"%s\"", optarg ); + TRACE ( trace_file, POP_DEBUG, HERE, + "Opened log file \"%s\" as %d", + logfile_name, fileno(logfile_file) ); + break; + case 't': debug = TRUE; trace_name = strdup ( optarg ); @@ -373,7 +385,7 @@ break; } - i = getopt ( Qargc, Qargv, "b:BcCdD:e:f:FkK:l:L:p:RsSt:T:uUvy:z:" ); + i = getopt ( Qargc, Qargv, "b:BcCdD:e:f:FkK:l:L:o:p:RsSt:T:uUvy:z:" ); } optind = 1; /* reset for pop_init */ @@ -480,6 +492,10 @@ if ( i == fileno(trace_file) ) continue; + if ( logfile_file != NULL ) + if ( i == fileno(logfile_file) ) + continue; + if ( pid_file != NULL ) if ( i == fileno(pid_file) ) continue; @@ -625,6 +641,11 @@ fclose ( trace_file ); trace_file = NULL; } + if ( logfile_file != NULL ) + { + fclose ( logfile_file ); + logfile_file = NULL; + } if ( pid_file != NULL ) { fclose ( pid_file ); @@ -770,6 +791,11 @@ fclose ( trace_file ); trace_file = NULL; } + if ( logfile_file != NULL ) + { + fclose ( logfile_file ); + logfile_file = NULL; + } if ( pid_file != NULL ) { fclose ( pid_file ); @@ -940,6 +966,21 @@ trace_name, fileno(trace_file) ); } + if ( logfile_file != NULL && logfile_name != NULL ) + { + TRACE ( trace_file, POP_DEBUG, HERE, "rolling over log file..." ); + fflush ( logfile_file ); + fclose ( logfile_file ); + + logfile_file = fopen ( logfile_name, "a" ); + if ( logfile_file == NULL ) + err_dump ( HERE, "Unable to open trace file '%s'", logfile_name ); + + TRACE ( trace_file, POP_DEBUG, HERE, "Opened log file \"%s\" as %d", + logfile_name, fileno(logfile_file) ); + } +} + /* * Interprets what the user wants when placing a PID file. @@ -1071,6 +1112,12 @@ { fclose ( trace_file ); trace_file = NULL; + } + + if ( logfile_file != NULL ) + { + fclose ( logfile_file ); + logfile_file = NULL; } _exit ( 0 ); diff -urNb qpopper4.0.5/popper/pop_init.c qpopper4.0.5_logfile1/popper/pop_init.c --- qpopper4.0.5/popper/pop_init.c Fri Mar 21 14:47:17 2003 +++ qpopper4.0.5_logfile1/popper/pop_init.c Tue Mar 25 13:52:04 2003 @@ -694,7 +694,7 @@ /* * Process command line arguments */ - while ( ( c = getopt ( argcount, argmessage, "b:BcCdD:e:f:FkK:l:L:p:RsSt:T:uUvy:z:") ) != EOF ) + while ( ( c = getopt ( argcount, argmessage, "b:BcCdD:e:f:FkK:l:L:o:p:RsSt:T:uUvy:z:") ) != EOF ) switch ( c ) { case 'b': /* Bulletins requested */ @@ -805,6 +805,29 @@ p->check_lock_refresh ); break; + case 'o': /* log file specified */ +#ifdef STANDALONE + { + extern FILE *logfile_file; + p->logfile = logfile_file; + } +#else /* not STANDALONE */ + p->logfile = fopen ( optarg, "a" ); +#endif /* STANDALONE */ + + if ( p->logfile == NULL ) { + pop_log ( p, POP_PRIORITY, HERE, + "Unable to open log file \"%s\": %s (%d)", + optarg, STRERROR(errno), errno ); + fprintf ( stderr, "Unable to open log file \"%s\": %s (%d)\n", + optarg, STRERROR(errno), errno ); + EXIT ( 1 ); + } + p->logfile_name = optarg; + DEBUG_LOG1 ( p, "Log destination is file \"%s\"", + p->logfile_name ); + break; + case 'p': /* Set clear text password handling */ pw_handling = atoi ( optarg ); switch ( pw_handling ) { @@ -987,6 +1010,7 @@ "%s" /* -K / kerberos service, if KERBEROS set */ "%s" /* -l / tls_support, if QPOP_SSL set */ "[-L lock refresh] " + "[-o log-file] " "%s" /* -p / plain-text passwd stuff, if APOP or SCRAM */ "[-R] " "[-s] " diff -urNb qpopper4.0.5/popper/popper.h qpopper4.0.5_logfile1/popper/popper.h --- qpopper4.0.5/popper/popper.h Wed Mar 12 21:06:38 2003 +++ qpopper4.0.5_logfile1/popper/popper.h Tue Mar 25 13:52:05 2003 @@ -587,6 +587,8 @@ buffer */ FILE * trace; /* Debugging trace file */ char * trace_name; /* Name of debugging trace file */ + FILE * logfile; /* Log file */ + char * logfile_name; /* Name of log file */ FILE * hold; /* In SERVER_MODE, this value holds the drop FILE */ CALLSTACK InProcess; /* Call Stack that holds the