summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-06-01 03:52:37 +0000
committerDamien Miller <djm@mindrot.org>2018-06-01 14:24:08 +1000
commita1dcafc41c376332493b9385ee39f9754dc145ec (patch)
treec72ce56abba9f84aba4665613f189cdc6444d7a3 /regress
parent76f314c75dffd4a55839d50ee23622edad52c168 (diff)
upstream: Adapt to extra default verboisity from ssh-keygen when
searching for and hashing known_hosts entries in a single operation (ssh-keygen -HF ...) Patch from Anton Kremenetsky OpenBSD-Regress-ID: 519585a4de35c4611285bd6a7272766c229b19dd
Diffstat (limited to 'regress')
-rw-r--r--regress/keygen-knownhosts.sh35
1 files changed, 29 insertions, 6 deletions
diff --git a/regress/keygen-knownhosts.sh b/regress/keygen-knownhosts.sh
index 693cd0e75..37af34769 100644
--- a/regress/keygen-knownhosts.sh
+++ b/regress/keygen-knownhosts.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: keygen-knownhosts.sh,v 1.3 2015/07/17 03:34:27 djm Exp $ 1# $OpenBSD: keygen-knownhosts.sh,v 1.4 2018/06/01 03:52:37 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="ssh-keygen known_hosts" 4tid="ssh-keygen known_hosts"
@@ -55,13 +55,24 @@ expect_key() {
55check_find() { 55check_find() {
56 _host=$1 56 _host=$1
57 _name=$2 57 _name=$2
58 _keygenopt=$3 58 shift; shift
59 ${SSHKEYGEN} $_keygenopt -f $OBJ/kh.invalid -F $_host > $OBJ/kh.result 59 ${SSHKEYGEN} "$@" -f $OBJ/kh.invalid -F $_host > $OBJ/kh.result
60 if ! diff -w $OBJ/kh.expect $OBJ/kh.result ; then 60 if ! diff -w $OBJ/kh.expect $OBJ/kh.result ; then
61 fail "didn't find $_name" 61 fail "didn't find $_name"
62 fi 62 fi
63} 63}
64 64
65check_find_exit_code() {
66 _host=$1
67 _name=$2
68 _keygenopt=$3
69 _exp_exit_code=$4
70 ${SSHKEYGEN} $_keygenopt -f $OBJ/kh.invalid -F $_host > /dev/null
71 if [ "$?" != "$_exp_exit_code" ] ; then
72 fail "Unexpected exit code $_name"
73 fi
74}
75
65# Find key 76# Find key
66rm -f $OBJ/kh.expect 77rm -f $OBJ/kh.expect
67expect_key host-a host-a host-a 2 78expect_key host-a host-a host-a 2
@@ -88,6 +99,18 @@ rm -f $OBJ/kh.expect
88expect_key host-h "host-f,host-g,host-h " host-f 17 99expect_key host-h "host-f,host-g,host-h " host-f 17
89check_find host-h "find multiple hosts" 100check_find host-h "find multiple hosts"
90 101
102# Check exit code, known host
103check_find_exit_code host-a "known host" "-q" "0"
104
105# Check exit code, unknown host
106check_find_exit_code host-aa "unknown host" "-q" "1"
107
108# Check exit code, the hash mode, known host
109check_find_exit_code host-a "known host" "-q -H" "0"
110
111# Check exit code, the hash mode, unknown host
112check_find_exit_code host-aa "unknown host" "-q -H" "1"
113
91check_hashed_find() { 114check_hashed_find() {
92 _host=$1 115 _host=$1
93 _name=$2 116 _name=$2
@@ -110,19 +133,19 @@ check_hashed_find host-a "find simple and hash"
110rm -f $OBJ/kh.expect 133rm -f $OBJ/kh.expect
111expect_key host-c host-c host-c "" CA 134expect_key host-c host-c host-c "" CA
112# CA key output is not hashed. 135# CA key output is not hashed.
113check_find host-c "find simple and hash" -H 136check_find host-c "find simple and hash" -Hq
114 137
115# Find revoked key and hash 138# Find revoked key and hash
116rm -f $OBJ/kh.expect 139rm -f $OBJ/kh.expect
117expect_key host-d host-d host-d "" REVOKED 140expect_key host-d host-d host-d "" REVOKED
118# Revoked key output is not hashed. 141# Revoked key output is not hashed.
119check_find host-d "find simple and hash" -H 142check_find host-d "find simple and hash" -Hq
120 143
121# find key with wildcard and hash 144# find key with wildcard and hash
122rm -f $OBJ/kh.expect 145rm -f $OBJ/kh.expect
123expect_key host-e "host-e*" host-e "" 146expect_key host-e "host-e*" host-e ""
124# Key with wildcard hostname should not be hashed. 147# Key with wildcard hostname should not be hashed.
125check_find host-e "find wildcard key" -H 148check_find host-e "find wildcard key" -Hq
126 149
127# find key among multiple hosts 150# find key among multiple hosts
128rm -f $OBJ/kh.expect 151rm -f $OBJ/kh.expect