Index: log-server.c =================================================================== RCS file: /afs/ncsa.uiuc.edu/src/ssh/CVSTREE/ssh/log-server.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- log-server.c 1999/01/22 16:37:04 1.1 +++ log-server.c 1999/02/09 19:04:21 1.2 @@ -17,9 +17,13 @@ /* * $Id$ * $Log$ - * Revision 1.1 1999/01/22 16:37:04 jbarlow - * Initial revision + * Revision 1.2 1999/02/09 19:04:21 jbarlow + * Modified so that it will open and close the log file, rather than having + * an open handle on the file at all times. * + * Revision 1.1.1.1 1999/01/22 16:37:04 jbarlow + * Import of SSH 1.2.26 + * * Revision 1.6 1998/05/23 20:21:43 kivinen * Changed () -> (void). * @@ -68,6 +72,10 @@ static int log_quiet = 0; static int log_on_stderr = 0; +/* Initialize these for logging */ +static int log_facility = LOG_USER; +static char *prg_name = "sshd"; + /* Initialize the log. av0 program name (should be argv[0]) on_stderr print also on stderr @@ -78,7 +86,6 @@ void log_init(char *av0, int on_stderr, int debug, int quiet, SyslogFacility facility) { - int log_facility; switch (facility) { @@ -124,8 +131,11 @@ log_debug = debug; log_quiet = quiet; log_on_stderr = on_stderr; + prg_name = strdup(av0); /* store the program name for later use */ closelog(); /* Close any previous log. */ +#if 0 /* don't open log here, it keeps an open handle on every ssh running */ openlog(av0, LOG_PID, log_facility); +#endif } /* Log this message (information that usually should go to the log). */ @@ -141,7 +151,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "log: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(LOG_INFO, "log: %.500s", buf); + closelog(); } /* Converts portable syslog severity to machine-specific syslog severity. */ @@ -182,7 +194,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "log: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(syslog_severity(severity), "log: %.500s", buf); + closelog(); } /* Debugging messages that should not be logged during normal operation. */ @@ -198,7 +212,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "debug: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(LOG_DEBUG, "debug: %.500s", buf); + closelog(); } /* Error messages that should be logged. */ @@ -214,7 +230,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "error: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(LOG_ERR, "error: %.500s", buf); + closelog(); } struct fatal_cleanup @@ -309,7 +327,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "fatal: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(LOG_ERR, "fatal: %.500s", buf); + closelog(); do_fatal_cleanups(); @@ -328,7 +348,9 @@ va_end(args); if (log_on_stderr) fprintf(stderr, "fatal: %s\n", buf); + openlog(prg_name, LOG_PID, log_facility); syslog(syslog_severity(severity), "fatal: %.500s", buf); + closelog(); do_fatal_cleanups();