summaryrefslogtreecommitdiffstats
path: root/test/TEST-21-SYSUSERS
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:25:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:25:50 +0000
commit19f4f86bfed21c5326ed2acebe1163f3a83e832b (patch)
treed59b9989ce55ed23693e80974d94c856f1c2c8b1 /test/TEST-21-SYSUSERS
parentInitial commit. (diff)
downloadsystemd-19f4f86bfed21c5326ed2acebe1163f3a83e832b.tar.xz
systemd-19f4f86bfed21c5326ed2acebe1163f3a83e832b.zip
Adding upstream version 241.upstream/241upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
l---------test/TEST-21-SYSUSERS/Makefile1
-rw-r--r--test/TEST-21-SYSUSERS/inline.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/inline.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-1.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/test-1.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-1.input5
-rw-r--r--test/TEST-21-SYSUSERS/test-10.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/test-10.expected-passwd2
-rw-r--r--test/TEST-21-SYSUSERS/test-10.input5
-rw-r--r--test/TEST-21-SYSUSERS/test-11.expected-group6
-rw-r--r--test/TEST-21-SYSUSERS/test-11.expected-passwd6
-rw-r--r--test/TEST-21-SYSUSERS/test-11.initial-group4
-rw-r--r--test/TEST-21-SYSUSERS/test-11.initial-passwd5
-rw-r--r--test/TEST-21-SYSUSERS/test-11.input3
-rw-r--r--test/TEST-21-SYSUSERS/test-12.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/test-12.expected-passwd2
-rw-r--r--test/TEST-21-SYSUSERS/test-12.initial-group1
-rw-r--r--test/TEST-21-SYSUSERS/test-12.initial-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-12.input1
-rw-r--r--test/TEST-21-SYSUSERS/test-2.expected-group4
-rw-r--r--test/TEST-21-SYSUSERS/test-2.expected-passwd4
-rw-r--r--test/TEST-21-SYSUSERS/test-2.input8
-rw-r--r--test/TEST-21-SYSUSERS/test-3.expected-group4
-rw-r--r--test/TEST-21-SYSUSERS/test-3.expected-passwd4
-rw-r--r--test/TEST-21-SYSUSERS/test-3.input10
-rw-r--r--test/TEST-21-SYSUSERS/test-4.expected-group1
-rw-r--r--test/TEST-21-SYSUSERS/test-4.expected-passwd2
-rw-r--r--test/TEST-21-SYSUSERS/test-4.input6
-rw-r--r--test/TEST-21-SYSUSERS/test-5.expected-group39
-rw-r--r--test/TEST-21-SYSUSERS/test-5.expected-passwd18
-rw-r--r--test/TEST-21-SYSUSERS/test-5.input47
-rw-r--r--test/TEST-21-SYSUSERS/test-6.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/test-6.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-6.input7
-rw-r--r--test/TEST-21-SYSUSERS/test-7.expected-group16
-rw-r--r--test/TEST-21-SYSUSERS/test-7.expected-passwd5
-rw-r--r--test/TEST-21-SYSUSERS/test-7.input26
-rw-r--r--test/TEST-21-SYSUSERS/test-8.expected-group1
-rw-r--r--test/TEST-21-SYSUSERS/test-8.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-8.input2
-rw-r--r--test/TEST-21-SYSUSERS/test-9.expected-group1
-rw-r--r--test/TEST-21-SYSUSERS/test-9.expected-passwd2
-rw-r--r--test/TEST-21-SYSUSERS/test-9.input2
-rwxr-xr-xtest/TEST-21-SYSUSERS/test.sh121
-rw-r--r--test/TEST-21-SYSUSERS/unhappy-1.expected-err1
-rw-r--r--test/TEST-21-SYSUSERS/unhappy-1.input4
-rw-r--r--test/TEST-21-SYSUSERS/unhappy-2.expected-err1
-rw-r--r--test/TEST-21-SYSUSERS/unhappy-2.input4
48 files changed, 396 insertions, 0 deletions
diff --git a/test/TEST-21-SYSUSERS/Makefile b/test/TEST-21-SYSUSERS/Makefile
new file mode 120000
index 0000000..e9f93b1
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/Makefile
@@ -0,0 +1 @@
+../TEST-01-BASIC/Makefile \ No newline at end of file
diff --git a/test/TEST-21-SYSUSERS/inline.expected-group b/test/TEST-21-SYSUSERS/inline.expected-group
new file mode 100644
index 0000000..cc9093f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/inline.expected-group
@@ -0,0 +1,2 @@
+g1:x:111:
+u1:x:222:
diff --git a/test/TEST-21-SYSUSERS/inline.expected-passwd b/test/TEST-21-SYSUSERS/inline.expected-passwd
new file mode 100644
index 0000000..f50f25c
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/inline.expected-passwd
@@ -0,0 +1 @@
+u1:x:222:222::/:/bin/zsh
diff --git a/test/TEST-21-SYSUSERS/test-1.expected-group b/test/TEST-21-SYSUSERS/test-1.expected-group
new file mode 100644
index 0000000..cc9093f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.expected-group
@@ -0,0 +1,2 @@
+g1:x:111:
+u1:x:222:
diff --git a/test/TEST-21-SYSUSERS/test-1.expected-passwd b/test/TEST-21-SYSUSERS/test-1.expected-passwd
new file mode 100644
index 0000000..8d0bfff
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.expected-passwd
@@ -0,0 +1 @@
+u1:x:222:222::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-1.input b/test/TEST-21-SYSUSERS/test-1.input
new file mode 100644
index 0000000..297bbe3
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.input
@@ -0,0 +1,5 @@
+# Trivial smoke test that covers the most basic functionality
+#
+#Type Name ID GECOS HOMEDIR
+u u1 222 - -
+g g1 111 - -
diff --git a/test/TEST-21-SYSUSERS/test-10.expected-group b/test/TEST-21-SYSUSERS/test-10.expected-group
new file mode 100644
index 0000000..1c92158
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-10.expected-group
@@ -0,0 +1,2 @@
+u1:x:300:u2
+u2:x:SYSTEM_UID_MAX:
diff --git a/test/TEST-21-SYSUSERS/test-10.expected-passwd b/test/TEST-21-SYSUSERS/test-10.expected-passwd
new file mode 100644
index 0000000..222334b
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-10.expected-passwd
@@ -0,0 +1,2 @@
+u1:x:300:300::/:/sbin/nologin
+u2:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-10.input b/test/TEST-21-SYSUSERS/test-10.input
new file mode 100644
index 0000000..8e18a00
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-10.input
@@ -0,0 +1,5 @@
+# check that 'm' lines do not conflicts 'u' line
+#
+#Type Name ID GECOS HOMEDIR
+u u1 300 - -
+m u2 u1
diff --git a/test/TEST-21-SYSUSERS/test-11.expected-group b/test/TEST-21-SYSUSERS/test-11.expected-group
new file mode 100644
index 0000000..815a6c5
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-11.expected-group
@@ -0,0 +1,6 @@
+o1:x:100:
+g1:x:111:
+u1:x:222:
++giant:::bill,tina,alan,hetty
+-transport:::
++:::
diff --git a/test/TEST-21-SYSUSERS/test-11.expected-passwd b/test/TEST-21-SYSUSERS/test-11.expected-passwd
new file mode 100644
index 0000000..3f9ab39
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-11.expected-passwd
@@ -0,0 +1,6 @@
+root:x:0:0:root:/root:/bin/bash
+systemd-network:x:492:492:Systemd Network Management:/:/usr/sbin/nologin
+systemd-resolve:x:491:491:Systemd Resolver:/:/usr/sbin/nologin
+systemd-timesync:x:493:493:Systemd Time Synchronization:/:/usr/sbin/nologin
+u1:x:222:222::/:/sbin/nologin
++::::::
diff --git a/test/TEST-21-SYSUSERS/test-11.initial-group b/test/TEST-21-SYSUSERS/test-11.initial-group
new file mode 100644
index 0000000..88d31f2
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-11.initial-group
@@ -0,0 +1,4 @@
+o1:x:100
++giant:::bill,tina,alan,hetty
+-transport:::
++:::
diff --git a/test/TEST-21-SYSUSERS/test-11.initial-passwd b/test/TEST-21-SYSUSERS/test-11.initial-passwd
new file mode 100644
index 0000000..45d3ffd
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-11.initial-passwd
@@ -0,0 +1,5 @@
+root:x:0:0:root:/root:/bin/bash
+systemd-network:x:492:492:Systemd Network Management:/:/usr/sbin/nologin
+systemd-resolve:x:491:491:Systemd Resolver:/:/usr/sbin/nologin
+systemd-timesync:x:493:493:Systemd Time Synchronization:/:/usr/sbin/nologin
++::::::
diff --git a/test/TEST-21-SYSUSERS/test-11.input b/test/TEST-21-SYSUSERS/test-11.input
new file mode 100644
index 0000000..bffc2cd
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-11.input
@@ -0,0 +1,3 @@
+#Type Name ID GECOS HOMEDIR
+u u1 222 - -
+g g1 111 - -
diff --git a/test/TEST-21-SYSUSERS/test-12.expected-group b/test/TEST-21-SYSUSERS/test-12.expected-group
new file mode 100644
index 0000000..5d94846
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-12.expected-group
@@ -0,0 +1,2 @@
+root:x:0:
+systemd-coredump:x:1:
diff --git a/test/TEST-21-SYSUSERS/test-12.expected-passwd b/test/TEST-21-SYSUSERS/test-12.expected-passwd
new file mode 100644
index 0000000..75fe9b4
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-12.expected-passwd
@@ -0,0 +1,2 @@
+root:x:0:0:root:/root:/bin/bash
+systemd-coredump:x:1:1:systemd Core Dumper:/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-12.initial-group b/test/TEST-21-SYSUSERS/test-12.initial-group
new file mode 100644
index 0000000..1dbf901
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-12.initial-group
@@ -0,0 +1 @@
+root:x:0:
diff --git a/test/TEST-21-SYSUSERS/test-12.initial-passwd b/test/TEST-21-SYSUSERS/test-12.initial-passwd
new file mode 100644
index 0000000..aebc492
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-12.initial-passwd
@@ -0,0 +1 @@
+root:x:0:0:root:/root:/bin/bash
diff --git a/test/TEST-21-SYSUSERS/test-12.input b/test/TEST-21-SYSUSERS/test-12.input
new file mode 100644
index 0000000..2913120
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-12.input
@@ -0,0 +1 @@
+u systemd-coredump 1 "systemd Core Dumper"
diff --git a/test/TEST-21-SYSUSERS/test-2.expected-group b/test/TEST-21-SYSUSERS/test-2.expected-group
new file mode 100644
index 0000000..8fcc03f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.expected-group
@@ -0,0 +1,4 @@
+u1:x:SYSTEM_UID_MAX:
+u2:x:777:
+u3:x:778:
+u4:x:779:
diff --git a/test/TEST-21-SYSUSERS/test-2.expected-passwd b/test/TEST-21-SYSUSERS/test-2.expected-passwd
new file mode 100644
index 0000000..9eeee5d
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.expected-passwd
@@ -0,0 +1,4 @@
+u1:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX:some gecos:/random/dir:/sbin/nologin
+u2:x:777:777:some gecos:/random/dir:/bin/zsh
+u3:x:778:778::/random/dir2:/bin/bash
+u4:x:779:779::/:/bin/csh
diff --git a/test/TEST-21-SYSUSERS/test-2.input b/test/TEST-21-SYSUSERS/test-2.input
new file mode 100644
index 0000000..cedea9e
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.input
@@ -0,0 +1,8 @@
+# Test generation of ID dynamically based on SYSTEM_UID_MAX and
+# replacement of all fields up to the login shell.
+#
+#Type Name ID GECOS homedir shell
+u u1 - "some gecos" /random/dir -
+u u2 777 "some gecos" /random/dir /bin/zsh
+u u3 778 - /random/dir2 /bin/bash
+u u4 779 - - /bin/csh
diff --git a/test/TEST-21-SYSUSERS/test-3.expected-group b/test/TEST-21-SYSUSERS/test-3.expected-group
new file mode 100644
index 0000000..c3a6328
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.expected-group
@@ -0,0 +1,4 @@
+hoge:x:300:
+baz:x:302:
+foo:x:301:
+ccc:x:305:
diff --git a/test/TEST-21-SYSUSERS/test-3.expected-passwd b/test/TEST-21-SYSUSERS/test-3.expected-passwd
new file mode 100644
index 0000000..a86954f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.expected-passwd
@@ -0,0 +1,4 @@
+foo:x:301:301::/:/sbin/nologin
+aaa:x:303:302::/:/sbin/nologin
+bbb:x:304:302::/:/sbin/nologin
+ccc:x:305:305::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-3.input b/test/TEST-21-SYSUSERS/test-3.input
new file mode 100644
index 0000000..3257082
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.input
@@ -0,0 +1,10 @@
+# Ensure that the semantic for the uid:gid syntax is correct
+#
+#Type Name ID GECOS HOMEDIR
+g hoge 300 - -
+u foo 301 - -
+
+g baz 302 - -
+u aaa 303:302 - -
+u bbb 304:302 - -
+u ccc 305 - -
diff --git a/test/TEST-21-SYSUSERS/test-4.expected-group b/test/TEST-21-SYSUSERS/test-4.expected-group
new file mode 100644
index 0000000..64913a5
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-4.expected-group
@@ -0,0 +1 @@
+xxx:x:310:
diff --git a/test/TEST-21-SYSUSERS/test-4.expected-passwd b/test/TEST-21-SYSUSERS/test-4.expected-passwd
new file mode 100644
index 0000000..e0370a4
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-4.expected-passwd
@@ -0,0 +1,2 @@
+yyy:x:311:310::/:/sbin/nologin
+xxx:x:312:310::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-4.input b/test/TEST-21-SYSUSERS/test-4.input
new file mode 100644
index 0000000..557f61c
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-4.input
@@ -0,0 +1,6 @@
+# Ensure that already created groups are used when using the uid:gid syntax
+#
+#Type Name ID GECOS HOMEDIR
+g xxx 310
+u yyy 311:310
+u xxx 312:310
diff --git a/test/TEST-21-SYSUSERS/test-5.expected-group b/test/TEST-21-SYSUSERS/test-5.expected-group
new file mode 100644
index 0000000..e9ef0a7
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-5.expected-group
@@ -0,0 +1,39 @@
+adm:x:4:
+tty:x:5:
+disk:x:6:
+man:x:12:
+kmem:x:15:
+dialout:x:20:
+fax:x:21:
+voice:x:22:
+cdrom:x:24:
+floppy:x:25:
+tape:x:26:
+sudo:x:27:
+audio:x:29:
+dip:x:30:
+operator:x:37:
+src:x:40:
+shadow:x:42:
+utmp:x:43:
+video:x:44:
+sasl:x:45:
+plugdev:x:46:
+staff:x:50:
+games:x:60:
+users:x:100:
+nogroup:x:65534:
+root:x:0:
+daemon:x:1:
+bin:x:2:
+sys:x:3:
+lp:x:7:
+mail:x:8:
+news:x:9:
+uucp:x:10:
+proxy:x:13:
+www-data:x:33:
+backup:x:34:
+list:x:38:
+irc:x:39:
+gnats:x:41:
diff --git a/test/TEST-21-SYSUSERS/test-5.expected-passwd b/test/TEST-21-SYSUSERS/test-5.expected-passwd
new file mode 100644
index 0000000..116b126
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-5.expected-passwd
@@ -0,0 +1,18 @@
+root:x:0:0::/root:/bin/sh
+daemon:x:1:1::/usr/sbin:/sbin/nologin
+bin:x:2:2::/bin:/sbin/nologin
+sys:x:3:3::/dev:/sbin/nologin
+sync:x:4:65534::/bin:/sbin/nologin
+games:x:5:60::/usr/games:/sbin/nologin
+man:x:6:12::/var/cache/man:/sbin/nologin
+lp:x:7:7::/var/spool/lpd:/sbin/nologin
+mail:x:8:8::/var/mail:/sbin/nologin
+news:x:9:9::/var/spool/news:/sbin/nologin
+uucp:x:10:10::/var/spool/uucp:/sbin/nologin
+proxy:x:13:13::/bin:/sbin/nologin
+www-data:x:33:33::/var/www:/sbin/nologin
+backup:x:34:34::/var/backups:/sbin/nologin
+list:x:38:38::/var/list:/sbin/nologin
+irc:x:39:39::/var/run/ircd:/sbin/nologin
+gnats:x:41:41::/var/lib/gnats:/sbin/nologin
+nobody:x:65534:65534::/nonexistent:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-5.input b/test/TEST-21-SYSUSERS/test-5.input
new file mode 100644
index 0000000..57519d7
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-5.input
@@ -0,0 +1,47 @@
+# Reproduce the base-passwd master.{passwd,group} from Debian
+#
+#Type Name ID GECOS Home directory
+g adm 4 -
+g tty 5 -
+g disk 6 -
+g man 12 -
+g kmem 15 -
+g dialout 20 -
+g fax 21 -
+g voice 22 -
+g cdrom 24 -
+g floppy 25 -
+g tape 26 -
+g sudo 27 -
+g audio 29 -
+g dip 30 -
+g operator 37 -
+g src 40 -
+g shadow 42 -
+g utmp 43 -
+g video 44 -
+g sasl 45 -
+g plugdev 46 -
+g staff 50 -
+g games 60 -
+g users 100 -
+g nogroup 65534 -
+
+u root 0 - /root
+u daemon 1 - /usr/sbin
+u bin 2 - /bin
+u sys 3 - /dev
+u sync 4:65534 - /bin
+u games 5:60 - /usr/games
+u man 6:12 - /var/cache/man
+u lp 7 - /var/spool/lpd
+u mail 8 - /var/mail
+u news 9 - /var/spool/news
+u uucp 10 - /var/spool/uucp
+u proxy 13 - /bin
+u www-data 33 - /var/www
+u backup 34 - /var/backups
+u list 38 - /var/list
+u irc 39 - /var/run/ircd
+u gnats 41 - /var/lib/gnats
+u nobody 65534:65534 - /nonexistent
diff --git a/test/TEST-21-SYSUSERS/test-6.expected-group b/test/TEST-21-SYSUSERS/test-6.expected-group
new file mode 100644
index 0000000..499c900
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-6.expected-group
@@ -0,0 +1,2 @@
+g1:x:111:
+u1:x:SYSTEM_UID_MAX:
diff --git a/test/TEST-21-SYSUSERS/test-6.expected-passwd b/test/TEST-21-SYSUSERS/test-6.expected-passwd
new file mode 100644
index 0000000..5af9d11
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-6.expected-passwd
@@ -0,0 +1 @@
+u1:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-6.input b/test/TEST-21-SYSUSERS/test-6.input
new file mode 100644
index 0000000..764f57e
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-6.input
@@ -0,0 +1,7 @@
+# Ensure that existing IDs are not reused by default. I.e. the existing
+# ID 111 from g1 will cause u1 to get a new and different ID (999 on most
+# systems).
+#
+#Type Name ID GECOS HOMEDIR
+g g1 111 - -
+u u1 111 - -
diff --git a/test/TEST-21-SYSUSERS/test-7.expected-group b/test/TEST-21-SYSUSERS/test-7.expected-group
new file mode 100644
index 0000000..ae9539c
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-7.expected-group
@@ -0,0 +1,16 @@
+sys:x:3:
+mem:x:8:
+ftp:x:11:
+mail:x:12:
+log:x:19:
+smmsp:x:25:
+proc:x:26:
+games:x:50:
+lock:x:54:
+network:x:90:
+floppy:x:94:
+scanner:x:96:
+power:x:98:
+bin:x:1:
+daemon:x:2:
+http:x:33:
diff --git a/test/TEST-21-SYSUSERS/test-7.expected-passwd b/test/TEST-21-SYSUSERS/test-7.expected-passwd
new file mode 100644
index 0000000..79668c0
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-7.expected-passwd
@@ -0,0 +1,5 @@
+bin:x:1:1::/:/sbin/nologin
+daemon:x:2:2::/:/sbin/nologin
+mail:x:8:12::/var/spool/mail:/sbin/nologin
+ftp:x:14:11::/srv/ftp:/sbin/nologin
+http:x:33:33::/srv/http:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-7.input b/test/TEST-21-SYSUSERS/test-7.input
new file mode 100644
index 0000000..4e10b74
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-7.input
@@ -0,0 +1,26 @@
+# Issue #8315
+#
+#Type Name ID GECOS HOMEDIR
+
+# default arch groups
+# groups first, because we have user/group id mismatch on ftp and mail
+g sys 3 - -
+g mem 8 - -
+g ftp 11 - -
+g mail 12 - -
+g log 19 - -
+g smmsp 25 - -
+g proc 26 - -
+g games 50 - -
+g lock 54 - -
+g network 90 - -
+g floppy 94 - -
+g scanner 96 - -
+g power 98 - -
+
+# default arch users
+u bin 1 - -
+u daemon 2 - -
+u mail 8 - /var/spool/mail
+u ftp 14 - /srv/ftp
+u http 33 - /srv/http
diff --git a/test/TEST-21-SYSUSERS/test-8.expected-group b/test/TEST-21-SYSUSERS/test-8.expected-group
new file mode 100644
index 0000000..f09b2b6
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-8.expected-group
@@ -0,0 +1 @@
+groupname:x:300:
diff --git a/test/TEST-21-SYSUSERS/test-8.expected-passwd b/test/TEST-21-SYSUSERS/test-8.expected-passwd
new file mode 100644
index 0000000..727b819
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-8.expected-passwd
@@ -0,0 +1 @@
+username:x:SYSTEM_UID_MAX:300::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-8.input b/test/TEST-21-SYSUSERS/test-8.input
new file mode 100644
index 0000000..b76dd3e
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-8.input
@@ -0,0 +1,2 @@
+g groupname 300
+u username -:300
diff --git a/test/TEST-21-SYSUSERS/test-9.expected-group b/test/TEST-21-SYSUSERS/test-9.expected-group
new file mode 100644
index 0000000..33335d4
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-9.expected-group
@@ -0,0 +1 @@
+user1:x:300:
diff --git a/test/TEST-21-SYSUSERS/test-9.expected-passwd b/test/TEST-21-SYSUSERS/test-9.expected-passwd
new file mode 100644
index 0000000..a23260f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-9.expected-passwd
@@ -0,0 +1,2 @@
+user1:x:300:300::/:/sbin/nologin
+user2:x:SYSTEM_UID_MAX:300::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-9.input b/test/TEST-21-SYSUSERS/test-9.input
new file mode 100644
index 0000000..4d53647
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-9.input
@@ -0,0 +1,2 @@
+u user1 300
+u user2 -:300
diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh
new file mode 100755
index 0000000..b1049e7
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+set -e
+TEST_DESCRIPTION="Sysuser-related tests"
+
+. $TEST_BASE_DIR/test-functions
+
+test_setup() {
+ mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp
+}
+
+prepare_testdir() {
+ rm -f $TESTDIR/etc/*{passwd,group,shadow}
+ for i in $1.initial-{passwd,group,shadow}; do
+ test -f $i && cp $i $TESTDIR/etc/${i#*.initial-}
+ done
+ return 0
+}
+
+preprocess() {
+ in="$1"
+
+ # see meson.build how to extract this. gcc -E was used before to
+ # get this value from config.h, however the autopkgtest fails with
+ # it
+ SYSTEM_UID_MAX=$(awk 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }' /etc/login.defs)
+ sed "s/SYSTEM_UID_MAX/${SYSTEM_UID_MAX}/g" "$in"
+}
+
+compare() {
+ if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then
+ echo "**** Unexpected output for $f"
+ exit 1
+ fi
+
+ if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then
+ echo "**** Unexpected output for $f $2"
+ exit 1
+ fi
+}
+
+test_run() {
+ # ensure our build of systemd-sysusers is run
+ PATH=${BUILD_DIR}:$PATH
+
+ rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/*
+
+ # happy tests
+ for f in test-*.input; do
+ echo "*** Running $f"
+ prepare_testdir ${f%.input}
+ cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
+ systemd-sysusers --root=$TESTDIR
+
+ compare $f ""
+ done
+
+ for f in test-*.input; do
+ echo "*** Running $f on stdin"
+ prepare_testdir ${f%.input}
+ touch $TESTDIR/etc/sysusers.d/test.conf
+ cat $f | systemd-sysusers --root=$TESTDIR -
+
+ compare $f "on stdin"
+ done
+
+ for f in test-*.input; do
+ echo "*** Running $f on stdin with --replace"
+ prepare_testdir ${f%.input}
+ touch $TESTDIR/etc/sysusers.d/test.conf
+ # this overrides test.conf which is masked on disk
+ cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf -
+ # this should be ignored
+ cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf -
+
+ compare $f "on stdin with --replace"
+ done
+
+ # test --inline
+ echo "*** Testing --inline"
+ prepare_testdir
+ # copy a random file to make sure it is ignored
+ cp $f $TESTDIR/etc/sysusers.d/confuse.conf
+ systemd-sysusers --root=$TESTDIR --inline \
+ "u u1 222 - - /bin/zsh" \
+ "g g1 111"
+
+ compare inline "(--inline)"
+
+ # test --replace
+ echo "*** Testing --inline with --replace"
+ prepare_testdir
+ # copy a random file to make sure it is ignored
+ cp $f $TESTDIR/etc/sysusers.d/confuse.conf
+ systemd-sysusers --root=$TESTDIR \
+ --inline \
+ --replace=/etc/sysusers.d/confuse.conf \
+ "u u1 222 - - /bin/zsh" \
+ "g g1 111"
+
+ compare inline "(--inline --replace=…)"
+
+ rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/*
+
+ # tests for error conditions
+ for f in unhappy-*.input; do
+ echo "*** Running test $f"
+ prepare_testdir ${f%.input}
+ 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 "$@"
diff --git a/test/TEST-21-SYSUSERS/unhappy-1.expected-err b/test/TEST-21-SYSUSERS/unhappy-1.expected-err
new file mode 100644
index 0000000..d334240
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/unhappy-1.expected-err
@@ -0,0 +1 @@
+Failed to parse UID: '9999999999': Numerical result out of range
diff --git a/test/TEST-21-SYSUSERS/unhappy-1.input b/test/TEST-21-SYSUSERS/unhappy-1.input
new file mode 100644
index 0000000..b8ed855
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/unhappy-1.input
@@ -0,0 +1,4 @@
+# Ensure invalid uids are detected
+#
+#Type Name ID GECOS HOMEDIR
+u u1 9999999999 - -
diff --git a/test/TEST-21-SYSUSERS/unhappy-2.expected-err b/test/TEST-21-SYSUSERS/unhappy-2.expected-err
new file mode 100644
index 0000000..5db5c20
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/unhappy-2.expected-err
@@ -0,0 +1 @@
+Failed to create u1: please create GID 100
diff --git a/test/TEST-21-SYSUSERS/unhappy-2.input b/test/TEST-21-SYSUSERS/unhappy-2.input
new file mode 100644
index 0000000..5be0e6d
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/unhappy-2.input
@@ -0,0 +1,4 @@
+# Ensure it is not allowed to create groups implicitely in the uid:gid syntax
+#
+#Type Name ID GECOS HOMEDIR
+u u1 100:100 -