]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/main.c
add reopen_log(), call it after using PAM stuff
[ppp.git] / pppd / main.c
index 0e256229c7f8064e3f03ada8bae8913d3934ae90..c618a2616f600367aa134b59e33086f07b071bdc 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.68 1999/03/30 04:22:57 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.70 1999/03/31 05:39:42 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -214,12 +214,7 @@ main(argc, argv)
     script_env = NULL;
 
     /* Initialize syslog facilities */
-#ifdef ULTRIX
-    openlog("pppd", LOG_PID);
-#else
-    openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
-    setlogmask(LOG_UPTO(LOG_INFO));
-#endif
+    reopen_log();
 
     if (gethostname(hostname, MAXNAMELEN) < 0 ) {
        option_error("Couldn't get hostname: %m");
@@ -323,8 +318,6 @@ main(argc, argv)
        log_to_fd = 1;          /* default to stdout */
 
     script_setenv("DEVICE", devnam);
-    slprintf(numbuf, sizeof(numbuf), "%d", baud_rate);
-    script_setenv("SPEED", numbuf);
 
     /*
      * Initialize system-dependent stuff and magic number package.
@@ -644,6 +637,9 @@ main(argc, argv)
            close(i);
        }
 
+       slprintf(numbuf, sizeof(numbuf), "%d", baud_rate);
+       script_setenv("SPEED", numbuf);
+
        /* run welcome script, if any */
        if (welcomer && welcomer[0]) {
            if (device_script(welcomer, ttyfd, ttyfd, 0) < 0)
@@ -838,6 +834,20 @@ detach()
        create_pidfile();
 }
 
+/*
+ * reopen_log - (re)open our connection to syslog.
+ */
+void
+reopen_log()
+{
+#ifdef ULTRIX
+    openlog("pppd", LOG_PID);
+#else
+    openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
+    setlogmask(LOG_UPTO(LOG_INFO));
+#endif
+}
+
 /*
  * Create a file containing our process ID.
  */
@@ -1458,12 +1468,7 @@ run_program(prog, args, must_exist, done, arg)
        if (must_exist || errno != ENOENT) {
            /* have to reopen the log, there's nowhere else
               for the message to go. */
-#ifdef ULTRIX
-           openlog("pppd", LOG_PID);
-#else
-           openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);
-           setlogmask(LOG_UPTO(LOG_INFO));
-#endif
+           reopen_log();
            syslog(LOG_ERR, "Can't execute %s: %m", prog);
            closelog();
        }