]> andersk Git - openssh.git/blobdiff - log.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / log.c
diff --git a/log.c b/log.c
index 6eac73743327ebda60baf9495ca06c95f4ed9681..4a8239b931de474319b3cb21420eedbfaaeccc30 100644 (file)
--- a/log.c
+++ b/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.38 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: log.c,v 1.41 2008/06/10 04:50:25 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -44,6 +44,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <errno.h>
 #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
 # include <vis.h>
 #endif
@@ -113,6 +114,17 @@ log_facility_number(char *name)
        return SYSLOG_FACILITY_NOT_SET;
 }
 
+const char *
+log_facility_name(SyslogFacility facility)
+{
+       u_int i;
+
+       for (i = 0;  log_facilities[i].name; i++)
+               if (log_facilities[i].val == facility)
+                       return log_facilities[i].name;
+       return NULL;
+}
+
 LogLevel
 log_level_number(char *name)
 {
@@ -125,6 +137,17 @@ log_level_number(char *name)
        return SYSLOG_LEVEL_NOT_SET;
 }
 
+const char *
+log_level_name(LogLevel level)
+{
+       u_int i;
+
+       for (i = 0; log_levels[i].name != NULL; i++)
+               if (log_levels[i].val == level)
+                       return log_levels[i].name;
+       return NULL;
+}
+
 /* Error messages that should be logged. */
 
 void
@@ -137,6 +160,20 @@ error(const char *fmt,...)
        va_end(args);
 }
 
+void
+sigdie(const char *fmt,...)
+{
+#ifdef DO_LOG_SAFE_IN_SIGHAND
+       va_list args;
+
+       va_start(args, fmt);
+       do_log(SYSLOG_LEVEL_FATAL, fmt, args);
+       va_end(args);
+#endif
+       _exit(1);
+}
+
+
 /* Log this message (information that usually should go to the log). */
 
 void
@@ -299,6 +336,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
        char fmtbuf[MSGBUFSIZ];
        char *txt = NULL;
        int pri = LOG_INFO;
+       int saved_errno = errno;
 
        if (level > log_level)
                return;
@@ -359,4 +397,5 @@ do_log(LogLevel level, const char *fmt, va_list args)
                closelog();
 #endif
        }
+       errno = saved_errno;
 }
This page took 0.194109 seconds and 4 git commands to generate.