Hello,

Matt Taggart said on Fri, Mar 06, 2009 at 12:03:34PM -0800:
> > During install I have:
> > adduser: unrecognized option `--gecos'
> > 
> > Seems this is not a portable option (especially on CentOS 5 I'm testing
> > now).

Indeed:

In my chroot CentOS:
# adduser --help
Usage: useradd [options] LOGIN

Options:
  -b, --base-dir BASE_DIR       base directory for the new user account
                                home directory
  -c, --comment COMMENT         set the GECOS field for the new user
account
  -d, --home-dir HOME_DIR       home directory for the new user account
  -D, --defaults                print or save modified default useradd
                                configuration
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP for the new user account
  -G, --groups GROUPS           list of supplementary groups for the new
                                user account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           specify an alternative skel directory
  -K, --key KEY=VALUE           overrides /etc/login.defs defaults
  -m, --create-home             create home directory for the new user
                                account
  -l,                       do not add user to lastlog database file
  -M,                       do not create user's home directory(overrides 
/etc/login.defs)
  -r,                       create system account
  -o, --non-unique              allow create user with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new user
                                account
  -s, --shell SHELL             the login shell for the new user account
  -u, --uid UID                 force use the UID for the new user account
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user 
mapping


> Background: useradd is specified by the LSB so we know we can count on that 
> being there and behaving properly, but on systems where adduser exists we 
> use that in order to take advantage of --system.

Wouldn't it be easier to always work the same at install time ? Always
use useradd and the reduced set of common options ? And code the rest
(or re-use code from another app). Just a suggestion of course.

> We probably want to use useradd on CentOS5, I wonder why it's using adduser?

Good question. Maybe because it's there ;-):w!

> On some systems we ran into the fact that adduser was a symlink to useradd 
> (which is braindead) 

Probably done for compatibility purposes. Indeed, this is the case on
CentOS:

# ls -al /usr/sbin/adduser /usr/sbin/useradd
lrwxrwxrwx 1 root root     7 Feb 11 11:11 /usr/sbin/adduser -> useradd
-rwxr-x--- 1 root root 72964 May 24  2008 /usr/sbin/useradd

> so I made the code check for that case. Here's the code
> 
>       if [ -f /usr/sbin/adduser -a ! -L /usr/sbin/adduser ]; then
>          adduser --gecos "" --ingroup  --system \
>            --shell /bin/bash --home "${REPO%/*}"
>       else
>          useradd -c "" -g  -m \
>            -s /bin/bash -d "${REPO%/*}"
>       fi
> 
> On CentOS 5 is adduser a real file?

No.
I tested your if command, and indeed in the chroot I go in the else
clause. So not sure how we ended up in the if :-(

BTW, my code rather reads:
if which adduser; then
         adduser --gecos "{$PROJECT}" --ingroup {$PROJECTGROUP} --system \
           --shell /bin/bash --home "$\{REPO%/*\}" {$PROJECTUSER}
      else
         useradd -c "{$PROJECT}" -g {$PROJECTGROUP} -m \
           -s /bin/bash -d "$\{REPO%/*\}" {$PROJECTUSER}
      fi
(SVN tree as of now).
Do I miss a patch ?

useradd, as per the FHS, is always under /usr/sbin, so again, using that
one only by testing its full pathname may make things simpler.

Here is the log on screen of the failed install:
*** Creating user and group ***
NOTE: group 'fossy' already exists, good.
/usr/sbin/adduser
adduser: unrecognized option `--gecos'
Usage: useradd [options] LOGIN

Bruno.
-- 
Linux Profession Lead EMEA  / Open Source Ambassador \   EMEA CME Sol. Center
http://www.mondorescue.org / HP/Intel Solution Center \  http://hpintelco.net
Des infos sur Linux?  http://www.HyPer-Linux.org      http://www.hp.com/linux
La musique ancienne?  http://www.musique-ancienne.org http://www.medieval.org
_______________________________________________
fossology mailing list
[email protected]
http://fossology.org/mailman/listinfo/fossology

Reply via email to