diff options
Diffstat (limited to 'regress/keygen-knownhosts.sh')
-rw-r--r-- | regress/keygen-knownhosts.sh | 35 |
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 | ||
4 | tid="ssh-keygen known_hosts" | 4 | tid="ssh-keygen known_hosts" |
@@ -55,13 +55,24 @@ expect_key() { | |||
55 | check_find() { | 55 | check_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 | ||
65 | check_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 |
66 | rm -f $OBJ/kh.expect | 77 | rm -f $OBJ/kh.expect |
67 | expect_key host-a host-a host-a 2 | 78 | expect_key host-a host-a host-a 2 |
@@ -88,6 +99,18 @@ rm -f $OBJ/kh.expect | |||
88 | expect_key host-h "host-f,host-g,host-h " host-f 17 | 99 | expect_key host-h "host-f,host-g,host-h " host-f 17 |
89 | check_find host-h "find multiple hosts" | 100 | check_find host-h "find multiple hosts" |
90 | 101 | ||
102 | # Check exit code, known host | ||
103 | check_find_exit_code host-a "known host" "-q" "0" | ||
104 | |||
105 | # Check exit code, unknown host | ||
106 | check_find_exit_code host-aa "unknown host" "-q" "1" | ||
107 | |||
108 | # Check exit code, the hash mode, known host | ||
109 | check_find_exit_code host-a "known host" "-q -H" "0" | ||
110 | |||
111 | # Check exit code, the hash mode, unknown host | ||
112 | check_find_exit_code host-aa "unknown host" "-q -H" "1" | ||
113 | |||
91 | check_hashed_find() { | 114 | check_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" | |||
110 | rm -f $OBJ/kh.expect | 133 | rm -f $OBJ/kh.expect |
111 | expect_key host-c host-c host-c "" CA | 134 | expect_key host-c host-c host-c "" CA |
112 | # CA key output is not hashed. | 135 | # CA key output is not hashed. |
113 | check_find host-c "find simple and hash" -H | 136 | check_find host-c "find simple and hash" -Hq |
114 | 137 | ||
115 | # Find revoked key and hash | 138 | # Find revoked key and hash |
116 | rm -f $OBJ/kh.expect | 139 | rm -f $OBJ/kh.expect |
117 | expect_key host-d host-d host-d "" REVOKED | 140 | expect_key host-d host-d host-d "" REVOKED |
118 | # Revoked key output is not hashed. | 141 | # Revoked key output is not hashed. |
119 | check_find host-d "find simple and hash" -H | 142 | check_find host-d "find simple and hash" -Hq |
120 | 143 | ||
121 | # find key with wildcard and hash | 144 | # find key with wildcard and hash |
122 | rm -f $OBJ/kh.expect | 145 | rm -f $OBJ/kh.expect |
123 | expect_key host-e "host-e*" host-e "" | 146 | expect_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. |
125 | check_find host-e "find wildcard key" -H | 148 | check_find host-e "find wildcard key" -Hq |
126 | 149 | ||
127 | # find key among multiple hosts | 150 | # find key among multiple hosts |
128 | rm -f $OBJ/kh.expect | 151 | rm -f $OBJ/kh.expect |