diff options
author | joerg <joerg@pkgsrc.org> | 2009-03-08 19:39:03 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2009-03-08 19:39:03 +0000 |
commit | e1659a7b564cbc6076c2c9eb8feda1e3359d5239 (patch) | |
tree | 0989a88ad37999f30334051f5f792ade7274fa43 /mk | |
parent | 37601b1ca409d31f82d5b109792e5122b462b132 (diff) | |
download | pkgsrc-e1659a7b564cbc6076c2c9eb8feda1e3359d5239.tar.gz |
Try to work around the mess called useradd on Linux. On Red Hat derived
distributions, useradd will create the home directory by default and
there is support for an option to disable that. Other Linux
distrubutions either lack the option in login.defs or the support for
-M. As workaround look for the option and if it is set, force -M.
Tested by Jens Rehsack. Addresses PR 40737.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/pkginstall/usergroupfuncs.Linux | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/mk/pkginstall/usergroupfuncs.Linux b/mk/pkginstall/usergroupfuncs.Linux index de15ff8135a..57be340c927 100644 --- a/mk/pkginstall/usergroupfuncs.Linux +++ b/mk/pkginstall/usergroupfuncs.Linux @@ -1,4 +1,4 @@ -# $NetBSD: usergroupfuncs.Linux,v 1.4 2009/02/02 19:54:22 joerg Exp $ +# $NetBSD: usergroupfuncs.Linux,v 1.5 2009/03/08 19:39:03 joerg Exp $ # # Platform-specific adduser and addgroup functionality # on top of shadow-utils. (Not libuser) @@ -83,6 +83,30 @@ user_exists() ${RM} -fr $_tmpdir; return 3 } +# The useradd command on Linux is a complete mess. +# At least Red Hat derivatives want to create home directories +# by default. They have support for -M, but no --help. +# Other Linux distributions lack -M support, some at least have +# --help. +# LSB just wants useradd, but doesn't specify any behavior, so +# it is useless for writing portable scripts. + +call_useradd() +{ + case $userid in + "") + ${USERADD} \ + -c "$descr" -d "$home" -s "$shell" \ + -g $group $user "$@" + ;; + *) + ${USERADD} \ + -c "$descr" -d "$home" -s "$shell" \ + -g $group -u $userid $user "$@" + ;; + esac +} + # adduser user group [userid] [descr] [home] [shell] adduser() { @@ -104,18 +128,11 @@ adduser() if ${TEST} -n "${USERADD}" -a -x "${USERADD}"; then ${ECHO} "${PKGNAME}: Creating user \`\`$user''" - case $userid in - "") - ${USERADD} \ - -c "$descr" -d "$home" -s "$shell" \ - -g $group $user -M - ;; - *) - ${USERADD} \ - -c "$descr" -d "$home" -s "$shell" \ - -g $group -u $userid $user -M - ;; - esac + if grep -i -- "^CREATE_HOME.*yes" /etc/login.defs > /dev/null; then + call_useradd -M + else + call_useradd + fi fi return 0 } |