From csl@whale.sunbay.crimea.ua  Sun Mar 30 05:56:38 1997
Received: from whale.sunbay.crimea.ua (sunbay-10BASE-T.cris.net [194.93.176.88])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA25445
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 30 Mar 1997 05:56:32 -0800 (PST)
Received: (from csl@localhost) by whale.sunbay.crimea.ua (8.8.5/1.6) id QAA07163; Sun, 30 Mar 1997 16:59:38 +0400 (MSD)
Message-Id: <199703301259.QAA07163@whale.sunbay.crimea.ua>
Date: Sun, 30 Mar 1997 16:59:38 +0400 (MSD)
From: Sergei Chechetkin <csl@whale.sunbay.crimea.ua>
Reply-To: csl@whale.sunbay.crimea.ua
To: FreeBSD-gnats-submit@freebsd.org
Subject: ~/.hushlogin and expire time checks don't work in /usr/bin/login
X-Send-Pr-Version: 3.2

>Number:         3144
>Category:       bin
>Synopsis:       ~/.hushlogin and expire time checks don't work in /usr/bin/login
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    davidn
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 30 06:00:01 PST 1997
>Closed-Date:    Tue Apr 1 21:54:16 EST 1997
>Last-Modified:  Tue Apr  1 21:55:40 EST 1997
>Originator:     Sergei Chechetkin
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Sunbay Development Group
>Environment:
>Description:

	Due to misplaced figure brackets code that checks for existing
	~/.hushlogin and expire time is executed only if pw->pw_dir 
	has incorrect value. Code is not executed in normal way.

	Points are against revision 1.23 of usr.bin/login/login.c
	
	
	Line 538:
		if (chdir("/") < 0) {   
			refused("Cannot find root directory", "ROOTDIR", 1);
		pwd->pw_dir = "/";
		if (!quietlog || *pwd->pw_dir)
	
	here is first incorrect bracket

	Line 561:

		if (tp.tv_sec >= pwd->pw_change) {
			(void)printf("Sorry -- your password has expired.\n");
			changepass=1;
			syslog(LOG_INFO,
			       "%s Password expired - forcing change",
			       pwd->pw_name);
		} else if (pwd->pw_change - tp.tv_sec < warntime && !quietlog)
		    (void)printf("Warning: your password expires on %s",
				 ctime(&pwd->pw_change));
		}
		^
	as we can see this bracket must not be here. it's reverse
	bracket. so code compiles correctly but /usr/bin/login does not
	work as it must.

>How-To-Repeat:

	Create .hushlogin in your home directory and relogin.
	Motd, last login time, etc are still shown.

>Fix:
	
	Patch that removes two incorrect brackets:

*** login.c.orig	Sun Mar 30 16:49:35 1997
--- login.c	Sun Mar 30 16:49:50 1997
***************
*** 535,541 ****
  		if (login_getcapbool(lc, "requirehome", !rootlogin))
  			refused("Home directory not available", "HOMEDIR", 1);
  #endif
! 		if (chdir("/") < 0) {
  			refused("Cannot find root directory", "ROOTDIR", 1);
  		pwd->pw_dir = "/";
  		if (!quietlog || *pwd->pw_dir)
--- 535,541 ----
  		if (login_getcapbool(lc, "requirehome", !rootlogin))
  			refused("Home directory not available", "HOMEDIR", 1);
  #endif
! 		if (chdir("/") < 0) 
  			refused("Cannot find root directory", "ROOTDIR", 1);
  		pwd->pw_dir = "/";
  		if (!quietlog || *pwd->pw_dir)
***************
*** 567,573 ****
  		} else if (pwd->pw_change - tp.tv_sec < warntime && !quietlog)
  		    (void)printf("Warning: your password expires on %s",
  				 ctime(&pwd->pw_change));
- 		}
  	}
  
  #ifdef LOGIN_CAP
--- 567,572 ----
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: davidn 
State-Changed-When: Tue Apr 1 21:47:38 EST 1997 
State-Changed-Why:  
Patch & diagnosis appears to be correct. 


Responsible-Changed-From-To: freebsd-bugs->davidn 
Responsible-Changed-By: davidn 
Responsible-Changed-When: Tue Apr 1 21:47:38 EST 1997 
Responsible-Changed-Why:  
I last worked on login. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: davidn 
State-Changed-When: Tue Apr 1 21:54:16 EST 1997 
State-Changed-Why:  
Patch applied in login.c r1.24. 
>Unformatted:
