1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00
systemd/test/units/TEST-74-AUX-UTILS.sysusers.sh
2024-10-29 11:00:13 +01:00

36 lines
963 B
Bash
Executable File

#!/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
systemd-sysusers - <<EOF
u unlockedtestuser - "An unlocked system user" / /bin/bash
u! lockedtestuser - "A locked system user" / /bin/bash
EOF
userdbctl -j user unlockedtestuser
userdbctl -j user lockedtestuser
assert_eq "$(userdbctl -j user unlockedtestuser | jq .locked)" "null"
assert_eq "$(userdbctl -j user lockedtestuser | jq .locked)" "true"
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