NetBSD Problem Report #21146
Received: (qmail 1515 invoked by uid 605); 14 Apr 2003 08:09:41 -0000
Message-Id: <200304140809.h3E89bF00332@tnt.toves.net>
Date: Mon, 14 Apr 2003 04:09:37 -0400 (EDT)
From: Daniel Lamblin <daniell@tnt.toves.net>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: daniell@beachbash.net
To: gnats-bugs@gnats.netbsd.org
Subject: useradd --help
X-Send-Pr-Version: 3.95
>Number: 21146
>Category: bin
>Synopsis: useradd has left the password file locked.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: dsl
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Apr 14 08:10:00 +0000 2003
>Closed-Date: Fri Apr 25 19:36:38 +0000 2003
>Last-Modified: Fri Apr 25 19:36:38 +0000 2003
>Originator: Daniel Lamblin
>Release: NetBSD 1.6
>Organization:
netbsd hobbyist
>Environment:
System: NetBSD tnt 1.6 NetBSD 1.6 (PM8500wACARD6260wMX98715AEC) #0: Mon Apr 14 00:10:10 EDT 2003 root@tnt:/usr/src/sys/arch/macppc/compile/PM8500wACARD6260wMX98715AEC macppc
Architecture: powerpc
Machine: macppc
>Description:
I ran `useradd --help` which didn't work as I expected, but failed
in such a way as to leave my password file locked. It also left me
uncertain as to how to unlock it; it would be nice if it both didn't
do this, and made a helpful comment about proceeding on foot in case
of failure.
I'm supposing I just find and delete the pw_lock file, but do I need
to worry about anything being in an inconsistant state?
>How-To-Repeat:
root@tnt:~# adduser --help
bash: adduser: command not found
root@tnt:~# useradd --help
useradd: Warning: home directory `/home/--help' doesn't exist, and -m was not specified
usage: pwd_mkdb [-BLps] [-d directory] [-u user] file
useradd: pw_mkdb failed: No such file or directory
root@tnt:~# userdel --help
userdel: No such user `--help'
root@tnt:~# man useradd
:q
root@tnt:~# useradd -m -s /usr/pkg/bin/bash friend
useradd: can't obtain pw_lock: File exists
root@tnt:~# vipw
vipw: the passwd file is busy.
root@tnt:~# echo sigh
sigh
>Fix:
Don't pass variables to programs without first checking if they will be
seen as flags. Also do more exit code checking, though maybe --help
exits with 0.
>Release-Note:
>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: netbsd-bugs@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/21146: useradd --help
Date: Mon, 14 Apr 2003 10:55:25 +0100
> >Synopsis: useradd has left the password file locked.
The 'current' useradd reports:
# userdel --help
userdel: unknown option -- -
userdel: unknown option -- h
userdel: unknown option -- e
userdel: unknown option -- l
userdel: option requires an argument -- p
Usage: userdel -D [-p preserve]
Usage: userdel [-p preserve] [-r] [-v] user
and doesn't lock the password file.
I've just fixed it to report the usage on an unknown option.
I suspect that --help was escaping through libc's broken getopt() code in 1.6
Dunno what locked the pw file.
David
--
David Laight: david@l8s.co.uk
State-Changed-From-To: open->feedback
State-Changed-By: perry
State-Changed-When: Wed Apr 23 23:45:43 UTC 2003
State-Changed-Why:
Does the problem persist after David Laight's fix?
From: "Perry E. Metzger" <perry@piermont.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/21146
Date: 25 Apr 2003 12:25:57 -0400
Forwarded:
Date: Fri, 25 Apr 2003 12:20:43 -0500 (EST)
From: Daniel Lamblin <daniell@trillian.beachbash.net>
To: perry@netbsd.org
Cc: gnats-admin@netbsd.org
Subject: Re: bin/21146
On 23 Apr 2003 perry@netbsd.org wrote:
> Does the problem persist after David Laight's fix?
>
Well, I'm running 1.6, I havn't moved to -current nor 1.6.1
>From his post though it seems the problem is dealt with.
I still think checking the exit code of pwd_mkdb and either automatically
doing the cleanup or leaving a message as to how to proceed would be the
correct way to do it; in case another netbsd's getopts goes bad.
BTW, the correct file to get rid of is /etc/ptmp
Which contains a last line:
--help:*************:1006:100::0:0::/home/--help:/bin/csh
So since the passwd file is not committed after the fail, its not that
bad, as long as people can man vipw and look at the FILES section [which
isn't exactly what people expect to look up, they'd more likely look at
pwd_mkdb].
-Daniel
Responsible-Changed-From-To: bin-bug-people->dsl
Responsible-Changed-By: perry
Responsible-Changed-When: Fri Apr 25 19:20:46 UTC 2003
Responsible-Changed-Why:
David Laight seems to have been working on this...
State-Changed-From-To: feedback->closed
State-Changed-By: agc
State-Changed-When: Fri Apr 25 19:34:03 UTC 2003
State-Changed-Why:
dsl fixed the original problem - that bad option letters were being let
through to the functions which did all the work, and causing unexpected side-effects.
I'll close the PR now, and if anything untoward happens again, please raise
another PR.
Thanks for your help.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.