From c708843e6a209b1c1f1a6d3e60b29be56d1d8894 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 2 Jul 2000 18:44:54 +1000 Subject: [PATCH] - (djm) Stop shadow expiry checking from preventing logins with NIS. Based on fix from HARUYAMA Seigo --- ChangeLog | 2 ++ auth.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d9dc9856..118416f6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 20000702 - (djm) Fix brace mismatch from Corinna Vinschen + - (djm) Stop shadow expiry checking from preventing logins with NIS. Based + on fix from HARUYAMA Seigo 20000701 - (djm) Fix Tru64 SIA problems reported by John P Speno diff --git a/auth.c b/auth.c index bf5306be4..5aeeec6de 100644 --- a/auth.c +++ b/auth.c @@ -65,17 +65,18 @@ allowed_user(struct passwd * pw) return 0; spw = getspnam(pw->pw_name); - if (spw == NULL) - return 0; - - /* Check account expiry */ - if ((spw->sp_expire > 0) && ((time(NULL) / 86400) > spw->sp_expire)) - return 0; + if (spw != NULL) { + int days = time(NULL) / 86400; - /* Check password expiry */ - if ((spw->sp_lstchg > 0) && (spw->sp_inact > 0) && - ((time(NULL) / 86400) > (spw->sp_lstchg + spw->sp_inact))) - return 0; + /* Check account expiry */ + if ((spw->sp_expire > 0) && (days > spw->sp_expire)) + return 0; + + /* Check password expiry */ + if ((spw->sp_lstchg > 0) && (spw->sp_inact > 0) && + (days > (spw->sp_lstchg + spw->sp_inact))) + return 0; + } #else /* Shouldn't be called if pw is NULL, but better safe than sorry... */ if (!pw)