From nobody@FreeBSD.org  Sun Dec 12 23:39:16 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1603D16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Dec 2004 23:39:16 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 00CB143D45
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Dec 2004 23:39:16 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id iBCNdFKv093813
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Dec 2004 23:39:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id iBCNdFx5093812;
	Sun, 12 Dec 2004 23:39:15 GMT
	(envelope-from nobody)
Message-Id: <200412122339.iBCNdFx5093812@www.freebsd.org>
Date: Sun, 12 Dec 2004 23:39:15 GMT
From: Rostislav Krasny <rosti_bsd@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hushlogin and nocheckmail attributes don't work from user's '.login_conf'
X-Send-Pr-Version: www-2.3

>Number:         75001
>Category:       bin
>Synopsis:       hushlogin and nocheckmail attributes don't work from user's '.login_conf'
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 12 23:40:28 GMT 2004
>Closed-Date:    Mon Jun 13 12:27:48 GMT 2005
>Last-Modified:  Mon Jun 13 12:27:48 GMT 2005
>Originator:     Rostislav Krasny
>Release:        5.3-RELEASE
>Organization:
>Environment:
FreeBSD saturn 5.3-RELEASE-p2 FreeBSD 5.3-RELEASE-p2 #1: Fri Dec  3 13:57:01 IST 2004     root@saturn:/usr/obj/usr/src/sys/MYKERNEL  i386
>Description:
hushlogin and nocheckmail attributes don't work from user's '.login_conf' because they are not checked there. My patch of login(1) allows these attributes to work from the user's '.login_conf' as well as from the '/etc/login.conf'.
>How-To-Repeat:
Try each of following versions of your ~/.login_conf file:

####### first version #######
me:\
        :hushlogin:
####### first version #######

####### second version #######
me:\
        :nocheckmail:
####### second version #######

And then relogin.
>Fix:
--- /usr/src/usr.bin/login/login.c      Mon Jan 26 22:04:47 2004
+++ login.c     Mon Dec 13 00:16:14 2004
@@ -171,6 +171,7 @@
        const char *tp;
        const char *shell = NULL;
        login_cap_t *lc = NULL;
+       login_cap_t *lc_user = NULL;
        pid_t pid;

        (void)signal(SIGQUIT, SIG_IGN);
@@ -354,8 +355,10 @@
         * Establish the login class.
         */
        lc = login_getpwclass(pwd);
+       lc_user = login_getuserclass(pwd);

-       quietlog = login_getcapbool(lc, "hushlogin", 0);
+       if (!(quietlog = login_getcapbool(lc_user, "hushlogin", 0)))
+               quietlog = login_getcapbool(lc, "hushlogin", 0);

        /*
         * Switching needed for NFS with root access disabled.
@@ -568,7 +571,8 @@
                else
                        motd(_PATH_MOTDFILE);

-               if (login_getcapbool(lc, "nocheckmail", 0) == 0) {
+               if (login_getcapbool(lc_user, "nocheckmail", 0) == 0 &&
+                   login_getcapbool(lc, "nocheckmail", 0) == 0) {
                        char *cx;

                        /* $MAIL may have been set by class. */

>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: bug-followup@freebsd.org
Cc:  
Subject: bin/75001
Date: Mon, 23 May 2005 17:29:54 +0400 (MSD)

 Am I right you missed login_close(lc_user) call near the line 592?
 
 -- 
 Maxim Konovalov

From: Rostislav Krasny <rosti.bsd@gmail.com>
To: Maxim Konovalov <maxim@macomnet.ru>
Cc: bug-followup@freebsd.org
Subject: Re: bin/75001
Date: Tue, 31 May 2005 12:16:09 +0200

 This is a multi-part message in MIME format.
 --------------050207050407070605070907
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Maxim Konovalov wrote:
 > Am I right you missed login_close(lc_user) call near the line 592?
 
 Yes, you are absolutely right. New diff is attached to this email.
 
 
 --------------050207050407070605070907
 Content-Type: text/plain;
  name="login.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="login.diff"
 
 diff -ur login.orig/login.c /usr/src/usr.bin/login/login.c
 --- login.orig/login.c	Mon Jan 26 22:04:47 2004
 +++ /usr/src/usr.bin/login/login.c	Tue May 31 10:56:34 2005
 @@ -171,6 +171,7 @@
  	const char *tp;
  	const char *shell = NULL;
  	login_cap_t *lc = NULL;
 +	login_cap_t *lc_user = NULL;
  	pid_t pid;
  
  	(void)signal(SIGQUIT, SIG_IGN);
 @@ -354,8 +355,10 @@
  	 * Establish the login class.
  	 */
  	lc = login_getpwclass(pwd);
 +	lc_user = login_getuserclass(pwd);
  
 -	quietlog = login_getcapbool(lc, "hushlogin", 0);
 +	if (!(quietlog = login_getcapbool(lc_user, "hushlogin", 0)))
 +		quietlog = login_getcapbool(lc, "hushlogin", 0);
  
  	/*
  	 * Switching needed for NFS with root access disabled.
 @@ -568,7 +571,8 @@
  		else
  			motd(_PATH_MOTDFILE);
  
 -		if (login_getcapbool(lc, "nocheckmail", 0) == 0) {
 +		if (login_getcapbool(lc_user, "nocheckmail", 0) == 0 &&
 +		    login_getcapbool(lc, "nocheckmail", 0) == 0) {
  			char *cx;
  
  			/* $MAIL may have been set by class. */
 @@ -585,6 +589,7 @@
  		}
  	}
  
 +	login_close(lc_user);
  	login_close(lc);
  
  	(void)signal(SIGALRM, SIG_DFL);
 
 --------------050207050407070605070907--
 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Wed Jun 1 12:23:25 GMT 2005 
State-Changed-Why:  
Fixed in HEAD, thanks! 


Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Wed Jun 1 12:23:25 GMT 2005 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=75001 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Mon Jun 13 12:27:29 GMT 2005 
State-Changed-Why:  
MFCed to RELENG_5, thanks! 

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