From nobody@FreeBSD.org  Wed Apr 18 08:47:23 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 3ACC037B424
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Apr 2001 08:47:23 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f3IFlNx24895;
	Wed, 18 Apr 2001 08:47:23 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200104181547.f3IFlNx24895@freefall.freebsd.org>
Date: Wed, 18 Apr 2001 08:47:23 -0700 (PDT)
From: dan@freebsddiary.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: rmuser xyz reports incorrect error message if xyz does not exist
X-Send-Pr-Version: www-1.0

>Number:         26674
>Category:       bin
>Synopsis:       rmuser xyz reports incorrect error message if xyz does not exist
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    adrian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 18 08:50:01 PDT 2001
>Closed-Date:    Fri May 25 08:04:28 PDT 2001
>Last-Modified:  Fri May 25 08:05:54 PDT 2001
>Originator:     Dan Langille
>Release:        4.3-BETA
>Organization:
The FreeBSD Diary / FreshPorts
>Environment:
FreeBSD ns1.unixathome.org 4.3-BETA FreeBSD 4.3-BETA #1: Tue Mar 13 16:03:23 NZD
T 2001     root@xeon.int.nz.freebsd.org:/usr/obj/usr/src/sys/DUCKY  i386
>Description:
if you use rmuser to remove a user which does not exist, the message is:

/usr/sbin/rmuser: Error: I'd rather not remove a user with a uid of 0.

The message should be:

/usr/sbin/rmuser: Error: User xyz not in password database
>How-To-Repeat:
Remove a user which does not exist

# grep xyz /etc/passwd
# rmuser xyz
/usr/sbin/rmuser: Error: I'd rather not remove a user with a uid of 0.
#
>Fix:
The problem appears to be with the return value from getpwnam.  Here's
some code from /usr/sbin/rmuser.  mux is hunting around for more info.

($name, $password, $uid, $gid, $change, $class, $gecos, $home_dir, $shell) =
    (getpwnam("$login_name"));

if ($?) {
    print STDERR "${whoami}: Error: User ${login_name} not in password database\
    &unlockpw;
    exit 1;
}

if ($uid == 0) {
    print "${whoami}: Error: I'd rather not remove a user with a uid of 0.\n";
    &unlockpw;
    exit 1;
}
>Release-Note:
>Audit-Trail:

From: Maxime Henrion <mux@qualys.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/26674: rmuser xyz reports incorrect error message if xyz does not exist
Date: Wed, 18 Apr 2001 18:08:26 +0200

 --7AUc2qLy4jB3hD7Z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Here is the patch.
 
 Thanks to Anton Berezin <tobez@tobez.org> :-)
 
 mux
 -- 
 Don't be fooled by cheap finnish imitations ; BSD is the One True Code
 Key fingerprint = F9B6 1D5A 4963 331C 88FC  CA6A AB50 1EF2 8CBE 99D6
 Public Key : http://www.epita.fr/~henrio_m/
 
 --7AUc2qLy4jB3hD7Z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="rmuser.diff"
 
 *** /usr/src/usr.sbin/adduser/rmuser.perl	Sun Jan 14 11:21:11 2001
 --- src/rmuser.perl	Wed Apr 18 18:02:17 2001
 ***************
 *** 120,126 ****
   ($name, $password, $uid, $gid, $change, $class, $gecos, $home_dir, $shell) =
       (getpwnam("$login_name"));
   
 ! if ($?) {
       print STDERR "${whoami}: Error: User ${login_name} not in password database\n";
       &unlockpw;
       exit 1;
 --- 120,126 ----
   ($name, $password, $uid, $gid, $change, $class, $gecos, $home_dir, $shell) =
       (getpwnam("$login_name"));
   
 ! if (!defined $uid) {
       print STDERR "${whoami}: Error: User ${login_name} not in password database\n";
       &unlockpw;
       exit 1;
 
 --7AUc2qLy4jB3hD7Z--
Responsible-Changed-From-To: freebsd-bugs->adrian 
Responsible-Changed-By: adrian 
Responsible-Changed-When: Wed May 2 06:27:37 PDT 2001 
Responsible-Changed-Why:  
I'll take this one over, since I have my fingers in the adduser code atm 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26674 
State-Changed-From-To: open->closed 
State-Changed-By: adrian 
State-Changed-When: Fri May 25 08:04:28 PDT 2001 
State-Changed-Why:  


Commited in HEAD: rev 1.16 
commited in RELENG_4: rev 1.8.2.4 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=26674 
>Unformatted:
