Skip to content

Commit

Permalink
Merge branch 'fredrik/ssh-password-conf/OTP-10511' into maint
Browse files Browse the repository at this point in the history
* fredrik/ssh-password-conf/OTP-10511:
  Ssh appup modifications
  Updated appup for ssh
  Bumped revision
  Removed some testing variables
  ssh_opts is now a proper list
  After auth rsa and dsa passwords is set to undefined
  Removing the password after auth
  • Loading branch information
rimmius committed Nov 12, 2012
2 parents 668c426 + f35c7ad commit 674c844
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/ssh/src/ssh.appup.src
Expand Up @@ -19,25 +19,35 @@


{"%VSN%", {"%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, []}, {<<"2.1">>, [{load_module, ssh_sftpd_file_api, soft_purge, soft_purge, []},
{load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection, soft_purge, soft_purge, []},
{load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []},
{load_module, ssh_auth, 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_channel, soft_purge, soft_purge, []},
{load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh_file, soft_purge, soft_purge, []}]},
{load_module, ssh, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]},
{<<"2.0\\.*">>, [{restart_application, ssh}]}, {<<"2.0\\.*">>, [{restart_application, ssh}]},
{<<"1\\.*">>, [{restart_application, ssh}]} {<<"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, []}, {<<"2.1">>,[{load_module, ssh_sftpd_file_api, soft_purge, soft_purge, []},
{load_module, ssh_connection, soft_purge, soft_purge, []}, {load_module, ssh_connection, soft_purge, soft_purge, []},
{load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_connection_manager, soft_purge, soft_purge, []},
{load_module, ssh_auth, 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_channel, soft_purge, soft_purge, []},
{load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh_file, soft_purge, soft_purge, []}]},
{load_module, ssh, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]},
{<<"2.0\\.*">>, [{restart_application, ssh}]}, {<<"2.0\\.*">>, [{restart_application, ssh}]},
{<<"1\\.*">>, [{restart_application, ssh}]} {<<"1\\.*">>, [{restart_application, ssh}]}
] ]
}. }.
43 changes: 42 additions & 1 deletion lib/ssh/src/ssh_connection_manager.erl
Expand Up @@ -523,7 +523,7 @@ handle_info({same_user, _}, State) ->
handle_info(ssh_connected, #state{role = client, client = Pid} handle_info(ssh_connected, #state{role = client, client = Pid}
= State) -> = State) ->
Pid ! {self(), is_connected}, 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) -> handle_info(ssh_connected, #state{role = server} = State) ->
{noreply, State#state{connected = true}}; {noreply, State#state{connected = true}};
Expand All @@ -536,6 +536,47 @@ handle_info({'DOWN', _Ref, process, ChannelPid, _Reason}, State) ->
handle_info({'EXIT', _Sup, Reason}, State) -> handle_info({'EXIT', _Sup, Reason}, State) ->
{stop, 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 ->
case proplists:get_value(password, SshOpts, false) of
false ->
Opts;
_Password ->
NewOpts = [{password, undefined}|lists:keydelete(password, 1, SshOpts)],
[{ssh_opts, 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_phrase, undefined}|lists:keydelete(dsa_pass_phrase, 1, SshOpts)],
[{ssh_opts, 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_phrase, undefined}|lists:keydelete(rsa_pass_phrase, 1, SshOpts)],
[{ssh_opts, NewOpts}|lists:keydelete(ssh_opts, 1, Opts)]
end
end.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Function: terminate(Reason, State) -> void() %% Function: terminate(Reason, State) -> void()
%% Description: This function is called by a gen_server when it is about to %% Description: This function is called by a gen_server when it is about to
Expand Down
2 changes: 1 addition & 1 deletion lib/ssh/vsn.mk
@@ -1,5 +1,5 @@
#-*-makefile-*- ; force emacs to enter makefile-mode #-*-makefile-*- ; force emacs to enter makefile-mode


SSH_VSN = 2.1.1 SSH_VSN = 2.1.2
APP_VSN = "ssh-$(SSH_VSN)" APP_VSN = "ssh-$(SSH_VSN)"


0 comments on commit 674c844

Please sign in to comment.