SHA256
1
0
forked from cockpit/cockpit
Files
cockpit/check_cockpit_users
Luna D Dragon f99ded1391 Add check for systemd dynamic users
Glibc provides /etc/nsswitch.conf but doesn't update it after first
install. This adds a check to ensure we have systemd dynamic support
present before running as we need dynamic users and a out of date
nsswitch overrides the up to date file in /usr/etc/ breaking support.
2025-05-08 13:06:57 +05:30

34 lines
1.1 KiB
Plaintext

#/bin/sh
bad_users_groups=("cockpit-wsinstance-socket" "cockpit-session-socket")
failed=false
for gu in "${bad_users_groups[@]}"; do
echo $gu
if getent passwd "$gu" > /dev/null; then
echo "user ${gu} exists, cockpit will fail to start up if this user exists, please run userdel ${gu} to resolve this"
failed=true
fi
if getent group "$gu" > /dev/null; then
echo "group ${gu} exists, cockpit will fail to start up if this group exists, please run groupdel ${gu} to resolve this"
failed=true
fi
done
if getent passwd cockpit-systemd-service > /dev/null; then
echo "user cockpit-systemd-service exists, cockpit will fail to start up if this group exists, please run userdel cockpit-systemd-service to resolve this"
failed=true
fi
if [ -f /etc/nsswitch.conf ]; then
grep -Fxq "passwd: compat systemd" /etc/nsswitch.conf; then
if [ $? -ne 0 ]; then
echo "/etc/nsswitch.conf is out of date, please update it from /usr/etc/nsswitch.conf to use cockpit"
failed=true
fi
fi
if $failed; then
exit 1
fi