diff options
author | Colin Watson <cjwatson@debian.org> | 2016-12-27 16:00:40 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2016-12-27 16:00:40 +0000 |
commit | c46ae24baae62b55577aac54deccd631fa134062 (patch) | |
tree | a0b9dd9b0c2e3c5afbbde21c13c3739157dd9218 /debian/tests/regress | |
parent | ab9e62811d05708655a430199531465edda1e294 (diff) |
When running regression tests under autopkgtest, use a non-root user with passwordless sudo.
Diffstat (limited to 'debian/tests/regress')
-rwxr-xr-x | debian/tests/regress | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/debian/tests/regress b/debian/tests/regress index 253541ad5..846482d62 100755 --- a/debian/tests/regress +++ b/debian/tests/regress | |||
@@ -1,10 +1,33 @@ | |||
1 | #! /bin/sh | 1 | #! /bin/sh |
2 | set -e | 2 | set -e |
3 | 3 | ||
4 | if [ "$(id -un)" != openssh-tests ]; then | ||
5 | TMP="$ADTTMP/user" | ||
6 | |||
7 | cleanup () { | ||
8 | rm -rf "$TMP" | ||
9 | rm -f /etc/sudoers.d/openssh-tests | ||
10 | if id openssh-tests >/dev/null 2>&1; then | ||
11 | deluser --remove-home openssh-tests | ||
12 | fi | ||
13 | } | ||
14 | trap cleanup EXIT | ||
15 | |||
16 | adduser --disabled-password --gecos 'OpenSSH tests' openssh-tests | ||
17 | cat >/etc/sudoers.d/openssh-tests <<EOF | ||
18 | openssh-tests ALL = (ALL:ALL) NOPASSWD: ALL | ||
19 | EOF | ||
20 | chmod 440 /etc/sudoers.d/openssh-tests | ||
21 | mkdir -p "$TMP" | ||
22 | chown openssh-tests:openssh-tests "$TMP" | ||
23 | sudo -u openssh-tests env TMP="$TMP" "$0" "$@" | ||
24 | exit "$?" | ||
25 | fi | ||
26 | |||
4 | # Don't use "make tests"; we want to test the installed version. | 27 | # Don't use "make tests"; we want to test the installed version. |
5 | 28 | ||
6 | cp -a . "$ADTTMP/tree" | 29 | cp -a . "$TMP/tree" |
7 | cd "$ADTTMP/tree" | 30 | cd "$TMP/tree" |
8 | 31 | ||
9 | # We aren't actually going to use most of this build, but we need a basic | 32 | # We aren't actually going to use most of this build, but we need a basic |
10 | # build tree in place in order to be able to build the regression tests. | 33 | # build tree in place in order to be able to build the regression tests. |