From: Ian Jackson Date: Sun, 26 Dec 2021 00:24:21 +0000 (+0000) Subject: autopkgtests: wip, a test for non-root to non-root X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=commitdiff_plain;h=891ed69cbbbb1e84a884bde3a02af3c22e114eaf autopkgtests: wip, a test for non-root to non-root Signed-off-by: Ian Jackson --- diff --git a/.gitignore b/.gitignore index 69b856b..c018b41 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ *.o +tmp daemon client diff --git a/debian/tests/control b/debian/tests/control index cc11fad..e5bae1e 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -2,3 +2,8 @@ Tests: t-basic Depends: @, bash Tests-Directory: tests Restrictions: isolation-container, allow-stderr, needs-root + +Tests: t-config +Depends: @, bash, chiark-really +Tests-Directory: tests +Restrictions: isolation-container, allow-stderr, needs-root, breaks-testbed diff --git a/tests/lib b/tests/lib index ae2aa50..bf56c46 100644 --- a/tests/lib +++ b/tests/lib @@ -4,7 +4,8 @@ expect_output () { local e_status=$1; shift local e_stdout=$1; shift set +e - local g_stdout="$( "$@" )" + local g_stdout + g_stdout="$( "$@" )" local g_status=$? set -e test "$g_status" = "$e_status" diff --git a/tests/t-basic b/tests/t-basic index 969bbc4..e06ba71 100755 --- a/tests/t-basic +++ b/tests/t-basic @@ -5,3 +5,5 @@ set -ex expect_output 0 'games' \ userv --override 'execute whoami' games spong + +echo ok. diff --git a/tests/t-config b/tests/t-config new file mode 100755 index 0000000..64e2b83 --- /dev/null +++ b/tests/t-config @@ -0,0 +1,43 @@ +#!/bin/bash +set -ex + +. tests/lib + +( + cat >/etc/userv/services.d/userv-t-config <"$tmp"/env + +for expect in \ + 'USERV_SERVICE=userv-t-config' \ + 'USERV_USER=bin' \ + 'USERV_GROUP=bin bin' \ + "USERV_UID=$bin_uid" \ + "USERV_GID=$bin_gid $bin_gid" \ +; do + egrep "^$expect\$" "$tmp"/env +done + +expect_output 255 '' \ +really -u daemon \ +userv games userv-t-config + +echo ok.