1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-02 06:03:50 +00:00

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)
This commit is contained in:
Baptiste Daroussin 2011-09-09 08:10:29 +00:00
parent 8c75fec409
commit 7626bb39cb
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=281486

View File

@ -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; \