sysusers: ensure GID in uid:gid syntax exists
Ensure that the GID already exists or is created when the new "uid:gid" syntax is used. This ensures the behaviour is always predictable.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
hoge:x:300:
|
||||
baz:x:302:
|
||||
foo:x:301:
|
||||
ccc:x:306:
|
||||
ccc:x:305:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
foo:x:301:301::/:/sbin/nologin
|
||||
aaa:x:303:302::/:/sbin/nologin
|
||||
bbb:x:304:302::/:/sbin/nologin
|
||||
ccc:x:305:306::/:/sbin/nologin
|
||||
ccc:x:305:305::/:/sbin/nologin
|
||||
|
||||
@@ -4,4 +4,4 @@ u foo 301 - -
|
||||
g baz 302 - -
|
||||
u aaa 303:302 - -
|
||||
u bbb 304:302 - -
|
||||
u ccc 305:306 - -
|
||||
u ccc 305 - -
|
||||
|
||||
@@ -11,11 +11,16 @@ test_setup() {
|
||||
}
|
||||
|
||||
test_run() {
|
||||
# ensure our build of systemd-sysusers is run
|
||||
PATH=${BUILD_DIR}:$PATH
|
||||
|
||||
# happy tests
|
||||
for f in test-*.input; do
|
||||
echo "***** Running $f"
|
||||
echo "*** Running $f"
|
||||
rm -f $TESTDIR/etc/*
|
||||
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
|
||||
${BUILD_DIR}/systemd-sysusers --root=$TESTDIR
|
||||
systemd-sysusers --root=$TESTDIR
|
||||
|
||||
if ! diff -u $TESTDIR/etc/passwd ${f%.*}.expected-passwd; then
|
||||
echo "**** Unexpected output for $f"
|
||||
exit 1
|
||||
@@ -25,6 +30,20 @@ test_run() {
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# tests for error conditions
|
||||
for f in unhappy-*.input; do
|
||||
echo "*** Running test $f"
|
||||
rm -f $TESTDIR/etc/*
|
||||
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
|
||||
systemd-sysusers --root=$TESTDIR 2> /dev/null
|
||||
journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err
|
||||
if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then
|
||||
echo "**** Unexpected error output for $f"
|
||||
cat $TESTDIR/tmp/err
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Failed to parse UID: '9999999999': Numerical result out of range
|
||||
@@ -0,0 +1 @@
|
||||
u u1 9999999999 - -
|
||||
@@ -0,0 +1 @@
|
||||
Failed to create u1: please create GID 100
|
||||
@@ -0,0 +1,2 @@
|
||||
# it is not allowed to create groups implicitely in the uid:gid syntax
|
||||
u u1 100:100 -
|
||||
Reference in New Issue
Block a user