From nobody@FreeBSD.ORG Mon Oct 25 00:41:11 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id DBA571507F; Mon, 25 Oct 1999 00:41:11 -0700 (PDT)
Message-Id: <19991025074111.DBA571507F@hub.freebsd.org>
Date: Mon, 25 Oct 1999 00:41:11 -0700 (PDT)
From: kondo@ysyslab.co.jp
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: chapss Y2K problem
X-Send-Pr-Version: www-1.0

>Number:         14511
>Category:       misc
>Synopsis:       chpass Y2K problem
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cjc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 25 00:50:00 PDT 1999
>Closed-Date:    Thu Mar 21 02:33:37 PST 2002
>Last-Modified:  Thu Mar 21 02:33:37 PST 2002
>Originator:     kondo hiroshi
>Release:        FreeBSD 3.3
>Organization:
Yokohama System Laboratory
>Environment:
FreeBSD mike.ysyslab.co.jp 3.3-RELEASE FreeBSD 3.3-RELEASE #6: Wed Oct 13 15:44:57 JST 1999     root@mike.ysyslab.co.jp:/usr/src/sys/compile/SB16  i386
>Description:
chpass expire date (year ploblem)
"-e Dec 6 99"  is OK.
"-e Dec 6 00"  is error.
"-e Dec 6 01"  is OK.

>How-To-Repeat:
# chpass "-e Dec 6 00" username
chpass: illegal date for expire field
chpass: /etc/master.passwd: unchanged
>Fix:
chpass "-e Dec 6 2000" username
chpass: updating the database...
chpass: done

>Release-Note:
>Audit-Trail:

From: Mike Pritchard <mpp@mpp.pro-ns.net>
To: kondo@ysyslab.co.jp
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/14511: chapss Y2K problem
Date: Mon, 25 Oct 1999 05:12:06 -0500

 On Mon, Oct 25, 1999 at 12:41:11AM -0700, kondo@ysyslab.co.jp wrote:
 > >Synopsis:       chapss Y2K problem
 > chpass expire date (year ploblem)
 > "-e Dec 6 99"  is OK.
 > "-e Dec 6 00"  is error.
 > "-e Dec 6 01"  is OK.
 
 The following patch fixes the problem, but I noticed that the commit
 that broke this advertises that it supports single digit years in the
 range 69 - 68, meaning 1968 - 2068.  This doesn't work.  chpass
 fails if you try to set a date beyond Jan 18, 2038.  I think the call
 to mktime() fails for dates beyond that, because that is the last
 date that can be stored in one of our time_t variables (someone
 correct me if I'm wrong).
 
 I also noticed that the "-e" flag isn't documented in the man page.
 If no one else steps up and commits a fix, I'll do it next time I 
 have some spare time.  I only took a look at this because
 I fixed/rewrote some of the routine that handles password
 change/expiration dates several years ago, and I was curious to see
 if it was my change that messed it up.
 
 It might be possible for chpass to incorrectly set the expiration
 year to 2000 if atoi returns zero due to the input string being
 garbled.  The atot routine in chpass should probably be changed
 to call strtol() directly and test the return values to see if
 it was given a valid string of all digits.  That was what the
 previous !year check was for, but the two digit year change messed
 that up.
 
 -Mike
 
 Index: util.c
 ===================================================================
 RCS file: /shared/ncvs/src/usr.bin/chpass/util.c,v
 retrieving revision 1.8
 diff -u -r1.8 util.c
 --- util.c	1999/08/28 00:59:39	1.8
 +++ util.c	1999/10/25 09:48:54
 @@ -113,7 +113,7 @@
  	if (!(t = strtok((char *)NULL, " \t,")) || !isdigit(*t))
  		goto bad;
  	year = atoi(t);
 -	if (day < 1 || day > 31 || month < 1 || month > 12 || !year)
 +	if (day < 1 || day > 31 || month < 1 || month > 12)
  		goto bad;
  	/* Allow two digit years 1969-2068 */
  	if (year < 69)
 
 -- 
 Mike Pritchard
 mpp@FreeBSD.org or mpp@mpp.pro-ns.net
 
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Mon Jan 21 13:26:52 PST 2002 
State-Changed-Why:  

Can this be closed, now that it has become a Y3K problem? :-) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=14511 
State-Changed-From-To: feedback->analyzed 
State-Changed-By: cjc 
State-Changed-When: Mon Mar 18 01:49:37 PST 2002 
State-Changed-Why:  
Fixed in -CURRENT. 


Responsible-Changed-From-To: freebsd-bugs->cjc 
Responsible-Changed-By: cjc 
Responsible-Changed-When: Mon Mar 18 01:49:37 PST 2002 
Responsible-Changed-Why:  
I've been working in chpass(8). Looking at fixing some old PRs. Will 
handle MFC to -STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=14511 
State-Changed-From-To: analyzed->closed 
State-Changed-By: cjc 
State-Changed-When: Thu Mar 21 02:33:11 PST 2002 
State-Changed-Why:  
MFC'ed to -STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=14511 
>Unformatted:
