Bug 26674

Summary: rmuser xyz reports incorrect error message if xyz does not exist
Product: Base System Reporter: dan <dan>
Component: binAssignee: Adrian Chadd <adrian>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
rmuser.diff none

Description dan 2001-04-18 16:50:01 UTC
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

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;
}
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.
#
Comment 1 mux 2001-04-18 17:08:26 UTC
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/
Comment 2 Adrian Chadd freebsd_committer freebsd_triage 2001-05-02 14:27:37 UTC
Responsible Changed
From-To: freebsd-bugs->adrian

I'll take this one over, since I have my fingers in the adduser code atm
Comment 3 Adrian Chadd freebsd_committer freebsd_triage 2001-05-25 16:04:28 UTC
State Changed
From-To: open->closed



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