diff options
author | Erlang/OTP <[email protected]> | 2016-06-29 17:42:52 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2016-06-29 17:42:52 +0200 |
commit | 10991ae10b85d65215aaf570127c29d1e48a2e62 (patch) | |
tree | 54d6c25fd4e1a4b04db5039f43e0bfb473d4af1e /lib/ssh/src/ssh_connection_handler.erl | |
parent | 932cda08f6a1e08fd908097276fd10529b7d8e29 (diff) | |
parent | e6e8b9bd005910ba3840b5ff154e37d5e1366a8b (diff) | |
download | otp-10991ae10b85d65215aaf570127c29d1e48a2e62.tar.gz otp-10991ae10b85d65215aaf570127c29d1e48a2e62.tar.bz2 otp-10991ae10b85d65215aaf570127c29d1e48a2e62.zip |
Merge branch 'hans/ssh/retry_passwd_patch/OTP-13674' into maint-19
* hans/ssh/retry_passwd_patch/OTP-13674:
ssh: update vsn.mk
ssh: polishing of password prompt's linefeed
ssh: Fix a hazard bug in ssh_auth
ssh: Some code cuddling in ssh_io
ssh: Fix type error in args of ssh_auth:sort_selected_mthds
ssh: Make client send a faulty pwd only once, ssh_connection_handler part
ssh: Make client send a faulty pwd only once, ssh_auth part
ssh: test cases for no repetition of bad passwords
Diffstat (limited to 'lib/ssh/src/ssh_connection_handler.erl')
-rw-r--r-- | lib/ssh/src/ssh_connection_handler.erl | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index e952a333ff..27c205a932 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -428,7 +428,12 @@ init_connection(server, C = #connection{}, Opts) -> init_ssh_record(Role, Socket, Opts) -> {ok, PeerAddr} = inet:peername(Socket), KeyCb = proplists:get_value(key_cb, Opts, ssh_file), - AuthMethods = proplists:get_value(auth_methods, Opts, ?SUPPORTED_AUTH_METHODS), + AuthMethods = proplists:get_value(auth_methods, + Opts, + case Role of + server -> ?SUPPORTED_AUTH_METHODS; + client -> undefined + end), S0 = #ssh{role = Role, key_cb = KeyCb, opts = Opts, @@ -794,9 +799,13 @@ handle_event(_, #ssh_msg_userauth_banner{message = Msg}, {userauth,client}, D) - handle_event(_, #ssh_msg_userauth_info_request{} = Msg, {userauth_keyboard_interactive, client}, #data{ssh_params = Ssh0} = D) -> - {ok, {Reply, Ssh}} = ssh_auth:handle_userauth_info_request(Msg, Ssh0#ssh.io_cb, Ssh0), - send_bytes(Reply, D), - {next_state, {userauth_keyboard_interactive_info_response,client}, D#data{ssh_params = Ssh}}; + case ssh_auth:handle_userauth_info_request(Msg, Ssh0) of + {ok, {Reply, Ssh}} -> + send_bytes(Reply, D), + {next_state, {userauth_keyboard_interactive_info_response,client}, D#data{ssh_params = Ssh}}; + not_ok -> + {next_state, {userauth,client}, D, [{next_event, internal, Msg}]} + end; handle_event(_, #ssh_msg_userauth_info_response{} = Msg, {userauth_keyboard_interactive, server}, D) -> case ssh_auth:handle_userauth_info_response(Msg, D#data.ssh_params) of @@ -819,7 +828,18 @@ handle_event(_, Msg = #ssh_msg_userauth_failure{}, {userauth_keyboard_interactiv D = D0#data{ssh_params = Ssh0#ssh{userauth_preference=Prefs}}, {next_state, {userauth,client}, D, [{next_event, internal, Msg}]}; -handle_event(_, Msg=#ssh_msg_userauth_failure{}, {userauth_keyboard_interactive_info_response, client}, D) -> +handle_event(_, Msg=#ssh_msg_userauth_failure{}, {userauth_keyboard_interactive_info_response, client}, + #data{ssh_params = Ssh0} = D0) -> + Opts = Ssh0#ssh.opts, + D = case proplists:get_value(password, Opts) of + undefined -> + D0; + _ -> + D0#data{ssh_params = + Ssh0#ssh{opts = + lists:keyreplace(password,1,Opts, + {password,not_ok})}} % FIXME:intermodule dependency + end, {next_state, {userauth,client}, D, [{next_event, internal, Msg}]}; handle_event(_, Msg=#ssh_msg_userauth_success{}, {userauth_keyboard_interactive_info_response, client}, D) -> |