aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_connection_handler.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2014-10-15 20:33:25 +0200
committerHans Nilsson <[email protected]>2014-10-16 15:21:09 +0200
commita4cd7efbbbf174ae283cfac60a8e5492e340e3a6 (patch)
treeebc48d4df688aadf16d7f4b1ae2f042e38d91fba /lib/ssh/src/ssh_connection_handler.erl
parent5d49d05c3604f764736b10cfb287818d4b41efda (diff)
downloadotp-a4cd7efbbbf174ae283cfac60a8e5492e340e3a6.tar.gz
otp-a4cd7efbbbf174ae283cfac60a8e5492e340e3a6.tar.bz2
otp-a4cd7efbbbf174ae283cfac60a8e5492e340e3a6.zip
ssh: Fix port scanner problems
Diffstat (limited to 'lib/ssh/src/ssh_connection_handler.erl')
-rw-r--r--lib/ssh/src/ssh_connection_handler.erl17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 4fbc5d0ae2..e9d35c4c4c 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -45,7 +45,8 @@
%% gen_fsm callbacks
-export([hello/2, kexinit/2, key_exchange/2, new_keys/2,
- userauth/2, connected/2]).
+ userauth/2, connected/2,
+ error/2]).
-export([init/1, handle_event/3,
handle_sync_event/4, handle_info/3, terminate/3, format_status/2, code_change/4]).
@@ -174,6 +175,13 @@ init([Role, Socket, SshOpts]) ->
gen_fsm:enter_loop(?MODULE, [], error, {Error, State0})
end.
+%% Temporary fix for the Nessus error. SYN-> <-SYNACK ACK-> RST-> ?
+error(_Event, {Error, %%={badmatch,{error,enotconn}},
+ State=#state{socket=Socket,
+ transport_cb=Transport}}) ->
+ (catch Transport:close(Socket)),
+ {stop, {shutdown,init,Error}, State}.
+
%%--------------------------------------------------------------------
-spec open_channel(pid(), string(), iodata(), integer(), integer(),
timeout()) -> {open, channel_id()} | {error, term()}.
@@ -951,8 +959,14 @@ terminate({shutdown, #ssh_msg_disconnect{} = Msg}, StateName,
{SshPacket, Ssh} = ssh_transport:ssh_packet(Msg, Ssh0),
send_msg(SshPacket, State),
terminate(normal, StateName, State#state{ssh_params = Ssh});
+
terminate({shutdown, _}, StateName, State) ->
terminate(normal, StateName, State);
+
+terminate({shutdown,init,Reason}, StateName, State) ->
+ error_logger:info_report(io_lib:format("Erlang ssh in connection handler init: ~p~n",[Reason])),
+ terminate(normal, StateName, State);
+
terminate(Reason, StateName, #state{ssh_params = Ssh0, starter = _Pid,
connection_state = Connection} = State) ->
terminate_subsytem(Connection),
@@ -965,6 +979,7 @@ terminate(Reason, StateName, #state{ssh_params = Ssh0, starter = _Pid,
send_msg(SshPacket, State),
terminate(normal, StateName, State#state{ssh_params = Ssh}).
+
terminate_subsytem(#connection{system_supervisor = SysSup,
sub_system_supervisor = SubSysSup}) when is_pid(SubSysSup) ->
ssh_system_sup:stop_subsystem(SysSup, SubSysSup);