]> git.ozlabs.org Git - ppp.git/commitdiff
add reopen_log(), call it after using PAM stuff
authorPaul Mackerras <paulus@samba.org>
Wed, 31 Mar 1999 05:39:43 +0000 (05:39 +0000)
committerPaul Mackerras <paulus@samba.org>
Wed, 31 Mar 1999 05:39:43 +0000 (05:39 +0000)
pppd/auth.c
pppd/main.c
pppd/pppd.h

index 2d1256b68e8d6ac1d93b134c8562cdd4323e6686..e26d36af94aefd947d6cfcc1c8d63d54245fcf96 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: auth.c,v 1.48 1999/03/30 06:02:21 paulus Exp $";
+static char rcsid[] = "$Id: auth.c,v 1.49 1999/03/31 05:39:42 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -891,6 +891,7 @@ static int PAM_conv (int num_msg, const struct pam_message **msg,
     *resp = reply;     
     return PAM_SUCCESS;
 }
+
 static struct pam_conv PAM_conversation = {
     &PAM_conv,
     NULL
@@ -921,7 +922,8 @@ plogin(user, passwd, msg, msglen)
 
     pam_error = pam_start ("ppp", user, &PAM_conversation, &pamh);
     if (pam_error != PAM_SUCCESS) {
-        *msg = (char *) pam_strerror (pamh, pam_error);  
+        *msg = (char *) pam_strerror (pamh, pam_error);
+       reopen_log();
        return UPAP_AUTHNAK;
     }
     /*
@@ -944,9 +946,11 @@ plogin(user, passwd, msg, msglen)
     }
 
     *msg = (char *) pam_strerror (pamh, pam_error);
+
     /*
      * Clean up the mess
      */
+    reopen_log();      /* apparently the PAM stuff does closelog() */
     PAM_username = NULL;
     PAM_password = NULL;
     if (pam_error != PAM_SUCCESS)
@@ -1039,6 +1043,8 @@ plogout()
        pam_end (pamh, pam_error);
        pamh = NULL;
     }
+    /* Apparently the pam stuff does closelog(). */
+    reopen_log();
 #else /* ! USE_PAM */   
     char *tty;
 
index 0fbef8681e5bd1ec6d95b15b737289c24727598d..c618a2616f600367aa134b59e33086f07b071bdc 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.69 1999/03/30 06:01:24 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");
@@ -839,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.
  */
@@ -1459,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();
        }
index a51c99c80418616e1c4847e3571b227f97b27d1f..c997f81fdd3305e50624fcbe10c5a2992a1ad677 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: pppd.h,v 1.36 1999/03/30 06:33:09 paulus Exp $
+ * $Id: pppd.h,v 1.37 1999/03/31 05:39:43 paulus Exp $
  */
 
 /*
@@ -285,6 +285,7 @@ void notice __P((char *, ...));     /* log a notice-level message */
 void warn __P((char *, ...));  /* log a warning message */
 void error __P((char *, ...)); /* log an error message */
 void fatal __P((char *, ...)); /* log an error message and die(1) */
+void reopen_log __P((void));   /* (re)open the connection to syslog */
 
 /* Procedures exported from auth.c */
 void link_required __P((int));   /* we are starting to use the link */