Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 63b0399

Browse files
ansasakicryptomilk
authored andcommitted
tests: Added a check for unaccessible global known_hosts
Verify that the check process will not fail if the global known_hosts file is not accessible and the local known_hosts file contain the host. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com> (cherry picked from commit 8e42ed8)
1 parent 39665fd commit 63b0399

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/unittests/torture_knownhosts_parsing.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,22 @@ static void torture_knownhosts_host_exists(void **state)
381381

382382
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
383383
ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, knownhosts_file);
384+
384385
/* This makes sure the system's known_hosts are not used */
385386
ssh_options_set(session, SSH_OPTIONS_GLOBAL_KNOWNHOSTS, "/dev/null");
386387

387388
found = ssh_session_has_known_hosts_entry(session);
388389
assert_int_equal(found, SSH_KNOWN_HOSTS_OK);
389390
assert_true(found == SSH_KNOWN_HOSTS_OK);
390391

392+
/* This makes sure the check will not fail when the system's known_hosts is
393+
* not accessible*/
394+
ssh_options_set(session, SSH_OPTIONS_GLOBAL_KNOWNHOSTS, "./unaccessible");
395+
396+
found = ssh_session_has_known_hosts_entry(session);
397+
assert_int_equal(found, SSH_KNOWN_HOSTS_OK);
398+
assert_true(found == SSH_KNOWN_HOSTS_OK);
399+
391400
ssh_options_set(session, SSH_OPTIONS_HOST, "wurstbrot");
392401
found = ssh_session_has_known_hosts_entry(session);
393402
assert_true(found == SSH_KNOWN_HOSTS_UNKNOWN);

0 commit comments

Comments
 (0)