test/TEST-21-SYSUSERS: turn into a unit test

All this test does is manipulate text files in a subdir specified with --testroot.
It can be a normal unittest without the overhead of creating a machine image.

As a bonus, also test the .standalone version.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-10-01 17:52:51 +02:00
parent d338bfff4a
commit bd7e6aa73a
61 changed files with 148 additions and 134 deletions
+2
View File
@@ -0,0 +1,2 @@
g1:x:111:
u1:x:222:
@@ -0,0 +1 @@
u1:x:222:222::/:/bin/zsh
+2
View File
@@ -0,0 +1,2 @@
g1:x:111:
u1:x:222:
@@ -0,0 +1 @@
u1:x:222:222::/:NOLOGIN
+5
View File
@@ -0,0 +1,5 @@
# Trivial smoke test that covers the most basic functionality
#
#Type Name ID GECOS HOMEDIR
u u1 222 - -
g g1 111 - -
@@ -0,0 +1,2 @@
u1:x:300:u2
u2:x:SYSTEM_UID_MAX:
@@ -0,0 +1,2 @@
u1:x:300:300::/:NOLOGIN
u2:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX::/:NOLOGIN
+5
View File
@@ -0,0 +1,5 @@
# check that 'm' lines do not conflicts 'u' line
#
#Type Name ID GECOS HOMEDIR
u u1 300 - -
m u2 u1
@@ -0,0 +1,6 @@
o1:x:100:
g1:x:111:
u1:x:222:
+giant:::bill,tina,alan,hetty
-transport:::
+:::
@@ -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::/:NOLOGIN
+::::::
+4
View File
@@ -0,0 +1,4 @@
o1:x:100
+giant:::bill,tina,alan,hetty
-transport:::
+:::
@@ -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
+::::::
+3
View File
@@ -0,0 +1,3 @@
#Type Name ID GECOS HOMEDIR
u u1 222 - -
g g1 111 - -
@@ -0,0 +1,2 @@
root:x:0:
systemd-coredump:x:1:
@@ -0,0 +1,2 @@
root:x:0:0:root:/root:/bin/bash
systemd-coredump:x:1:1:systemd Core Dumper:/:NOLOGIN
+1
View File
@@ -0,0 +1 @@
root:x:0:
@@ -0,0 +1 @@
root:x:0:0:root:/root:/bin/bash
+1
View File
@@ -0,0 +1 @@
u systemd-coredump 1 "systemd Core Dumper"
@@ -0,0 +1,5 @@
hoge:x:300:
baz:x:302:
yyy:x:SYSTEM_GID_MAX:
foo:x:301:
ccc:x:305:
@@ -0,0 +1,5 @@
foo:x:301:301::/:NOLOGIN
aaa:x:303:302::/:NOLOGIN
bbb:x:304:302::/:NOLOGIN
ccc:x:305:305::/:NOLOGIN
zzz:x:306:SYSTEM_GID_MAX::/:NOLOGIN
+13
View File
@@ -0,0 +1,13 @@
# Ensure that the semantic for the uid:groupname syntax is correct
#
#Type Name ID GECOS HOMEDIR
g hoge 300 - -
u foo 301 - -
g baz 302 - -
u aaa 303:baz - -
u bbb 304:baz - -
u ccc 305 - -
g yyy -
u zzz 306:yyy
@@ -0,0 +1 @@
pre:x:987:
@@ -0,0 +1 @@
aaa:x:SYSTEM_UID_MAX:987::/:NOLOGIN
+1
View File
@@ -0,0 +1 @@
pre:x:987:
+4
View File
@@ -0,0 +1,4 @@
# Ensure that a preexisting system group can be used as primary
#
#Type Name ID GECOS HOMEDIR
u aaa -:pre
+4
View File
@@ -0,0 +1,4 @@
u1:x:SYSTEM_UID_MAX:
u2:x:777:
u3:x:778:
u4:x:779:
@@ -0,0 +1,4 @@
u1:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX:some gecos:/random/dir: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
+8
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
hoge:x:300:
baz:x:302:
foo:x:301:
ccc:x:305:
@@ -0,0 +1,4 @@
foo:x:301:301::/:NOLOGIN
aaa:x:303:302::/:NOLOGIN
bbb:x:304:302::/:NOLOGIN
ccc:x:305:305::/:NOLOGIN
+10
View File
@@ -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 - -
+1
View File
@@ -0,0 +1 @@
xxx:x:310:
@@ -0,0 +1,2 @@
yyy:x:311:310::/:NOLOGIN
xxx:x:312:310::/:NOLOGIN
+6
View File
@@ -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
+39
View File
@@ -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:
+18
View File
@@ -0,0 +1,18 @@
root:x:0:0::/root:/bin/sh
daemon:x:1:1::/usr/sbin:NOLOGIN
bin:x:2:2::/bin:NOLOGIN
sys:x:3:3::/dev:NOLOGIN
sync:x:4:65534::/bin:NOLOGIN
games:x:5:60::/usr/games:NOLOGIN
man:x:6:12::/var/cache/man:NOLOGIN
lp:x:7:7::/var/spool/lpd:NOLOGIN
mail:x:8:8::/var/mail:NOLOGIN
news:x:9:9::/var/spool/news:NOLOGIN
uucp:x:10:10::/var/spool/uucp:NOLOGIN
proxy:x:13:13::/bin:NOLOGIN
www-data:x:33:33::/var/www:NOLOGIN
backup:x:34:34::/var/backups:NOLOGIN
list:x:38:38::/var/list:NOLOGIN
irc:x:39:39::/var/run/ircd:NOLOGIN
gnats:x:41:41::/var/lib/gnats:NOLOGIN
nobody:x:65534:65534::/nonexistent:NOLOGIN
+47
View File
@@ -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
+2
View File
@@ -0,0 +1,2 @@
g1:x:111:
u1:x:SYSTEM_UID_MAX:
@@ -0,0 +1 @@
u1:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX::/:NOLOGIN
+7
View File
@@ -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 - -
+16
View File
@@ -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:
@@ -0,0 +1,5 @@
bin:x:1:1::/:NOLOGIN
daemon:x:2:2::/:NOLOGIN
mail:x:8:12::/var/spool/mail:NOLOGIN
ftp:x:14:11::/srv/ftp:NOLOGIN
http:x:33:33::/srv/http:NOLOGIN
+26
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
groupname:x:300:
@@ -0,0 +1 @@
username:x:SYSTEM_UID_MAX:300::/:NOLOGIN
+2
View File
@@ -0,0 +1,2 @@
g groupname 300
u username -:300
+1
View File
@@ -0,0 +1 @@
user1:x:300:
@@ -0,0 +1,2 @@
user1:x:300:300::/:NOLOGIN
user2:x:SYSTEM_UID_MAX:300::/:NOLOGIN
+2
View File
@@ -0,0 +1,2 @@
u user1 300
u user2 -:300
@@ -0,0 +1 @@
Failed to parse UID: '9999999999': Numerical result out of range
+4
View File
@@ -0,0 +1,4 @@
# Ensure invalid uids are detected
#
#Type Name ID GECOS HOMEDIR
u u1 9999999999 - -
@@ -0,0 +1 @@
Failed to create u1: please create GID 100
+4
View File
@@ -0,0 +1,4 @@
# Ensure it is not allowed to create groups implicitly in the uid:gid syntax
#
#Type Name ID GECOS HOMEDIR
u u1 100:100 -
@@ -0,0 +1 @@
Group g1 not found.
+4
View File
@@ -0,0 +1,4 @@
# Ensure it is not allowed to create groups implicitly in the uid:groupname syntax
#
#Type Name ID GECOS HOMEDIR
u u1 100:g1 -