Check for the expiration of an account and its password in the proper

order.

Reviewed by:	-audit (silence)
Approved by:	murray
Obtained from:	OpenBSD
MFC after:	5 days
This commit is contained in:
Eric Melville 2001-05-17 03:10:04 +00:00
parent 19d4c7b3d7
commit 40c65ba9c7

View File

@ -415,6 +415,19 @@ main(argc, argv)
#define DEFAULT_WARN (2L * 7L * 86400L) /* Two weeks */
warntime = login_getcaptime(lc, "warnexpire",
DEFAULT_WARN, DEFAULT_WARN);
if (pwd->pw_expire) {
if (tp.tv_sec >= pwd->pw_expire) {
refused("Sorry -- your account has expired",
"EXPIRED", 1);
} else if (pwd->pw_expire - tp.tv_sec < warntime && !quietlog)
(void)printf("Warning: your account expires on %s",
ctime(&pwd->pw_expire));
}
warntime = login_getcaptime(lc, "warnpassword",
DEFAULT_WARN, DEFAULT_WARN);
@ -431,18 +444,6 @@ main(argc, argv)
ctime(&pwd->pw_change));
}
warntime = login_getcaptime(lc, "warnexpire",
DEFAULT_WARN, DEFAULT_WARN);
if (pwd->pw_expire) {
if (tp.tv_sec >= pwd->pw_expire) {
refused("Sorry -- your account has expired",
"EXPIRED", 1);
} else if (pwd->pw_expire - tp.tv_sec < warntime && !quietlog)
(void)printf("Warning: your account expires on %s",
ctime(&pwd->pw_expire));
}
if (lc != NULL) {
if (hostname) {
struct addrinfo hints, *res;