mirror of
https://github.com/void-linux/void-packages.git
synced 2025-08-02 10:52:57 +02:00
xbps-triggers: don't delete users and groups on package removal.
Also, change the shell to /bin/false and insure that the account is locked. Fixes #345.
This commit is contained in:
parent
cf19729918
commit
faa0a79220
2 changed files with 20 additions and 25 deletions
|
@ -53,15 +53,12 @@ run)
|
||||||
if [ -x sbin/useradd -o -x bin/useradd ]; then
|
if [ -x sbin/useradd -o -x bin/useradd ]; then
|
||||||
USERADD=1
|
USERADD=1
|
||||||
fi
|
fi
|
||||||
if [ -x sbin/userdel -o -x bin/userdel ]; then
|
if [ -x sbin/usermod -o -x bin/usermod ]; then
|
||||||
USERDEL=1
|
USERMOD=1
|
||||||
fi
|
fi
|
||||||
if [ -x sbin/groupadd -o -x bin/groupadd ]; then
|
if [ -x sbin/groupadd -o -x bin/groupadd ]; then
|
||||||
GROUPADD=1
|
GROUPADD=1
|
||||||
fi
|
fi
|
||||||
if [ -x sbin/groupdel -o -x bin/groupdel ]; then
|
|
||||||
GROUPDEL=1
|
|
||||||
fi
|
|
||||||
if [ -x bin/getent -o -x sbin/getent ]; then
|
if [ -x bin/getent -o -x sbin/getent ]; then
|
||||||
GETENT=1
|
GETENT=1
|
||||||
fi
|
fi
|
||||||
|
@ -120,36 +117,34 @@ run)
|
||||||
echo "Failed to create ${acct} system user!"
|
echo "Failed to create ${acct} system user!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [ -z "$USERMOD" ]; then
|
||||||
|
echo "WARNING: cannot update ${acct} system user/group (missing usermod)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
usermod -c "${descr}" -s "${shell}" ${_uname} >/dev/null 2>&1
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Updated shell and comment for ${_uname} (${_uid}) system user."
|
||||||
|
else
|
||||||
|
echo "Failed to update shell and comment for ${acct} system user!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
pre-remove)
|
pre-remove)
|
||||||
#
|
|
||||||
# Only unregister if we aren't updating a package.
|
|
||||||
#
|
|
||||||
if [ "$UPDATE" = "no" ]; then
|
if [ "$UPDATE" = "no" ]; then
|
||||||
for acct in ${system_accounts}; do
|
for acct in ${system_accounts}; do
|
||||||
_uname="${acct%:*}"
|
_uname="${acct%:*}"
|
||||||
_uid="${acct#*:}"
|
_uid="${acct#*:}"
|
||||||
if [ -z "$USERDEL" ]; then
|
comment="$(getent passwd "${_uname}" |cut -d: -f5 |head -n1) - for uninstalled package ${PKGNAME}"
|
||||||
echo "WARNING: cannot remove ${acct} system user/group (missing userdel)"
|
if [ -z "$USERMOD" ]; then
|
||||||
|
echo "WARNING: cannot disable ${acct} system user/group (missing usermod)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
userdel -f ${_uname} >/dev/null 2>&1
|
usermod -L -s /bin/false -c "${comment}" ${_uname} >/dev/null 2>&1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Removed ${_uname} (${_uid}) system user/group."
|
echo "Disabled ${_uname} (${_uid}) system user/group."
|
||||||
fi
|
|
||||||
done
|
|
||||||
for grp in ${system_groups}; do
|
|
||||||
_uname="${grp%:*}"
|
|
||||||
_uid="${grp#*:}"
|
|
||||||
if [ -z "$GROUPDEL" ]; then
|
|
||||||
echo "WARNING: cannot remove ${grp} system group (missing groupdel)"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
groupdel ${_uname} >/dev/null 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo "Removed ${_uname} (${_uid}) system group."
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Template file for 'xbps-triggers'
|
# Template file for 'xbps-triggers'
|
||||||
pkgname=xbps-triggers
|
pkgname=xbps-triggers
|
||||||
version=0.104
|
version=0.105
|
||||||
revision=1
|
revision=1
|
||||||
noarch=yes
|
noarch=yes
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
|
|
Loading…
Add table
Reference in a new issue