adduser/addgroup vs portable useradd/groupadd

Natanael Copa ncopa at alpinelinux.org
Mon Feb 15 16:42:25 UTC 2016


Hi,

As you may know, busybox has been the core of Alpine Linux for a
decade. One of the things that has been necessary for its success has
been that busybox has followed the standards, making the tools
compatible with the corresponding bigger tools.

Even GNU extensions and long-opts have been implemented whenever that
has made sense, and busybox has always been good at doing so in a
portable way.

One exception of this has been the adduser/addgroup tools, and it is
starting to become a problem[1]. Scripts that work on many other
systems needs to be handled special when busybox adduser/addgroup is
needed.

A co-worker did some investigation of the adduser/addgroup vs
useradd/group add implementations on various systems to get an idea
what is the most portable.

I think that what would make most sense is to add useradd and groupadd
to busybox.

What do you think?



useradd, groupadd

Debian, Ubuntu

"useradd is a low level utility for adding users. On Debian,
administrators should usually use adduser(8) instead."

http://manpages.ubuntu.com/manpages/trusty/man8/useradd.8.html
http://manpages.ubuntu.com/manpages/trusty/man8/groupadd.8.html

useradd is not interactive, and supports both long and short command
options, eg -g and --gid. SUpports getting and setting defaults options
with -D. The short options are very similar to many other systems, and
the exit codes correspond to HPUX wg 4=uid alread in use and -o not
specified.

Redhat, Centos

useradd and groupadd are symlinks to adduser, addgroup. These are
basically the same as the Debian, Ubuntu useradd commands, with long
and short form options and the multiple return values for scripting.

Busybox

no useradd or groupadd applets.

HPUX

useradd very like Linux one with only short options eg -g, and supports
-D to set defaults. groupadd only supports -g and -o. Provides 10 exit
codes for different types of failure.

http://ods.com.ua/win/eng/unix/usail/man/hpux/useradd.1.html
http://ods.com.ua/win/eng/unix/usail/man/hpux/groupadd.1.html

claims: STANDARDS COMPLIANCE: useradd: SVID3 groupadd: SVID3

FreeBSD, NetBSD

short form options only, supports -D to change defaults. Man page does
not mention return values.

SVID

System V Interface Definition, Fourth Edition Volume 2
http://www.sco.com/developers/devspecs/vol2.pdf

useradd is specified in here, with short form options, without -D to set defaults.
useradd [-u uid [-o] [-i]] [-g group] [-G group[[,group] . . . ]] [-d dir]
[-s shell] [-c comment] [-m [-k skel_dir] -f inactive] [-e expire]
[-h level [-h level [ . . . ]]] [-v def_level] [-w hd_level] [-a event[, . . . ]]
login

adduser

Debian, Ubuntu

adduser, addgroup are the same perl script. Only accept long form
options.

Redhat, Centos

Exactly same as Debian and Ubuntu version of useradd.

Busybox

Short form options only. Do not correspond to standard useradd options
though - eg -D is used for different purpose.

NetBSD, FreeBSD

No adduser.

--

[1]: https://github.com/docker/docker/blob/master/pkg/idtools/usergroupadd_linux.go#L11-L16


More information about the busybox mailing list