From 689b5085d2e9bb1a3fbae81a0e6af600f91a5424 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Wed, 24 Oct 2012 15:23:25 +0200 Subject: [PATCH 1/7] Removing the password after auth --- lib/ssh/src/ssh_connection_manager.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index e53cd4f4f780..01452642b14e 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -523,7 +523,7 @@ handle_info({same_user, _}, State) -> handle_info(ssh_connected, #state{role = client, client = Pid} = State) -> Pid ! {self(), is_connected}, - {noreply, State#state{connected = true}}; + {noreply, State#state{connected = true, opts = handle_password(State#state.opts)}}; handle_info(ssh_connected, #state{role = server} = State) -> {noreply, State#state{connected = true}}; @@ -536,6 +536,14 @@ handle_info({'DOWN', _Ref, process, ChannelPid, _Reason}, State) -> handle_info({'EXIT', _Sup, Reason}, State) -> {stop, Reason, State}. +handle_password(Opts) -> + case proplists:get_value(ssh_opts, Opts, false) of + false -> + Opts; + SshOpts -> + NewOpts = [{password, undefined}|lists:keydelete(password, 1, SshOpts)], + {ssh_opts, lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts))} + end. %%-------------------------------------------------------------------- %% Function: terminate(Reason, State) -> void() %% Description: This function is called by a gen_server when it is about to From 161ddec59071e77bf6fc49db9dd867aa0e0e1268 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Thu, 25 Oct 2012 09:59:48 +0200 Subject: [PATCH 2/7] After auth rsa and dsa passwords is set to undefined --- lib/ssh/src/ssh_connection_manager.erl | 37 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index 01452642b14e..16a31459e78a 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -537,12 +537,45 @@ handle_info({'EXIT', _Sup, Reason}, State) -> {stop, Reason, State}. handle_password(Opts) -> + handle_rsa_password(handle_dsa_password(handle_normal_password(Opts))). +handle_normal_password(Opts) -> case proplists:get_value(ssh_opts, Opts, false) of false -> Opts; SshOpts -> - NewOpts = [{password, undefined}|lists:keydelete(password, 1, SshOpts)], - {ssh_opts, lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts))} + case proplists:get_value(password, SshOpts, false) of + false -> + Opts; + _Password -> + NewOpts = [{password, undefined}|lists:keydelete(password, 1, SshOpts)], + lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + end + end. +handle_dsa_password(Opts) -> + case proplists:get_value(ssh_opts, Opts, false) of + false -> + Opts; + SshOpts -> + case proplists:get_value(dsa_pass_phrase, SshOpts, false) of + false -> + Opts; + _Password -> + NewOpts = [{dsa_pass_phase, undefined}|lists:keydelete(password, 1, SshOpts)], + lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + end + end. +handle_rsa_password(Opts) -> + case proplists:get_value(ssh_opts, Opts, false) of + false -> + Opts; + SshOpts -> + case proplists:get_value(rsa_pass_phrase, SshOpts, false) of + false -> + Opts; + _Password -> + NewOpts = [{rsa_pass_phase, undefined}|lists:keydelete(password, 1, SshOpts)], + lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + end end. %%-------------------------------------------------------------------- %% Function: terminate(Reason, State) -> void() From 6a37d426a3f85a59adf8769d65b009012fa7d701 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Thu, 25 Oct 2012 10:34:15 +0200 Subject: [PATCH 3/7] ssh_opts is now a proper list --- lib/ssh/src/ssh_connection_manager.erl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index 16a31459e78a..dd31fe47608d 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -548,7 +548,7 @@ handle_normal_password(Opts) -> Opts; _Password -> NewOpts = [{password, undefined}|lists:keydelete(password, 1, SshOpts)], - lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + [{ssh_opts, NewOpts}|lists:keydelete(ssh_opts, 1, Opts)] end end. handle_dsa_password(Opts) -> @@ -560,11 +560,12 @@ handle_dsa_password(Opts) -> false -> Opts; _Password -> - NewOpts = [{dsa_pass_phase, undefined}|lists:keydelete(password, 1, SshOpts)], - lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + NewOpts = [{dsa_pass_phrase, undefined}|lists:keydelete(dsa_pass_phrase, 1, SshOpts)], + [{ssh_opts, NewOpts}|lists:keydelete(ssh_opts, 1, Opts)] end end. handle_rsa_password(Opts) -> + io:format("rsa"), case proplists:get_value(ssh_opts, Opts, false) of false -> Opts; @@ -573,8 +574,9 @@ handle_rsa_password(Opts) -> false -> Opts; _Password -> - NewOpts = [{rsa_pass_phase, undefined}|lists:keydelete(password, 1, SshOpts)], - lists:merge(NewOpts, lists:keydelete(ssh_opts, 1, Opts)) + io:format("rsa_2"), + NewOpts = [{rsa_pass_phrase, undefined}|lists:keydelete(rsa_pass_phrase, 1, SshOpts)], + [{ssh_opts, NewOpts}|lists:keydelete(ssh_opts, 1, Opts)] end end. %%-------------------------------------------------------------------- From 9d0aa2b3f20f6e0ddb09a4896f6cd0697d7d577f Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Thu, 25 Oct 2012 10:35:27 +0200 Subject: [PATCH 4/7] Removed some testing variables --- lib/ssh/src/ssh_connection_manager.erl | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index dd31fe47608d..5aa79f978c07 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -565,7 +565,6 @@ handle_dsa_password(Opts) -> end end. handle_rsa_password(Opts) -> - io:format("rsa"), case proplists:get_value(ssh_opts, Opts, false) of false -> Opts; @@ -574,7 +573,6 @@ handle_rsa_password(Opts) -> false -> Opts; _Password -> - io:format("rsa_2"), NewOpts = [{rsa_pass_phrase, undefined}|lists:keydelete(rsa_pass_phrase, 1, SshOpts)], [{ssh_opts, NewOpts}|lists:keydelete(ssh_opts, 1, Opts)] end From 4400bfa63bdfcdf4118fb83ccf646825e76650b9 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Wed, 7 Nov 2012 14:48:37 +0100 Subject: [PATCH 5/7] Bumped revision --- lib/ssh/vsn.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ssh/vsn.mk b/lib/ssh/vsn.mk index defa47f82419..921ec2206ab9 100644 --- a/lib/ssh/vsn.mk +++ b/lib/ssh/vsn.mk @@ -1,5 +1,5 @@ #-*-makefile-*- ; force emacs to enter makefile-mode -SSH_VSN = 2.1.1 +SSH_VSN = 2.1.2 APP_VSN = "ssh-$(SSH_VSN)" From f2d6fd60c3dccf8bc0efc42eff844fb122ff9827 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Thu, 8 Nov 2012 16:09:25 +0100 Subject: [PATCH 6/7] Updated appup for ssh --- lib/ssh/src/ssh.appup.src | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ssh/src/ssh.appup.src b/lib/ssh/src/ssh.appup.src index d08dbafc3286..ae0bbec1ced7 100644 --- a/lib/ssh/src/ssh.appup.src +++ b/lib/ssh/src/ssh.appup.src @@ -19,6 +19,10 @@ {"%VSN%", [ + {<<"2.1.1">>, [{load_module, ssh_connection_handler, soft_purge, soft_purge, []}, + {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, + {load_module, ssh_auth, soft_purge, soft_purge, []}, + {load_module, ssh, soft_purge, soft_purge, []}]}, {<<"2.1">>, [{load_module, ssh_sftpd_file_api, soft_purge, soft_purge, []}, {load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, @@ -30,6 +34,10 @@ {<<"1\\.*">>, [{restart_application, ssh}]} ], [ + {<<"2.1.1">>, [{load_module, ssh_connection_handler, soft_purge, soft_purge, []}, + {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, + {load_module, ssh_auth, soft_purge, soft_purge, []}, + {load_module, ssh, soft_purge, soft_purge, []}]}, {<<"2.1">>,[{load_module, ssh_sftpd_file_api, soft_purge, soft_purge, []}, {load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, @@ -40,4 +48,4 @@ {<<"2.0\\.*">>, [{restart_application, ssh}]}, {<<"1\\.*">>, [{restart_application, ssh}]} ] -}. +}. \ No newline at end of file From f35c7ad2ec46cdcaeef935f4da459865e03cb5f9 Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Fri, 9 Nov 2012 15:58:34 +0100 Subject: [PATCH 7/7] Ssh appup modifications --- lib/ssh/src/ssh.appup.src | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ssh/src/ssh.appup.src b/lib/ssh/src/ssh.appup.src index ae0bbec1ced7..8914aeffdbfa 100644 --- a/lib/ssh/src/ssh.appup.src +++ b/lib/ssh/src/ssh.appup.src @@ -27,6 +27,7 @@ {load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_auth, soft_purge, soft_purge, []}, + {load_module, ssh_connection_handler, soft_purge, soft_purge, []}, {load_module, ssh_channel, soft_purge, soft_purge, []}, {load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]}, @@ -42,6 +43,7 @@ {load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_auth, soft_purge, soft_purge, []}, + {load_module, ssh_connection_handler, soft_purge, soft_purge, []}, {load_module, ssh_channel, soft_purge, soft_purge, []}, {load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]},