From marck@woozle.rinet.ru  Sun Aug  4 09:14:16 2002
Return-Path: <marck@woozle.rinet.ru>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A2D7037B400
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  4 Aug 2002 09:14:16 -0700 (PDT)
Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 821E343E70
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  4 Aug 2002 09:14:15 -0700 (PDT)
	(envelope-from marck@woozle.rinet.ru)
Received: (from marck@localhost)
	by woozle.rinet.ru (8.11.6/8.11.6) id g74GEDY84314;
	Sun, 4 Aug 2002 20:14:13 +0400 (MSD)
	(envelope-from marck)
Message-Id: <200208041614.g74GEDY84314@woozle.rinet.ru>
Date: Sun, 4 Aug 2002 20:14:13 +0400 (MSD)
From: Dmitry Morozovsky <marck@rinet.ru>
Reply-To: Dmitry Morozovsky <marck@rinet.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: reflect kernel building user for sudo-ers
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41317
>Category:       kern
>Synopsis:       reflect kernel building user for sudo-ers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    trhodes
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 04 09:20:01 PDT 2002
>Closed-Date:    Wed Feb 23 01:52:27 GMT 2005
>Last-Modified:  Wed Feb 23 01:52:27 GMT 2005
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4-STABLE i386
>Organization:
Cronyx Plus LLC (RiNet ISP)
>Environment:
System: FreeBSD 4-STABLE 

>Description:
	When using sudo instead of su, environment is slightly different.
In particular, both $USER and $LOGNAME are set to root after sudo -s. 
There is at least one annoying side effect of this: kernel build user 
mentioned is always 'root'.

In this case the only reliable way to get logged-in user name is 
/usr/bin/logname. Following patch utilizes it.

>How-To-Repeat:

For example, using old-way kernel compile:

sudo -s
cd /usr/src/sys/i386/conf
config GENERIC
cd ../../compile/GENERIC
make vers.c
grep compile vers.c

>Fix:

Index: newvers.sh
===================================================================
RCS file: /home/ncvs/src/sys/conf/newvers.sh,v
retrieving revision 1.44.2.24
diff -u -r1.44.2.24 newvers.sh
--- newvers.sh  16 Jun 2002 00:31:54 -0000      1.44.2.24
+++ newvers.sh  4 Aug 2002 15:30:14 -0000
@@ -85,7 +85,8 @@
 fi
 
 touch version
-v=`cat version` u=${USER-root} d=`pwd` h=`hostname` t=`date`
+u=`/usr/bin/logname`
+v=`cat version` u=${u-root} d=`pwd` h=`hostname` t=`date`
 cat << EOF > vers.c
 $COPYRIGHT
 char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };


>Release-Note:
>Audit-Trail:

From: Dmitry Morozovsky <marck@rinet.ru>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  
Subject: Re: kern/41317: reflect kernel building user for sudo-ers
Date: Sun, 4 Aug 2002 20:27:36 +0400 (MSD)

 On Sun, 4 Aug 2002, Dmitry Morozovsky wrote:
 
 Oops. It seems I missed colon (to handle sing-user mode kernel compiles
 correctly). Here is fixed patch:
 
 retrieving revision 1.44.2.24
 diff -u -r1.44.2.24 newvers.sh
 --- newvers.sh  16 Jun 2002 00:31:54 -0000      1.44.2.24
 +++ newvers.sh  4 Aug 2002 15:30:14 -0000
 @@ -85,7 +85,8 @@
  fi
 
  touch version
 -v=`cat version` u=${USER-root} d=`pwd` h=`hostname` t=`date`
 +u=`/usr/bin/logname`
 +v=`cat version` u=${u:-root} d=`pwd` h=`hostname` t=`date`
  cat << EOF > vers.c
  $COPYRIGHT
  char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
 
 
 Sincerely,
 D.Marck                                   [DM5020, DM268-RIPE, DM3-RIPN]
 ------------------------------------------------------------------------
 *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
 ------------------------------------------------------------------------
 
Responsible-Changed-From-To: freebsd-bugs->trhodes 
Responsible-Changed-By: trhodes 
Responsible-Changed-When: Thu Aug 22 09:54:41 PDT 2002 
Responsible-Changed-Why:  
I'll review this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41317 
State-Changed-From-To: open->closed 
State-Changed-By: trhodes 
State-Changed-When: Wed Feb 23 01:52:00 GMT 2005 
State-Changed-Why:  
Patched and MFCed by obrien or ru or someone.  :) 

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