aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorHans Nilsson <hans@erlang.org>2015-11-11 16:10:57 +0100
committerHans Nilsson <hans@erlang.org>2015-11-11 16:10:57 +0100
commit98e1d3394514181648c64ab9e5f7a1af2573d658 (patch)
treea69a75e26060058ad23f506ef0d9538227b0d6d7 /lib/ssh
parent7eb292fd6849e43dad0b738027d90ca4944d14e2 (diff)
parent37e598c1784595f8e10924ac2460d71c0c251c2c (diff)
downloadotp-98e1d3394514181648c64ab9e5f7a1af2573d658.tar.gz
otp-98e1d3394514181648c64ab9e5f7a1af2573d658.tar.bz2
otp-98e1d3394514181648c64ab9e5f7a1af2573d658.zip
Merge branch 'hans/ssh/knownhost_loss/OTP-12699' into maint
* hans/ssh/knownhost_loss/OTP-12699: ssh: add better error handling in ssh_file
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh_file.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index c087ce14d7..2f16a31cba 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -221,9 +221,11 @@ do_lookup_host_key(KeyToMatch, Host, Alg, Opts) ->
{ok, Fd} ->
Res = lookup_host_key_fd(Fd, KeyToMatch, Host, Alg),
file:close(Fd),
- {ok, Res};
- {error, enoent} -> {error, not_found};
- Error -> Error
+ Res;
+ {error, enoent} ->
+ {error, not_found};
+ Error ->
+ Error
end.
identity_key_filename('ssh-dss' ) -> "id_dsa";
@@ -242,6 +244,9 @@ lookup_host_key_fd(Fd, KeyToMatch, Host, KeyType) ->
case io:get_line(Fd, '') of
eof ->
{error, not_found};
+ {error,Error} ->
+ %% Rare... For example NFS errors
+ {error,Error};
Line ->
case ssh_decode_line(Line, known_hosts) of
[{Key, Attributes}] ->
@@ -262,7 +267,7 @@ handle_host(Fd, KeyToMatch, Host, HostList, Key, KeyType) ->
Host1 = host_name(Host),
case lists:member(Host1, HostList) andalso key_match(Key, KeyType) of
true when KeyToMatch == Key ->
- Key;
+ {ok,Key};
_ ->
lookup_host_key_fd(Fd, KeyToMatch, Host, KeyType)
end.
@@ -309,6 +314,9 @@ lookup_user_key_fd(Fd, Key) ->
case io:get_line(Fd, '') of
eof ->
{error, not_found};
+ {error,Error} ->
+ %% Rare... For example NFS errors
+ {error,Error};
Line ->
case ssh_decode_line(Line, auth_keys) of
[{AuthKey, _}] ->