aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2011-09-09 16:10:29 +0800
committerbapt <bapt@FreeBSD.org>2011-09-09 16:10:29 +0800
commite8cd5112356c46556cc30442c7df6167a340871f (patch)
treed560b3d1b062ebef2778b22adb79415ba7ea46ed
parent5f3ceb6a0e1e106306e62d20b05f55f3bcb3e6b6 (diff)
downloadfreebsd-ports-gnome-e8cd5112356c46556cc30442c7df6167a340871f.tar.gz
freebsd-ports-gnome-e8cd5112356c46556cc30442c7df6167a340871f.tar.zst
freebsd-ports-gnome-e8cd5112356c46556cc30442c7df6167a340871f.zip
Simplify USERS/GROUPS management, use groupmod instead of usermod to append user to a group
This fix group management PR: ports/159577 Submitted by: sahil Reviewed by: flz Exp-run: bapt Approved by: portmgr (flz)
-rw-r--r--Mk/bsd.port.mk15
1 files changed, 7 insertions, 8 deletions
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 4f8974289b29..435cec57693a 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -4147,14 +4147,13 @@ create-users-groups:
IFS=","; for _login in $$members; do \
for _user in ${USERS}; do \
if [ "x$${_user}" = "x$${_login}" ]; then \
- list=`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'`; \
- ${ECHO_MSG} "Setting \`$${_login}' groups to \`$$list$${list:+,}${_group}'."; \
- ${PW} usermod $${_login} -G $$list$${list:+,}${_group}; \
- ${ECHO_CMD} "@exec list=\`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'\`; \
- echo \"Setting '$${_login}' groups to '$$list$${list:+,}${_group}'.\"; \
- ${PW} usermod $${_login} -G $${list},${_group}" >> ${TMPPLIST}; \
- else \
- ${ECHO_MSG} "==> DEBUG skip login $${_login} => not defined in USERS \"( ${USERS} )\""; \
+ if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
+ ${ECHO_MSG} "Adding user \`$${_login}' to group \`${_group}'."; \
+ ${PW} groupmod ${_group} -m $${_login}; \
+ fi; \
+ ${ECHO_CMD} "@exec if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
+ echo \"Adding user '$${_login}' to group '${_group}'.\"; \
+ ${PW} groupmod ${_group} -m $${_login}; fi" >> ${TMPPLIST}; \
fi; \
done; \
done; \