-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sysusers: handle NSS errors gracefully
If the io.systemd.DynamicUser or io.systemd.Machine files exist, but nothing is listening on them, the nss-systemd module returns ECONNREFUSED and systemd-sysusers fails to creat the user/group. This is problematic when ran by packaging scripts, as the package assumes that after this has run, the user/group exist and can be used. adduser does not fail in the same situation. Change sysusers to print a loud warning but otherwise continue when NSS returns an error. (cherry picked from commit fc9938d6f8e7081df5420bf88bf98f683b1391c0) (cherry picked from commit abba1e6bc29b7e07354ca23906c6f485ba245a1a) (cherry picked from commit 0f51875) (cherry picked from commit dffa62c) (cherry picked from commit af2eb43)
- Loading branch information
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
set -eux | ||
set -o pipefail | ||
|
||
# shellcheck source=test/units/util.sh | ||
. "$(dirname "$0")"/util.sh | ||
|
||
at_exit() { | ||
set +e | ||
userdel -r foobarbaz | ||
umount /run/systemd/userdb/ | ||
} | ||
|
||
# Check that we indeed run under root to make the rest of the test work | ||
[[ "$(id -u)" -eq 0 ]] | ||
|
||
trap at_exit EXIT | ||
|
||
# Ensure that a non-responsive NSS socket doesn't make sysusers fail | ||
mount -t tmpfs tmpfs /run/systemd/userdb/ | ||
touch /run/systemd/userdb/io.systemd.DynamicUser | ||
echo 'u foobarbaz' | SYSTEMD_LOG_LEVEL=debug systemd-sysusers - | ||
grep -q foobarbaz /etc/passwd |