mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
test: drop the use of /bin/sh in various test services
This is not meant to be comprehensive, just the few cases where the /bin/sh -c wrapper is obviously superfluous.
This commit is contained in:
parent
5008da1ec1
commit
42345b178d
@ -4,14 +4,14 @@ Description=Test for BindPaths= and BindReadOnlyPaths=
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# Create a file in /tmp/test-exec-bindpaths
|
||||
ExecStart=/bin/sh -c 'touch /tmp/test-exec-bindpaths/thisisasimpletest'
|
||||
ExecStart=touch /tmp/test-exec-bindpaths/thisisasimpletest
|
||||
# Then, the file can be access through /tmp
|
||||
ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest'
|
||||
ExecStart=test -f /tmp/thisisasimpletest
|
||||
# Also, through /tmp/test-exec-bindreadonlypaths
|
||||
ExecStart=/bin/sh -c 'test -f /tmp/test-exec-bindreadonlypaths/thisisasimpletest'
|
||||
ExecStart=test -f /tmp/test-exec-bindreadonlypaths/thisisasimpletest
|
||||
# The file cannot modify through /tmp/test-exec-bindreadonlypaths
|
||||
ExecStart=/bin/sh -x -c '! touch /tmp/test-exec-bindreadonlypaths/thisisasimpletest'
|
||||
# Cleanup
|
||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest'
|
||||
ExecStart=rm /tmp/thisisasimpletest
|
||||
BindPaths=/tmp:/tmp/test-exec-bindpaths
|
||||
BindReadOnlyPaths=/tmp:/tmp/test-exec-bindreadonlypaths
|
||||
|
@ -2,14 +2,14 @@
|
||||
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test ! -L /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test ! -L /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate/yay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
||||
ExecStart=test -w /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test -w /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test ! -L /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test ! -L /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test -d /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test -d /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
|
||||
ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||
|
||||
Type=oneshot
|
||||
DynamicUser=no
|
||||
|
@ -2,22 +2,22 @@
|
||||
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test -L /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -L /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/test-dynamicuser-migrate/yay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/private/test-dynamicuser-migrate'
|
||||
ExecStart=/bin/sh -c 'test -d /var/lib/private/test-dynamicuser-migrate2/hoge'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/test-dynamicuser-migrate/yay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate/yay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/private/test-dynamicuser-migrate/yay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay'
|
||||
ExecStart=test -w /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test -w /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test -L /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test -L /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test -d /var/lib/test-dynamicuser-migrate
|
||||
ExecStart=test -d /var/lib/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test -f /var/lib/test-dynamicuser-migrate/yay
|
||||
ExecStart=test -f /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||
ExecStart=test -d /var/lib/private/test-dynamicuser-migrate
|
||||
ExecStart=test -d /var/lib/private/test-dynamicuser-migrate2/hoge
|
||||
ExecStart=test -f /var/lib/private/test-dynamicuser-migrate/yay
|
||||
ExecStart=test -f /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay
|
||||
ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
|
||||
ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||
ExecStart=touch /var/lib/private/test-dynamicuser-migrate/yay
|
||||
ExecStart=touch /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay
|
||||
|
||||
Type=oneshot
|
||||
DynamicUser=yes
|
||||
|
@ -2,17 +2,17 @@
|
||||
Description=Test DynamicUser= with StateDirectory=
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/waldo'
|
||||
ExecStart=/bin/sh -c 'test -w /var/lib/quux/pief'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/waldo/yay'
|
||||
ExecStart=/bin/sh -c 'touch /var/lib/quux/pief/yayyay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/waldo/yay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/quux/pief/yayyay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/waldo/yay'
|
||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/quux/pief/yayyay'
|
||||
ExecStart=test -w /var/lib/waldo
|
||||
ExecStart=test -w /var/lib/quux/pief
|
||||
ExecStart=touch /var/lib/waldo/yay
|
||||
ExecStart=touch /var/lib/quux/pief/yayyay
|
||||
ExecStart=test -f /var/lib/waldo/yay
|
||||
ExecStart=test -f /var/lib/quux/pief/yayyay
|
||||
ExecStart=test -f /var/lib/private/waldo/yay
|
||||
ExecStart=test -f /var/lib/private/quux/pief/yayyay
|
||||
|
||||
# Make sure that /var/lib/private/waldo is really the only writable directory besides the obvious candidates
|
||||
ExecStart=/bin/sh -x -c 'test $$(find / -type d -writable 2> /dev/null | egrep -v -e \'^(/var/tmp$$|/tmp$$|/proc/|/dev/mqueue$$|/dev/shm$$|/sys/fs/bpf$$)\' | sort -u | tr -d '\\\\n') = /var/lib/private/quux/pief/var/lib/private/waldo'
|
||||
ExecStart=sh -x -c 'test $$(find / -type d -writable 2> /dev/null | egrep -v -e \'^(/var/tmp$$|/tmp$$|/proc/|/dev/mqueue$$|/dev/shm$$|/sys/fs/bpf$$)\' | sort -u | tr -d '\\\\n') = /var/lib/private/quux/pief/var/lib/private/waldo'
|
||||
|
||||
Type=oneshot
|
||||
DynamicUser=yes
|
||||
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=~mnt
|
||||
|
||||
[Service]
|
||||
RestrictNamespaces=~mnt
|
||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
||||
ExecStart=unshare -m
|
||||
Type=oneshot
|
||||
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=mnt
|
||||
|
||||
[Service]
|
||||
RestrictNamespaces=mnt
|
||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
||||
ExecStart=unshare -m
|
||||
Type=oneshot
|
||||
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=no
|
||||
|
||||
[Service]
|
||||
RestrictNamespaces=no
|
||||
ExecStart=/bin/sh -x -c 'unshare -m -u -i -n -p -f'
|
||||
ExecStart=unshare -m -u -i -n -p -f
|
||||
Type=oneshot
|
||||
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=yes
|
||||
|
||||
[Service]
|
||||
RestrictNamespaces=yes
|
||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
||||
ExecStart=unshare -m
|
||||
Type=oneshot
|
||||
|
@ -3,22 +3,22 @@ Description=Test for specifiers
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/test %n = exec-specifier.service
|
||||
ExecStart=/usr/bin/test %N = exec-specifier
|
||||
ExecStart=/usr/bin/test %p = exec-specifier
|
||||
ExecStart=/usr/bin/test %P = exec/specifier
|
||||
ExecStart=/usr/bin/test %i = ""
|
||||
ExecStart=/usr/bin/test %I = ""
|
||||
ExecStart=/usr/bin/test %f = /exec/specifier
|
||||
ExecStart=/usr/bin/test %t = /run
|
||||
ExecStart=/usr/bin/test %S = /var/lib
|
||||
ExecStart=/usr/bin/test %C = /var/cache
|
||||
ExecStart=/usr/bin/test %L = /var/log
|
||||
ExecStart=/bin/sh -c 'test %u = $$(id -un 0)'
|
||||
ExecStart=/usr/bin/test %U = 0
|
||||
ExecStart=/bin/sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
||||
ExecStart=/bin/sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||
ExecStart=/bin/sh -c 'test %m = $$(cat /etc/machine-id)'
|
||||
ExecStart=/bin/sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||
ExecStart=/bin/sh -c 'test %H = $$(hostname)'
|
||||
ExecStart=/bin/sh -c 'test %v = $$(uname -r)'
|
||||
ExecStart=test %n = exec-specifier.service
|
||||
ExecStart=test %N = exec-specifier
|
||||
ExecStart=test %p = exec-specifier
|
||||
ExecStart=test %P = exec/specifier
|
||||
ExecStart=test %i = ""
|
||||
ExecStart=test %I = ""
|
||||
ExecStart=test %f = /exec/specifier
|
||||
ExecStart=test %t = /run
|
||||
ExecStart=test %S = /var/lib
|
||||
ExecStart=test %C = /var/cache
|
||||
ExecStart=test %L = /var/log
|
||||
ExecStart=sh -c 'test %u = $$(id -un 0)'
|
||||
ExecStart=test %U = 0
|
||||
ExecStart=sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
||||
ExecStart=sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||
ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)'
|
||||
ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||
ExecStart=sh -c 'test %H = $$(hostname)'
|
||||
ExecStart=sh -c 'test %v = $$(uname -r)'
|
||||
|
@ -3,22 +3,22 @@ Description=Test for specifiers (template unit)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/test %n = exec-specifier@foo-bar.service
|
||||
ExecStart=/usr/bin/test %N = exec-specifier@foo-bar
|
||||
ExecStart=/usr/bin/test %p = exec-specifier
|
||||
ExecStart=/usr/bin/test %P = exec/specifier
|
||||
ExecStart=/usr/bin/test %i = foo-bar
|
||||
ExecStart=/usr/bin/test %I = foo/bar
|
||||
ExecStart=/usr/bin/test %f = /foo/bar
|
||||
ExecStart=/usr/bin/test %t = /run
|
||||
ExecStart=/usr/bin/test %S = /var/lib
|
||||
ExecStart=/usr/bin/test %C = /var/cache
|
||||
ExecStart=/usr/bin/test %L = /var/log
|
||||
ExecStart=/bin/sh -c 'test %u = $$(id -un 0)'
|
||||
ExecStart=/usr/bin/test %U = 0
|
||||
ExecStart=/bin/sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
||||
ExecStart=/bin/sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||
ExecStart=/bin/sh -c 'test %m = $$(cat /etc/machine-id)'
|
||||
ExecStart=/bin/sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||
ExecStart=/bin/sh -c 'test %H = $$(hostname)'
|
||||
ExecStart=/bin/sh -c 'test %v = $$(uname -r)'
|
||||
ExecStart=test %n = exec-specifier@foo-bar.service
|
||||
ExecStart=test %N = exec-specifier@foo-bar
|
||||
ExecStart=test %p = exec-specifier
|
||||
ExecStart=test %P = exec/specifier
|
||||
ExecStart=test %i = foo-bar
|
||||
ExecStart=test %I = foo/bar
|
||||
ExecStart=test %f = /foo/bar
|
||||
ExecStart=test %t = /run
|
||||
ExecStart=test %S = /var/lib
|
||||
ExecStart=test %C = /var/cache
|
||||
ExecStart=test %L = /var/log
|
||||
ExecStart=sh -c 'test %u = $$(id -un 0)'
|
||||
ExecStart=test %U = 0
|
||||
ExecStart=sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
||||
ExecStart=sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||
ExecStart=sh -c 'test %m = $$(cat /etc/machine-id)'
|
||||
ExecStart=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||
ExecStart=sh -c 'test %H = $$(hostname)'
|
||||
ExecStart=sh -c 'test %v = $$(uname -r)'
|
||||
|
@ -5,28 +5,28 @@ Description=Test for TemporaryFileSystem
|
||||
Type=oneshot
|
||||
|
||||
# Check directories exist
|
||||
ExecStart=/bin/sh -c 'test -d /var/test-exec-temporaryfilesystem/rw && test -d /var/test-exec-temporaryfilesystem/ro'
|
||||
ExecStart=test -d /var/test-exec-temporaryfilesystem/rw -a -d /var/test-exec-temporaryfilesystem/ro
|
||||
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=/bin/sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
ExecStart=sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
|
||||
# Create a file in /var
|
||||
ExecStart=/bin/sh -c 'touch /var/hoge'
|
||||
ExecStart=touch /var/hoge
|
||||
|
||||
# Create a file in /var/test-exec-temporaryfilesystem/rw
|
||||
ExecStart=/bin/sh -c 'touch /var/test-exec-temporaryfilesystem/rw/thisisasimpletest-temporaryfilesystem'
|
||||
ExecStart=touch /var/test-exec-temporaryfilesystem/rw/thisisasimpletest-temporaryfilesystem
|
||||
|
||||
# Then, the file can be access through /tmp
|
||||
ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
ExecStart=test -f /tmp/thisisasimpletest-temporaryfilesystem
|
||||
|
||||
# Also, through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c 'test -f /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
ExecStart=test -f /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem
|
||||
|
||||
# The file cannot modify through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c '! touch /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
ExecStart=sh -c '! touch /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Cleanup
|
||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
ExecStart=rm /tmp/thisisasimpletest-temporaryfilesystem
|
||||
|
||||
TemporaryFileSystem=/var
|
||||
BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
|
||||
|
Loading…
Reference in New Issue
Block a user