1
1

40 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
7ae47df16a knownhosts: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
5b18bcb0ac knownhosts: Use ssh_mkdirs() instead of ssh_mkdir()
Previously, if the path to known_hosts file set through
SSH_OPTIONS_KNOWNHOSTS included missing directories,
ssh_session_update_known_hosts() would fail.  The added test case checks
that this is not the case anymore.

The logic of checking if the directory is accessible before creating it
was replaced by creating the directory if opening the file failed.  This
is to minimize the risk of TOCTOU race conditions.

Fixes: T166

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:53:22 +02:00
Anderson Toshiyuki Sasaki
65a38759ca knownhosts: Introduced ssh_known_hosts_get_algorithms_names()
The added internal function obtain a newly allocated string containing a
list of the signature types that can be generated by the keys present in
the known_hosts files, separated by commas.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
e5a64a3d6b knownhosts: Read knownhosts file only if found
Avoid trying to open the files if they are not accessible.  This was
already treated as a non-error, but with this we save one function call.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
fe248414fe knownhosts: Fix possible memory leak
The memory allocated for host_port can leak if the global knownhosts
file is unaccessible.

Found by address sanitizer build in CI.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
5617eaf0e2 knownhosts: Fixed a typo
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-28 08:03:29 +02:00
Anderson Toshiyuki Sasaki
4adb13d9e3 knownhosts: Do not fail if global known_hosts file is inaccessible
Previously, if the global known_hosts file (default:
/etc/ssh/ssh_known_hosts) was inaccessible, the check for known hosts
failed.  This makes the check to fail if both files are inaccessible.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-28 08:03:13 +02:00
Jakub Jelen
196361c1f0 ssh_known_hosts_get_algorithms: Avoid returning duplicate key types from known hosts algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
79cd2618ec ssh_known_hosts_read_entries: Avoid returning duplicate knownhowst items
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Andreas Schneider
1a3436d7d3 knownhosts: Fix use after free
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:17:54 +02:00
Jakub Jelen
962bdf806c knownhosts: Handle wildcard ports matches against standard one
Fixes T110

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:27 +02:00
Jakub Jelen
8152c6aba4 knownhosts: Ignore OpenSSH markers related to certificates
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:18 +02:00
Andreas Schneider
db8aca69a7 knownhosts: Avoid possible null pointer dereference
CID 1401096

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-05-06 11:40:27 +02:00
Andreas Schneider
3e8bdb122f knownhosts: Check if the hosts file exists
Fixes T135

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:27 +02:00
Sanne Raymaekers
67f418218b knownhosts: Take StrictHostKeyChecking option into account
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-08 16:19:18 +01:00
Jakub Jelen
5159cd96e8 knownhosts: Make sure we have both knownhosts files ready
If either one is missing at this point, fill it with default vaules in
ssh_options_apply().

Previously, when setting up only knownhosts, global_knownhosts file
was left pointing to NULL and the ssh_known_hosts_read_entries()
was trying to open NULL file which is invalid.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 10:08:20 +01:00
Jakub Jelen
f622c4309b knownhosts: Consult also the global known hosts file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
893b69d82b knownhosts: Use the correct name for ECDSA keys for host key negotiation
The conversion from  ssh_keytype_e  to string does not work for ECDSA keys,
because different key lengths have different string representation.

The usage of  type_c  should work also for every other key type in future,
but it does not reflrect different signature types (SHA2 extension for RSA
keys), but this early in the key exchange phase, we can not make any
assumptions about supported extensions by the server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:42:55 +02:00
Andreas Schneider
795389ae1b src: Fix typos
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 16:36:20 +02:00
Andreas Schneider
7e1b67754c knownhosts: Add knownhosts to libssh_session group
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
96476f74af kownhosts: Fix a memory leak in ssh_session_has_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
52b57077de knownhosts: Fix a memory leak in ssh_session_get_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
b3a7e86a4a knownhosts: Fix memory leak
CID 1393774

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 07:09:24 +02:00
Andreas Schneider
2d90bc9d6b knownhosts: Fix checking if server is known
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
613dcc95e6 knownhosts: Fix return codes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
e49e4e13f3 knownhosts: Implement ssh_known_hosts_get_algorithms()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:38 +02:00
Andreas Schneider
206f3ff895 Rest in Peace SSHv1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-06-29 14:41:14 +02:00
Alberto Aguirre
b50fb638f7 knownhosts: Fix windows build failure
Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-25 08:20:40 +02:00
Andreas Schneider
0940b0f29b knownhosts: Do not double free memory
CID 1393236

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-06 08:38:14 +02:00
Andreas Schneider
f5f8c0fc76 knownhosts: Fix resource leak in ssh_known_hosts_parse_line()
CID 1391444

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:44:54 +02:00
Andreas Schneider
c4dbe3b863 knownhosts: Fix a memory leak on error
CID 1391446

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:43:08 +02:00
Andreas Schneider
669678119c knownhosts: Fix possible null pointer dereference
CID 1391447

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:35:42 +02:00
Andreas Schneider
34e7a3cf8c knownhosts: Fix resource leak in ssh_session_update_known_hosts()
CID 1391448

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:34:56 +02:00
Andreas Schneider
1001cbbb99 knownhosts: Fix resource leak in ssh_known_hosts_read_entries()
CID 1391449

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:34:49 +02:00
Andreas Schneider
a209f928d2 kwonhosts: Add functions to check if servers public key is known
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
f23dbe6f42 knownhosts: Add ssh_session_update_known_hosts()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
974e1831a0 knownhosts: Add ssh_session_export_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
963c46e4fb knownhosts: Add ssh_session_has_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
a465ea2d49 knownhosts: Add ssh_known_hosts_read_entries()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
702e9e8ad5 knownhosts: Introduce new known hosts managing functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00