From 2ae24df1326ff3e3e47c4957ef275d803d3c0eb5 Mon Sep 17 00:00:00 2001 From: Mike Pritchard Date: Sun, 16 Jul 1995 18:49:12 +0000 Subject: Fix chpass so that it doesn't advance the password change and expire dates by 1 day anytime root edits a user that has a change/expire date set. --- chpass/util.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'chpass/util.c') diff --git a/chpass/util.c b/chpass/util.c index 03c7677..8dfd388 100644 --- a/chpass/util.c +++ b/chpass/util.c @@ -49,8 +49,6 @@ static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; #include "chpass.h" #include "pathnames.h" -static int dmsize[] = - { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", @@ -114,15 +112,15 @@ atot(p, store) year += TM_YEAR_BASE; if (year <= EPOCH_YEAR) bad: return (1); - tval = isleap(year) && month > 2; - for (--year; year >= EPOCH_YEAR; --year) - tval += isleap(year) ? - DAYSPERLYEAR : DAYSPERNYEAR; - while (--month) - tval += dmsize[month]; - tval += day; - tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN; - tval -= lt->tm_gmtoff; + lt->tm_year = year - TM_YEAR_BASE; + lt->tm_mon = month - 1; + lt->tm_mday = day; + lt->tm_hour = 0; + lt->tm_min = 0; + lt->tm_sec = 0; + lt->tm_isdst = -1; + if ((tval = mktime(lt)) < 0) + return (1); *store = tval; return (0); } -- cgit v1.2.3-56-ge451