mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 17:03:01 +00:00
nixos/users-groups: Fix the update-lingering activation script failing
The update-lingering activation script currently fails during rebuilds. This happens when removing a user with linger enabled. The call to loginctl disable-linger runs for the non-existent user. This returns an error code which causes the failure. To mitigate this, this PR removes any residual linger files. These are files named for the user in /var/lib/systemd/linger. A simple check for user existence determines whether to delete the file. This happens before the call to disable-linger to avoid any errors. Fixes #283769.
This commit is contained in:
parent
9c8cdfde17
commit
8558d7b1ce
@ -704,6 +704,11 @@ in {
|
||||
in stringAfter [ "users" ] ''
|
||||
if [ -e ${lingerDir} ] ; then
|
||||
cd ${lingerDir}
|
||||
for user in ${lingerDir}/*; do
|
||||
if ! id "$user" >/dev/null 2>&1; then
|
||||
rm --force -- "$user"
|
||||
fi
|
||||
done
|
||||
ls ${lingerDir} | sort | comm -3 -1 ${lingeringUsersFile} - | xargs -r ${pkgs.systemd}/bin/loginctl disable-linger
|
||||
ls ${lingerDir} | sort | comm -3 -2 ${lingeringUsersFile} - | xargs -r ${pkgs.systemd}/bin/loginctl enable-linger
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user