Re: (forw) Bug#294345: passwd: useradd does not create homedirs with "-" in the path
Tomasz Kłoczko <[email protected]> Thu, 10 Feb 2005 00:22:54 +0100 (CET)
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 9 Feb 2005, Christian Perrier wrote:
> Tomasz, this may be a good candidate for an upstream bug. Does it
> still exist in 4.0.7?
[..]
> Package: passwd
> Version: 1:4.0.3-30.8
> Severity: normal
>
> postamt:/home/t# /usr/sbin/useradd -m -d /home/x/-/testruebe testruebe
> useradd: cannot create directory /home/x/-/testruebe
>
> postamt:/home/t# /usr/sbin/useradd -m -d "/home/x/-/testruebe" testruebe
> useradd: cannot create directory /home/x/-/testruebe
>
> postamt:/home/t# /usr/sbin/useradd -m -d "/home/x/\-/testruebe" testruebe
> useradd: cannot create directory /home/x/\-/testruebe
>
> If I create the /home/x/- directory by hand, useradd works.
This not bug in useradd and also this is not a bug :o)
Root above is in standard behavior of getopt(), getopt_long() functions.
>From getopt(3) man page:
DESCRIPTION
The getopt() function parses the command line arguments. Its
arguments argc and argv are the argument count and array as passed to
the main() function on program invocation. An element of argv that
starts with '-' (and is not exactly "-" or "--") is an option
element. The characters of this element (aside from the initial '-')
are option characters. If getopt() is called repeatedly, it returns
successively each of the option characters from each of the option
elements.
So correct useradd commamd line parameters for above is:
# useradd -m -d -- /home/x/-/testruebe testruebe
kloczek
--
-----------------------------------------------------------
*Ludzie nie majÂą problemĂłw, tylko sobie sami je stwarzajÂą*
-----------------------------------------------------------
Tomasz KÂłoczko, sys adm @zie.pg.gda.pl|*e-mail: [email protected]*