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
1 changed files with 5 additions and 0 deletions
|
@ -704,6 +704,11 @@ in {
|
||||||
in stringAfter [ "users" ] ''
|
in stringAfter [ "users" ] ''
|
||||||
if [ -e ${lingerDir} ] ; then
|
if [ -e ${lingerDir} ] ; then
|
||||||
cd ${lingerDir}
|
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 -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
|
ls ${lingerDir} | sort | comm -3 -2 ${lingeringUsersFile} - | xargs -r ${pkgs.systemd}/bin/loginctl enable-linger
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue