diff options
Diffstat (limited to 'regress/keys-command.sh')
-rw-r--r-- | regress/keys-command.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/regress/keys-command.sh b/regress/keys-command.sh new file mode 100644 index 000000000..b595a434f --- /dev/null +++ b/regress/keys-command.sh | |||
@@ -0,0 +1,39 @@ | |||
1 | # $OpenBSD: keys-command.sh,v 1.2 2012/12/06 06:06:54 dtucker Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="authorized keys from command" | ||
5 | |||
6 | if test -z "$SUDO" ; then | ||
7 | echo "skipped (SUDO not set)" | ||
8 | echo "need SUDO to create file in /var/run, test won't work without" | ||
9 | exit 0 | ||
10 | fi | ||
11 | |||
12 | # Establish a AuthorizedKeysCommand in /var/run where it will have | ||
13 | # acceptable directory permissions. | ||
14 | KEY_COMMAND="/var/run/keycommand_${LOGNAME}" | ||
15 | cat << _EOF | $SUDO sh -c "cat > '$KEY_COMMAND'" | ||
16 | #!/bin/sh | ||
17 | test "x\$1" != "x${LOGNAME}" && exit 1 | ||
18 | exec cat "$OBJ/authorized_keys_${LOGNAME}" | ||
19 | _EOF | ||
20 | $SUDO chmod 0755 "$KEY_COMMAND" | ||
21 | |||
22 | cp $OBJ/sshd_proxy $OBJ/sshd_proxy.bak | ||
23 | ( | ||
24 | grep -vi AuthorizedKeysFile $OBJ/sshd_proxy.bak | ||
25 | echo AuthorizedKeysFile none | ||
26 | echo AuthorizedKeysCommand $KEY_COMMAND | ||
27 | echo AuthorizedKeysCommandUser ${LOGNAME} | ||
28 | ) > $OBJ/sshd_proxy | ||
29 | |||
30 | if [ -x $KEY_COMMAND ]; then | ||
31 | ${SSH} -F $OBJ/ssh_proxy somehost true | ||
32 | if [ $? -ne 0 ]; then | ||
33 | fail "connect failed" | ||
34 | fi | ||
35 | else | ||
36 | echo "SKIPPED: $KEY_COMMAND not executable (/var/run mounted noexec?)" | ||
37 | fi | ||
38 | |||
39 | $SUDO rm -f $KEY_COMMAND | ||