]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/auth.c
fix fd leak, don't holdoff once link successfully established
[ppp.git] / pppd / auth.c
index 1532a74762491db5185519515e61eac8cd7c7246..1dfb148f28cd3e060de1d24bbb6df91ce045f788 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: auth.c,v 1.31 1997/04/30 05:50:16 paulus Exp $";
+static char rcsid[] = "$Id: auth.c,v 1.32 1997/07/14 03:52:33 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -304,6 +304,10 @@ network_phase(unit)
            if (protp->protocol != PPP_CCP)
                ++num_np_open;
        }
+
+    if (num_np_open == 0)
+       /* nothing to do */
+       lcp_close(0, "No network protocols running");
 }
 
 /*
@@ -415,8 +419,14 @@ void
 np_up(unit, proto)
     int unit, proto;
 {
-    if (num_np_up == 0 && idle_time_limit > 0) {
-       TIMEOUT(check_idle, NULL, idle_time_limit);
+    if (num_np_up == 0) {
+       /*
+        * At this point we consider that the link has come up successfully.
+        */
+       need_holdoff = 0;
+
+       if (idle_time_limit > 0)
+           TIMEOUT(check_idle, NULL, idle_time_limit);
 
        /*
         * Set a timeout to close the connection once the maximum
@@ -470,7 +480,6 @@ check_idle(arg)
     if (itime >= idle_time_limit) {
        /* link is idle: shut it down. */
        syslog(LOG_INFO, "Terminating connection due to lack of activity.");
-       need_holdoff = 0;
        lcp_close(0, "Link inactive");
     } else {
        TIMEOUT(check_idle, NULL, idle_time_limit - itime);
@@ -873,6 +882,7 @@ get_pap_passwd(passwd)
 {
     char *filename;
     FILE *f;
+    int ret;
     struct wordlist *addrs;
     char secret[MAXWORDLEN];
 
@@ -882,9 +892,11 @@ get_pap_passwd(passwd)
     if (f == NULL)
        return 0;
     check_access(f, filename);
-    if (scan_authfile(f, user,
-                     remote_name[0]? remote_name: NULL,
-                     (u_int32_t)0, secret, NULL, filename) < 0)
+    ret = scan_authfile(f, user,
+                       remote_name[0]? remote_name: NULL,
+                       (u_int32_t)0, secret, NULL, filename);
+    fclose(f);
+    if (ret < 0)
        return 0;
     if (passwd != NULL) {
        strncpy(passwd, secret, MAXSECRETLEN);