]> andersk Git - openssh.git/blobdiff - log.c
[configure.ac] Make sure -lcrypto is before -lsocket for sco3. ok mouring@
[openssh.git] / log.c
diff --git a/log.c b/log.c
index 6bbae32da231902064a1ba07f9048a201c46f3c5..686a2a43cbd9413d1b56af5e02945b14f1a98d10 100644 (file)
--- a/log.c
+++ b/log.c
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: log.c,v 1.27 2003/05/18 23:22:01 deraadt Exp $");
+RCSID("$OpenBSD: log.c,v 1.29 2003/09/23 20:17:11 markus Exp $");
 
 #include "log.h"
 #include "xmalloc.h"
 
 #include <syslog.h>
+#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
+# include <vis.h>
+#endif
 
 static LogLevel log_level = SYSLOG_LEVEL_INFO;
 static int log_on_stderr = 1;
@@ -180,83 +183,6 @@ debug3(const char *fmt,...)
        va_end(args);
 }
 
-/* Fatal cleanup */
-
-struct fatal_cleanup {
-       struct fatal_cleanup *next;
-       void (*proc) (void *);
-       void *context;
-};
-
-static struct fatal_cleanup *fatal_cleanups = NULL;
-
-/* Registers a cleanup function to be called by fatal() before exiting. */
-
-void
-fatal_add_cleanup(void (*proc) (void *), void *context)
-{
-       struct fatal_cleanup *cu;
-
-       cu = xmalloc(sizeof(*cu));
-       cu->proc = proc;
-       cu->context = context;
-       cu->next = fatal_cleanups;
-       fatal_cleanups = cu;
-}
-
-/* Removes a cleanup frunction to be called at fatal(). */
-
-void
-fatal_remove_cleanup(void (*proc) (void *context), void *context)
-{
-       struct fatal_cleanup **cup, *cu;
-
-       for (cup = &fatal_cleanups; *cup; cup = &cu->next) {
-               cu = *cup;
-               if (cu->proc == proc && cu->context == context) {
-                       *cup = cu->next;
-                       xfree(cu);
-                       return;
-               }
-       }
-       fatal("fatal_remove_cleanup: no such cleanup function: 0x%lx 0x%lx",
-           (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)
-{
-       struct fatal_cleanup *cu, *next_cu;
-       static int called = 0;
-
-       if (called)
-               exit(255);
-       called = 1;
-       /* Call cleanup functions. */
-       for (cu = fatal_cleanups; cu; cu = next_cu) {
-               next_cu = cu->next;
-               debug("Calling cleanup 0x%lx(0x%lx)",
-                   (u_long) cu->proc, (u_long) cu->context);
-               (*cu->proc) (cu->context);
-       }
-       exit(255);
-}
-
-
 /*
  * Initialize the log.
  */
@@ -390,16 +316,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);
-       
+       strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_SAFE|VIS_OCTAL);
        if (log_on_stderr) {
-               snprintf(fmtbuf, sizeof fmtbuf, "%s\r\n", msgbuf);
-               write(STDERR_FILENO, fmtbuf, strlen(fmtbuf));
+               snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
+               write(STDERR_FILENO, msgbuf, strlen(msgbuf));
        } else {
 #ifdef OPENLOG_R
                openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
-               syslog_r(pri, &sdata, "%.500s", msgbuf);
+               syslog_r(pri, &sdata, "%.500s", fmtbuf);
                closelog_r(&sdata);
 #else
                openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
This page took 0.137565 seconds and 4 git commands to generate.