From owner-freebsd-bugs Sat Jul 8 09:50:02 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id JAA09126 for bugs-outgoing; Sat, 8 Jul 1995 09:50:02 -0700 Received: (from gnats@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id JAA09113 ; Sat, 8 Jul 1995 09:50:01 -0700 Date: Sat, 8 Jul 1995 09:50:01 -0700 Message-Id: <199507081650.JAA09113@freefall.cdrom.com> From: mpp@legarto.minn.net Reply-To: mpp@legarto.minn.net To: freebsd-bugs Subject: bin/603: chpass screws up password change/expire fields In-Reply-To: Your message of Sat, 8 Jul 1995 11:46:50 -0500 <199507081646.LAA06672@mpp.minn.net> Sender: bugs-owner@FreeBSD.org Precedence: bulk >Number: 603 >Category: bin >Synopsis: chpass screws up password change/expire fields >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs (FreeBSD bugs mailing list) >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jul 8 09:50:00 1995 >Originator: Mike Pritchard >Organization: >Release: FreeBSD 2.0-BUILT-19950628 i386 >Environment: >Description: If the super-user uses chpass to edit a users password file entry, and that user happens to have a password change/expire date set, the change/expire date will be advanced by 1 day when the edit is complete. The date in question has to fall within the same daylight savings time period. E.g. setting a date of 8/1/95 will cause the date to advance on each edit, but a date of 12/1/95 will not. >How-To-Repeat: Run chpass and give an account a password expiration date. Run chpass again and note the current expiration date and then change something so that chpass will re-write the password file. Run chpass one last time and note that the expiration date has now advanced by one day. Repeat as desired. >Fix: Fix the atot() routine in chpass/util.c to use mktime() to generate the time fields, instead of doing all of the calculations itself and getting them wrong sometimes. --- orig/util.c Sat Jul 8 10:28:36 1995 +++ ./util.c Sat Jul 8 11:33:23 1995 @@ -49,8 +49,6 @@ #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 @@ 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); } >Audit-Trail: >Unformatted: