diff --git a/test/units/testsuite-74.run.sh b/test/units/testsuite-74.run.sh index d43d17ca61..38cbca54ce 100755 --- a/test/units/testsuite-74.run.sh +++ b/test/units/testsuite-74.run.sh @@ -213,23 +213,28 @@ for opt in nice on-{active,boot,calendar,startup,unit-active,unit-inactive} prop done # Let's make sure that ProtectProc= properly moves submounts of the original /proc over to the new proc +BOOT_ID="$( "$V" -mount --bind "$V" /proc/version - -B=$(systemd-run -q --wait --pipe -p ProtectProc=invisible cat /proc/version) - -assert_eq "$A" "$B" +TMP_KVER="/tmp/version.$RANDOM" +KVER="$("$TMP_KVER" +mount --bind "$TMP_KVER" /proc/version +UNIT_KVER="$(systemd-run -q --wait --pipe -p ProtectProc=invisible cat /proc/version)" +assert_eq "$KVER" "$UNIT_KVER" +umount /proc/version +rm -f "$TMP_KVER" # Check that invoking the tool under the uid0 alias name works uid0 ls / -echo "$(uid0 echo foo)" = "foo" - -umount /proc/version -rm "$V" +assert_eq "$(uid0 echo foo)" "foo" +# Check if we set some expected environment variables +for arg in "" "--user=root" "--user=testuser"; do + assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_USER')" "$USER" + assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_UID')" "$(id -u "$USER")" + assert_eq "$(uid0 ${arg:+"$arg"} bash -c 'echo $SUDO_GID')" "$(id -u "$USER")" +done +# Let's chain a couple of uid0 calls together, for fun +readarray -t cmdline < <(printf "%.0suid0\n" {0..31}) +assert_eq "$("${cmdline[@]}" bash -c 'echo $SUDO_USER')" "$USER"