]> andersk Git - openssh.git/blobdiff - log.c
*** empty log message ***
[openssh.git] / log.c
diff --git a/log.c b/log.c
index 5b25b5929029bf76b4ecd8c8af72898bf2b78a6d..685717aef8c24226a912107393f92574aa762646 100644 (file)
--- a/log.c
+++ b/log.c
@@ -34,7 +34,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: log.c,v 1.21 2002/02/04 12:15:25 markus Exp $");
+RCSID("$OpenBSD: log.c,v 1.25 2003/01/11 18:29:43 markus Exp $");
 
 #include "log.h"
 #include "xmalloc.h"
@@ -88,12 +88,11 @@ static struct {
        { NULL,         SYSLOG_LEVEL_NOT_SET }
 };
 
-static void     do_log(LogLevel level, const char *fmt, va_list args);
-
 SyslogFacility
 log_facility_number(char *name)
 {
        int i;
+
        if (name != NULL)
                for (i = 0; log_facilities[i].name; i++)
                        if (strcasecmp(log_facilities[i].name, name) == 0)
@@ -105,23 +104,13 @@ LogLevel
 log_level_number(char *name)
 {
        int i;
+
        if (name != NULL)
                for (i = 0; log_levels[i].name; i++)
                        if (strcasecmp(log_levels[i].name, name) == 0)
                                return log_levels[i].val;
        return SYSLOG_LEVEL_NOT_SET;
 }
-/* Fatal messages.  This function never returns. */
-
-void
-fatal(const char *fmt,...)
-{
-       va_list args;
-       va_start(args, fmt);
-       do_log(SYSLOG_LEVEL_FATAL, fmt, args);
-       va_end(args);
-       fatal_cleanup();
-}
 
 /* Error messages that should be logged. */
 
@@ -129,6 +118,7 @@ void
 error(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_ERROR, fmt, args);
        va_end(args);
@@ -137,9 +127,10 @@ error(const char *fmt,...)
 /* Log this message (information that usually should go to the log). */
 
 void
-log(const char *fmt,...)
+logit(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_INFO, fmt, args);
        va_end(args);
@@ -151,6 +142,7 @@ void
 verbose(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_VERBOSE, fmt, args);
        va_end(args);
@@ -162,6 +154,7 @@ void
 debug(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_DEBUG1, fmt, args);
        va_end(args);
@@ -171,6 +164,7 @@ void
 debug2(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_DEBUG2, fmt, args);
        va_end(args);
@@ -180,6 +174,7 @@ void
 debug3(const char *fmt,...)
 {
        va_list args;
+
        va_start(args, fmt);
        do_log(SYSLOG_LEVEL_DEBUG3, fmt, args);
        va_end(args);
@@ -228,6 +223,19 @@ fatal_remove_cleanup(void (*proc) (void *context), void *context)
            (u_long) proc, (u_long) context);
 }
 
+/* Remove all cleanups, to be called after fork() */
+void
+fatal_remove_all_cleanups(void)
+{
+       struct fatal_cleanup *cu, *next_cu;
+
+       for (cu = fatal_cleanups; cu; cu = next_cu) {
+               next_cu = cu->next;
+               xfree(cu);
+       }
+       fatal_cleanups = NULL;
+}
+
 /* Cleanup and exit */
 void
 fatal_cleanup(void)
@@ -328,7 +336,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
 
 #define MSGBUFSIZ 1024
 
-static void
+void
 do_log(LogLevel level, const char *fmt, va_list args)
 {
        char msgbuf[MSGBUFSIZ];
@@ -379,11 +387,14 @@ do_log(LogLevel level, const char *fmt, va_list args)
        } else {
                vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
        }
+       /* Escape magic chars in output. */
+       strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_OCTAL);
+       
        if (log_on_stderr) {
-               fprintf(stderr, "%s\r\n", msgbuf);
+               fprintf(stderr, "%s\r\n", fmtbuf);
        } else {
                openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
-               syslog(pri, "%.500s", msgbuf);
+               syslog(pri, "%.500s", fmtbuf);
                closelog();
        }
 }
This page took 0.106041 seconds and 4 git commands to generate.