X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fauth.c;h=c51a67d975501cad52673bb38b1f43cb357f538c;hb=96ea87ebbd9f1bca4797b3d0c8b5de7e2635eb9a;hp=2d1256b68e8d6ac1d93b134c8562cdd4323e6686;hpb=4426185a13df05984b8827e786966ed1b1408e4e;p=ppp.git diff --git a/pppd/auth.c b/pppd/auth.c index 2d1256b..c51a67d 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -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.53 1999/05/13 00:33:05 paulus Exp $"; #endif #include @@ -367,6 +367,7 @@ link_established(unit) if (!wo->neg_upap || !null_login(unit)) { warn("peer refused to authenticate: terminating link"); lcp_close(unit, "peer refused to authenticate"); + status = EXIT_PEER_AUTH_FAILED; return; } } @@ -460,6 +461,7 @@ auth_peer_fail(unit, protocol) * Authentication failure: take the link down */ lcp_close(unit, "Authentication failed"); + status = EXIT_PEER_AUTH_FAILED; } /* @@ -562,6 +564,7 @@ np_up(unit, proto) * At this point we consider that the link has come up successfully. */ need_holdoff = 0; + status = EXIT_OK; if (idle_time_limit > 0) TIMEOUT(check_idle, NULL, idle_time_limit); @@ -623,8 +626,9 @@ check_idle(arg) itime = MIN(idle.xmit_idle, idle.recv_idle); if (itime >= idle_time_limit) { /* link is idle: shut it down. */ - info("Terminating connection due to lack of activity."); + notice("Terminating connection due to lack of activity."); lcp_close(0, "Link inactive"); + status = EXIT_IDLE_TIMEOUT; } else { TIMEOUT(check_idle, NULL, idle_time_limit - itime); } @@ -639,6 +643,7 @@ connect_time_expired(arg) { info("Connect time expired"); lcp_close(0, "Connect time expired"); /* Close connection */ + status = EXIT_CONNECT_TIME; } /* @@ -785,7 +790,8 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen) } else { check_access(f, filename); if (scan_authfile(f, user, our_name, secret, &addrs, filename) < 0 - || (secret[0] != 0 && (cryptpap || strcmp(passwd, secret) != 0) + || (!uselogin && secret[0] != 0 + && (cryptpap || strcmp(passwd, secret) != 0) && strcmp(crypt(passwd, secret), secret) != 0)) { warn("PAP authentication failure for %s", user); ret = UPAP_AUTHNAK; @@ -891,6 +897,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 +928,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 +952,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) @@ -1012,7 +1022,7 @@ plogin(user, passwd, msg, msglen) (void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET); memset((void *)&ll, 0, sizeof(ll)); (void)time(&ll.ll_time); - (void)strlcpy(ll.ll_line, tty, sizeof(ll.ll_line)); + (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); (void)write(fd, (char *)&ll, sizeof(ll)); (void)close(fd); } @@ -1039,6 +1049,8 @@ plogout() pam_end (pamh, pam_error); pamh = NULL; } + /* Apparently the pam stuff does closelog(). */ + reopen_log(); #else /* ! USE_PAM */ char *tty;