]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/session.c
Clear hungup in start_link() instead of connect_tty()
[ppp.git] / pppd / session.c
index 05dcb769994190879741a83dca51fe952113ad6d..491d3bfaac11c79791f5fd3eba2628aa89397a4a 100644 (file)
 #include <string.h>
 #include <pwd.h>
 #include <crypt.h>
+#include <shadow.h>
+#include <time.h>
+#include <utmp.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include "pppd.h"
 #include "session.h"
 
@@ -164,8 +169,8 @@ session_start(flags, user, passwd, ttyName, msg)
     const char *ttyName;
     char **msg;
 {
-    bool ok = 1;
 #ifdef USE_PAM
+    bool ok = 1;
     const char *usr;
     int pam_error;
     bool try_session = 0;
@@ -289,9 +294,11 @@ session_start(flags, user, passwd, ttyName, msg)
 #else /* #ifdef USE_PAM */
 
 /*
- * Use the non-PAM methods directly
+ * Use the non-PAM methods directly.  'pw' will remain NULL if the user
+ * has not been authenticated using local UNIX system services.
  */
 
+    pw = NULL;
     if ((SESS_AUTH & flags)) {
        pw = getpwnam(user);
 
@@ -357,7 +364,12 @@ session_start(flags, user, passwd, ttyName, msg)
        logged_in = 1;
 
 #if defined(_PATH_LASTLOG) && !defined(USE_PAM)
-       {
+       /*
+        * Enter the user in lastlog only if he has been authenticated using
+        * local system services.  If he has not, then we don't know what his
+        * UID might be, and lastlog is indexed by UID.
+        */
+       if (pw != NULL) {
             struct lastlog ll;
             int fd;