summaryrefslogtreecommitdiff
path: root/mk/pkginstall
diff options
context:
space:
mode:
authorjoerg <joerg>2009-03-08 19:39:03 +0000
committerjoerg <joerg>2009-03-08 19:39:03 +0000
commitac33f5de71ebef5da2db0b051d6a3c858960e873 (patch)
tree0989a88ad37999f30334051f5f792ade7274fa43 /mk/pkginstall
parent0b07a0826be4e60f3ce540571320044b0ebb583b (diff)
downloadpkgsrc-ac33f5de71ebef5da2db0b051d6a3c858960e873.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/pkginstall')
-rw-r--r--mk/pkginstall/usergroupfuncs.Linux43
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
}