From 54a510907ca30d8a1651fdb5f7c2c360f4ef7e27 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 14 Jul 1997 03:52:33 +0000 Subject: [PATCH] fix fd leak, don't holdoff once link successfully established --- pppd/auth.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pppd/auth.c b/pppd/auth.c index 1532a74..1dfb148 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -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 @@ -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); -- 2.39.2