summaryrefslogtreecommitdiffstats
path: root/usr.bin/chpass/util.c
diff options
context:
space:
mode:
authormpp <mpp@FreeBSD.org>1995-07-16 18:49:12 +0000
committermpp <mpp@FreeBSD.org>1995-07-16 18:49:12 +0000
commite3afff6c25d39d4c845ff9307b3d769a5d31a688 (patch)
tree482a9a642d3ff5e62e9dd8a0306723331ab74630 /usr.bin/chpass/util.c
parent75e449c12d62a6af92debf09d9971e638bbe8b0d (diff)
downloadFreeBSD-src-e3afff6c25d39d4c845ff9307b3d769a5d31a688.zip
FreeBSD-src-e3afff6c25d39d4c845ff9307b3d769a5d31a688.tar.gz
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 'usr.bin/chpass/util.c')
-rw-r--r--usr.bin/chpass/util.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/usr.bin/chpass/util.c b/usr.bin/chpass/util.c
index 03c7677..8dfd388 100644
--- a/usr.bin/chpass/util.c
+++ b/usr.bin/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);
}
OpenPOWER on IntegriCloud