X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsession.c;h=56385dd638742ba9fd7028165104e8565cff0778;hp=491d3bfaac11c79791f5fd3eba2628aa89397a4a;hb=36733a891fb56594fcee580f667b33a64b990981;hpb=1c8af01fd1c14975b6ea9d757578ccbcafd97abb diff --git a/pppd/session.c b/pppd/session.c index 491d3bf..56385dd 100644 --- a/pppd/session.c +++ b/pppd/session.c @@ -73,7 +73,9 @@ #include #include #include +#ifdef HAS_SHADOW #include +#endif #include #include #include @@ -176,6 +178,7 @@ session_start(flags, user, passwd, ttyName, msg) bool try_session = 0; #else /* #ifdef USE_PAM */ struct passwd *pw; + char *cbuf; #ifdef HAS_SHADOW struct spwd *spwd; struct spwd *getspnam(); @@ -346,8 +349,10 @@ session_start(flags, user, passwd, ttyName, msg) /* * If no passwd, don't let them login if we're authenticating. */ - if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2 - || strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0) + if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2) + return SESSION_FAILED; + cbuf = crypt(passwd, pw->pw_passwd); + if (!cbuf || strcmp(cbuf, pw->pw_passwd) != 0) return SESSION_FAILED; } @@ -372,11 +377,13 @@ session_start(flags, user, passwd, ttyName, msg) if (pw != NULL) { struct lastlog ll; int fd; + time_t tnow; if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) { (void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET); memset((void *)&ll, 0, sizeof(ll)); - (void)time(&ll.ll_time); + (void)time(&tnow); + ll.ll_time = tnow; (void)strncpy(ll.ll_line, ttyName, sizeof(ll.ll_line)); (void)strncpy(ll.ll_host, ifname, sizeof(ll.ll_host)); (void)write(fd, (char *)&ll, sizeof(ll));