View | Details | Raw Unified | Return to bug 2772
Collapse All | Expand All

(-)a/openssh/regress/keygen-knownhosts.sh (-3 / +26 lines)
Lines 62-67 Link Here
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
Lines 88-93 Link Here
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
Lines 110-128 Link Here
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" "-q -H"
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" "-q -H"
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" "-q -H"
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
(-)a/openssh/ssh-keygen.c (-2 / +2 lines)
Lines 1274-1281 Link Here
1274
	foreach_options = find_host ? HKF_WANT_MATCH : 0;
1274
	foreach_options = find_host ? HKF_WANT_MATCH : 0;
1275
	foreach_options |= print_fingerprint ? HKF_WANT_PARSE_KEY : 0;
1275
	foreach_options |= print_fingerprint ? HKF_WANT_PARSE_KEY : 0;
1276
	if ((r = hostkeys_foreach(identity_file,
1276
	if ((r = hostkeys_foreach(identity_file,
1277
	    hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx,
1277
	    hash_hosts && !find_host ? known_hosts_hash : known_hosts_find_delete,
1278
	    name, NULL, foreach_options)) != 0) {
1278
	    &ctx, name, NULL, foreach_options)) != 0) {
1279
		if (inplace)
1279
		if (inplace)
1280
			unlink(tmp);
1280
			unlink(tmp);
1281
		fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r));
1281
		fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r));

Return to bug 2772