diff options
author | Mike Pritchard <mpp@FreeBSD.org> | 1995-07-16 18:49:12 +0000 |
---|---|---|
committer | Mike Pritchard <mpp@FreeBSD.org> | 1995-07-16 18:49:12 +0000 |
commit | 2ae24df1326ff3e3e47c4957ef275d803d3c0eb5 (patch) | |
tree | 5b768e37e2e16a49618408e5a4278dca6e019f3b /chpass/util.c | |
parent | 2eee1f7e7f16cca1adf13343a9d0e39fad958d29 (diff) | |
download | pw-darwin-2ae24df1326ff3e3e47c4957ef275d803d3c0eb5.tar.gz pw-darwin-2ae24df1326ff3e3e47c4957ef275d803d3c0eb5.tar.zst pw-darwin-2ae24df1326ff3e3e47c4957ef275d803d3c0eb5.zip |
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.
Diffstat (limited to 'chpass/util.c')
-rw-r--r-- | chpass/util.c | 20 |
1 files changed, 9 insertions, 11 deletions
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); } |