PASSWORD=xEhErW0ndafV4s homectl with test-user -- rm /home/test-user/xyz
PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz
(! PASSWORD=xEhErW0ndafV4s homectl with test-user -- test -f /home/test-user/xyz)
- [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %U /home/test-user/hoge)" == "test-user" ]]
+ if check_nss_module systemd; then
+ [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %U /home/test-user/hoge)" == "test-user" ]]
+ [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %u /home/test-user/hoge)" == "$(id -u test-user)" ]]
+ fi
+ # The machine ID may start with a numeric, and in that case the field name must be quoted.
+ [[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- stat -c %u /home/test-user/hoge)" == \
+ "$(homectl inspect --json=short test-user | jq .binding.\""$(cat /etc/machine-id)"\".uid)" ]]
[[ "$(PASSWORD=xEhErW0ndafV4s homectl with test-user -- cat /home/test-user/hoge)" == "$(cat "$TMP_SKEL"/hoge)" ]]
# Regression tests
return 0
fi
+ # 'ssh homedsshtest@localhost' requires systemd NSS module.
+ if ! check_nss_module systemd; then
+ return 0
+ fi
+
if ! command -v ssh >/dev/null || ! command -v sshd >/dev/null; then
echo "ssh/sshd is not installed, skipping the ssh test."
return 0
userdbctl user aliastest2@myrealm
userdbctl user aliastest3@myrealm
- getent passwd aliastest
- getent passwd aliastest2
- getent passwd aliastest3
- getent passwd aliastest@myrealm
- getent passwd aliastest2@myrealm
- getent passwd aliastest3@myrealm
+ if check_nss_module systemd; then
+ getent passwd aliastest
+ getent passwd aliastest2
+ getent passwd aliastest3
+ getent passwd aliastest@myrealm
+ getent passwd aliastest2@myrealm
+ getent passwd aliastest3@myrealm
+ fi
homectl remove aliastest
}
testcase_quota() {
+ # 'run0 -u' requires systemd NSS module.
+ if ! check_nss_module systemd; then
+ return 0
+ fi
+
NEWPASSWORD=quux homectl create tmpfsquota --storage=subvolume --dev-shm-limit=50K --tmp-limit=50K -P
for p in /dev/shm /tmp; do
if findmnt -n -o options "$p" | grep -q usrquota; then
}
testcase_subarea() {
+ # 'run0 -u' requires systemd NSS module.
+ if ! check_nss_module systemd; then
+ return 0
+ fi
+
NEWPASSWORD=quux homectl create subareatest --storage=subvolume -P
run0 --property=SetCredential=pam.authtok.systemd-run0:quux -u subareatest mkdir Areas
run0 --property=SetCredential=pam.authtok.systemd-run0:quux -u subareatest cp -av /etc/skel Areas/furb
testcase_03_23951() {
: "--- nss-resolve/nss-myhostname tests"
+
+ if ! check_nss_module resolve; then
+ return 0
+ fi
+
# Sanity check
TIMESTAMP=$(date '+%F %T')
# Issue: https://github.com/systemd/systemd/issues/23951
}
testcase_04_18812() {
+ if ! check_nss_module resolve; then
+ return 0
+ fi
+
# Issue: https://github.com/systemd/systemd/issues/18812
# PR: https://github.com/systemd/systemd/pull/18896
# Follow-up issue: https://github.com/systemd/systemd/issues/23152
}
testcase_05_25088() {
+ if ! check_nss_module resolve; then
+ return 0
+ fi
+
# Issue: https://github.com/systemd/systemd/issues/25088
run getent -s resolve hosts 127.128.0.5
grep -qEx '127\.128\.0\.5\s+localhost5(\s+localhost5?\.localdomain[45]?){4}' "$RUN_OUT"
set +ex
! systemd-analyze --quiet condition 'ConditionVersion=glibc $= ?*'
)
+
+check_nss_module() (
+ set +e
+
+ local name="${1:?}"
+ local have=
+ local i
+
+ if [[ ! -e /etc/nsswitch.conf ]]; then
+ : "/etc/nsswitch.conf not found."
+ return 1
+ fi
+
+ if ! find /usr/lib* -name "libnss_${name}.so.*" 2>/dev/null | grep . >/dev/null; then
+ : "NSS module $name not found."
+ return 1
+ fi
+
+ if [[ "$name" == systemd ]]; then
+ for i in passwd group shadow; do
+ if ! grep -qE "^$i:.*[[:space:]]*systemd" /etc/nsswitch.conf; then
+ : "systemd NSS module is not enabled for $i database."
+ return 1
+ fi
+ done
+ else
+ if ! grep -qE "^hosts:.*[[:space:]]*$name" /etc/nsswitch.conf; then
+ : "$name NSS module is not enabled for hosts database."
+ return 1
+ fi
+ fi
+
+ return 0
+)