diff options
author | 2012-12-06 06:06:54 +0000 | |
---|---|---|
committer | 2012-12-06 06:06:54 +0000 | |
commit | a477ac7cb86150591698ac8b7b24593f591b4c73 (patch) | |
tree | 6ff906e5bac9691ef670c82de790ccf2ac37bff6 | |
parent | Remove excessive sys/cdefs.h inclusion (diff) | |
download | wireguard-openbsd-a477ac7cb86150591698ac8b7b24593f591b4c73.tar.xz wireguard-openbsd-a477ac7cb86150591698ac8b7b24593f591b4c73.zip |
Fix some problems with the keys-command test:
- use string comparison rather than numeric comparison
- check for existing KEY_COMMAND file and don't clobber if it exists
- clean up KEY_COMMAND file if we do create it.
- check that KEY_COMMAND is executable (which it won't be if eg /var/run
is mounted noexec).
ok djm.
-rw-r--r-- | regress/usr.bin/ssh/keys-command.sh | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/regress/usr.bin/ssh/keys-command.sh b/regress/usr.bin/ssh/keys-command.sh index 4d9162de1b2..e41de55ad9a 100644 --- a/regress/usr.bin/ssh/keys-command.sh +++ b/regress/usr.bin/ssh/keys-command.sh @@ -1,4 +1,4 @@ -# $OpenBSD: keys-command.sh,v 1.1 2012/11/22 22:49:30 djm Exp $ +# $OpenBSD: keys-command.sh,v 1.2 2012/12/06 06:06:54 dtucker Exp $ # Placed in the Public Domain. tid="authorized keys from command" @@ -12,7 +12,7 @@ fi KEY_COMMAND="/var/run/keycommand_${LOGNAME}" cat << _EOF | $SUDO sh -c "cat > '$KEY_COMMAND'" #!/bin/sh -test "x\$1" -ne "x${LOGNAME}" && exit 1 +test "x\$1" != "x${LOGNAME}" && exit 1 exec cat "$OBJ/authorized_keys_${LOGNAME}" _EOF $SUDO chmod 0755 "$KEY_COMMAND" @@ -25,7 +25,13 @@ cp $OBJ/sshd_proxy $OBJ/sshd_proxy.bak echo AuthorizedKeysCommandUser ${LOGNAME} ) > $OBJ/sshd_proxy -${SSH} -F $OBJ/ssh_proxy somehost true -if [ $? -ne 0 ]; then - fail "connect failed" +if [ -x $KEY_COMMAND ]; then + ${SSH} -F $OBJ/ssh_proxy somehost true + if [ $? -ne 0 ]; then + fail "connect failed" + fi +else + echo "SKIPPED: $KEY_COMMAND not executable (/var/run mounted noexec?)" fi + +$SUDO rm -f $KEY_COMMAND |