chiark / gitweb /
autopkgtests: wip, a test for non-root to non-root
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Dec 2021 00:24:21 +0000 (00:24 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Dec 2021 01:05:06 +0000 (01:05 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
debian/tests/control
tests/lib
tests/t-basic
tests/t-config [new file with mode: 0755]

index 69b856bfe1f0d0ad67ec275e4f98218331ba5ee3..c018b41f74337a8f761d259f0150c29bf6829e32 100644 (file)
@@ -1,5 +1,6 @@
 *~
 *.o
+tmp
 
 daemon
 client
index cc11fad9daa7b36d60a4c3da9122fe7028c712c4..e5bae1ef148e2bbdd21481f36ec3ce0a8aa69d0b 100644 (file)
@@ -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
index ae2aa505512a5da3e9f0188bb91ce53b178211b7..bf56c46399c99b15f1ed6ce8622bcc463def3f9a 100644 (file)
--- 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"
index 969bbc470458b124b08832a885f865b833658dbe..e06ba71677c0cf74fb48b19c34f0d9d22b0328fa 100755 (executable)
@@ -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 (executable)
index 0000000..64e2b83
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+set -ex
+
+. tests/lib
+
+(
+    cat >/etc/userv/services.d/userv-t-config <<END
+if ( glob calling-user bin
+   & glob service-user games
+   )
+       execute printenv
+fi
+END
+)
+
+tmp="${AUTOPKGTEST_ARTIFACTS}"
+if [ "x$tmp" = x ]; then
+    rm -rf tmp
+    mkdir tmp
+    tmp=tmp
+fi
+
+bin_uid=$(id -u bin)
+bin_gid=$(id -g bin)
+
+really -u bin \
+userv games 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.