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]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
# Create a file in /tmp/test-exec-bindpaths
|
# 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
|
# 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
|
# 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
|
# The file cannot modify through /tmp/test-exec-bindreadonlypaths
|
||||||
ExecStart=/bin/sh -x -c '! touch /tmp/test-exec-bindreadonlypaths/thisisasimpletest'
|
ExecStart=/bin/sh -x -c '! touch /tmp/test-exec-bindreadonlypaths/thisisasimpletest'
|
||||||
# Cleanup
|
# Cleanup
|
||||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest'
|
ExecStart=rm /tmp/thisisasimpletest
|
||||||
BindPaths=/tmp:/tmp/test-exec-bindpaths
|
BindPaths=/tmp:/tmp/test-exec-bindpaths
|
||||||
BindReadOnlyPaths=/tmp:/tmp/test-exec-bindreadonlypaths
|
BindReadOnlyPaths=/tmp:/tmp/test-exec-bindreadonlypaths
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate'
|
ExecStart=test -w /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -w /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test ! -L /var/lib/test-dynamicuser-migrate'
|
ExecStart=test ! -L /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test ! -L /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test ! -L /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate'
|
ExecStart=test -d /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -d /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate/yay'
|
ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||||
|
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
DynamicUser=no
|
DynamicUser=no
|
||||||
|
|
|
@ -2,22 +2,22 @@
|
||||||
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
Description=Test DynamicUser= migrate StateDirectory= (preparation)
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate'
|
ExecStart=test -w /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -w /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test -L /var/lib/test-dynamicuser-migrate'
|
ExecStart=test -L /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -L /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -L /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate'
|
ExecStart=test -d /var/lib/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -d /var/lib/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/test-dynamicuser-migrate/yay'
|
ExecStart=test -f /var/lib/test-dynamicuser-migrate/yay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
ExecStart=test -f /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/private/test-dynamicuser-migrate'
|
ExecStart=test -d /var/lib/private/test-dynamicuser-migrate
|
||||||
ExecStart=/bin/sh -c 'test -d /var/lib/private/test-dynamicuser-migrate2/hoge'
|
ExecStart=test -d /var/lib/private/test-dynamicuser-migrate2/hoge
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/test-dynamicuser-migrate/yay'
|
ExecStart=test -f /var/lib/private/test-dynamicuser-migrate/yay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay'
|
ExecStart=test -f /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate/yay'
|
ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay'
|
ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/private/test-dynamicuser-migrate/yay'
|
ExecStart=touch /var/lib/private/test-dynamicuser-migrate/yay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay'
|
ExecStart=touch /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay
|
||||||
|
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
DynamicUser=yes
|
DynamicUser=yes
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
Description=Test DynamicUser= with StateDirectory=
|
Description=Test DynamicUser= with StateDirectory=
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/waldo'
|
ExecStart=test -w /var/lib/waldo
|
||||||
ExecStart=/bin/sh -c 'test -w /var/lib/quux/pief'
|
ExecStart=test -w /var/lib/quux/pief
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/waldo/yay'
|
ExecStart=touch /var/lib/waldo/yay
|
||||||
ExecStart=/bin/sh -c 'touch /var/lib/quux/pief/yayyay'
|
ExecStart=touch /var/lib/quux/pief/yayyay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/waldo/yay'
|
ExecStart=test -f /var/lib/waldo/yay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/quux/pief/yayyay'
|
ExecStart=test -f /var/lib/quux/pief/yayyay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/waldo/yay'
|
ExecStart=test -f /var/lib/private/waldo/yay
|
||||||
ExecStart=/bin/sh -c 'test -f /var/lib/private/quux/pief/yayyay'
|
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
|
# 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
|
Type=oneshot
|
||||||
DynamicUser=yes
|
DynamicUser=yes
|
||||||
|
|
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=~mnt
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestrictNamespaces=~mnt
|
RestrictNamespaces=~mnt
|
||||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
ExecStart=unshare -m
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=mnt
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestrictNamespaces=mnt
|
RestrictNamespaces=mnt
|
||||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
ExecStart=unshare -m
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=no
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestrictNamespaces=no
|
RestrictNamespaces=no
|
||||||
ExecStart=/bin/sh -x -c 'unshare -m -u -i -n -p -f'
|
ExecStart=unshare -m -u -i -n -p -f
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -3,5 +3,5 @@ Description=Test RestrictNamespaces=yes
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestrictNamespaces=yes
|
RestrictNamespaces=yes
|
||||||
ExecStart=/bin/sh -x -c 'unshare -m'
|
ExecStart=unshare -m
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
|
@ -3,22 +3,22 @@ Description=Test for specifiers
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/test %n = exec-specifier.service
|
ExecStart=test %n = exec-specifier.service
|
||||||
ExecStart=/usr/bin/test %N = exec-specifier
|
ExecStart=test %N = exec-specifier
|
||||||
ExecStart=/usr/bin/test %p = exec-specifier
|
ExecStart=test %p = exec-specifier
|
||||||
ExecStart=/usr/bin/test %P = exec/specifier
|
ExecStart=test %P = exec/specifier
|
||||||
ExecStart=/usr/bin/test %i = ""
|
ExecStart=test %i = ""
|
||||||
ExecStart=/usr/bin/test %I = ""
|
ExecStart=test %I = ""
|
||||||
ExecStart=/usr/bin/test %f = /exec/specifier
|
ExecStart=test %f = /exec/specifier
|
||||||
ExecStart=/usr/bin/test %t = /run
|
ExecStart=test %t = /run
|
||||||
ExecStart=/usr/bin/test %S = /var/lib
|
ExecStart=test %S = /var/lib
|
||||||
ExecStart=/usr/bin/test %C = /var/cache
|
ExecStart=test %C = /var/cache
|
||||||
ExecStart=/usr/bin/test %L = /var/log
|
ExecStart=test %L = /var/log
|
||||||
ExecStart=/bin/sh -c 'test %u = $$(id -un 0)'
|
ExecStart=sh -c 'test %u = $$(id -un 0)'
|
||||||
ExecStart=/usr/bin/test %U = 0
|
ExecStart=test %U = 0
|
||||||
ExecStart=/bin/sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
ExecStart=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=sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||||
ExecStart=/bin/sh -c 'test %m = $$(cat /etc/machine-id)'
|
ExecStart=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=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||||
ExecStart=/bin/sh -c 'test %H = $$(hostname)'
|
ExecStart=sh -c 'test %H = $$(hostname)'
|
||||||
ExecStart=/bin/sh -c 'test %v = $$(uname -r)'
|
ExecStart=sh -c 'test %v = $$(uname -r)'
|
||||||
|
|
|
@ -3,22 +3,22 @@ Description=Test for specifiers (template unit)
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/bin/test %n = exec-specifier@foo-bar.service
|
ExecStart=test %n = exec-specifier@foo-bar.service
|
||||||
ExecStart=/usr/bin/test %N = exec-specifier@foo-bar
|
ExecStart=test %N = exec-specifier@foo-bar
|
||||||
ExecStart=/usr/bin/test %p = exec-specifier
|
ExecStart=test %p = exec-specifier
|
||||||
ExecStart=/usr/bin/test %P = exec/specifier
|
ExecStart=test %P = exec/specifier
|
||||||
ExecStart=/usr/bin/test %i = foo-bar
|
ExecStart=test %i = foo-bar
|
||||||
ExecStart=/usr/bin/test %I = foo/bar
|
ExecStart=test %I = foo/bar
|
||||||
ExecStart=/usr/bin/test %f = /foo/bar
|
ExecStart=test %f = /foo/bar
|
||||||
ExecStart=/usr/bin/test %t = /run
|
ExecStart=test %t = /run
|
||||||
ExecStart=/usr/bin/test %S = /var/lib
|
ExecStart=test %S = /var/lib
|
||||||
ExecStart=/usr/bin/test %C = /var/cache
|
ExecStart=test %C = /var/cache
|
||||||
ExecStart=/usr/bin/test %L = /var/log
|
ExecStart=test %L = /var/log
|
||||||
ExecStart=/bin/sh -c 'test %u = $$(id -un 0)'
|
ExecStart=sh -c 'test %u = $$(id -un 0)'
|
||||||
ExecStart=/usr/bin/test %U = 0
|
ExecStart=test %U = 0
|
||||||
ExecStart=/bin/sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'
|
ExecStart=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=sh -c 'test %s = $$(getent passwd 0 | cut -d: -f 7)'
|
||||||
ExecStart=/bin/sh -c 'test %m = $$(cat /etc/machine-id)'
|
ExecStart=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=sh -c 'test %b = $$(cat /proc/sys/kernel/random/boot_id | sed -e 's/-//g')'
|
||||||
ExecStart=/bin/sh -c 'test %H = $$(hostname)'
|
ExecStart=sh -c 'test %H = $$(hostname)'
|
||||||
ExecStart=/bin/sh -c 'test %v = $$(uname -r)'
|
ExecStart=sh -c 'test %v = $$(uname -r)'
|
||||||
|
|
|
@ -5,28 +5,28 @@ Description=Test for TemporaryFileSystem
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
|
||||||
# Check directories exist
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# 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
|
# Cleanup
|
||||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest-temporaryfilesystem'
|
ExecStart=rm /tmp/thisisasimpletest-temporaryfilesystem
|
||||||
|
|
||||||
TemporaryFileSystem=/var
|
TemporaryFileSystem=/var
|
||||||
BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
|
BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
|
||||||
|
|
Loading…
Reference in New Issue