diff options
author | Ingela Anderton Andin <[email protected]> | 2018-11-06 09:36:43 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2018-11-06 09:36:43 +0100 |
commit | c2a3104849583a9e1aa5370873457975bef67296 (patch) | |
tree | 63286fa8e78bd884b37076a9c9d356c09554ab70 /lib/ssl | |
parent | 35ec009f24bf255984bf0283629d088e29d2d955 (diff) | |
parent | e7e3f59e5350bb39f57f0403f3c78443c58039b1 (diff) | |
download | otp-c2a3104849583a9e1aa5370873457975bef67296.tar.gz otp-c2a3104849583a9e1aa5370873457975bef67296.tar.bz2 otp-c2a3104849583a9e1aa5370873457975bef67296.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/ssl')
-rw-r--r-- | lib/ssl/src/ssl_connection.erl | 2 | ||||
-rw-r--r-- | lib/ssl/test/ssl_basic_SUITE.erl | 27 | ||||
-rw-r--r-- | lib/ssl/test/ssl_test_lib.erl | 25 |
3 files changed, 52 insertions, 2 deletions
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index 1a848df2a3..2abc678ed9 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -627,6 +627,8 @@ init({call, From}, {start, {Opts, EmOpts}, Timeout}, catch throw:Error -> stop_and_reply(normal, {reply, From, {error, Error}}, State0) end; +init({call, From}, {new_user, _} = Msg, State, Connection) -> + handle_call(Msg, From, ?FUNCTION_NAME, State, Connection); init({call, From}, _Msg, _State, _Connection) -> {keep_state_and_data, [{reply, From, {error, notsup_on_transport_accept_socket}}]}; init(_Type, _Event, _State, _Connection) -> diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl index abc5ad1e87..1cfff436d2 100644 --- a/lib/ssl/test/ssl_basic_SUITE.erl +++ b/lib/ssl/test/ssl_basic_SUITE.erl @@ -245,7 +245,8 @@ error_handling_tests()-> recv_error_handling, call_in_error_state, close_in_error_state, - abuse_transport_accept_socket + abuse_transport_accept_socket, + controlling_process_transport_accept_socket ]. error_handling_tests_tls()-> @@ -4057,7 +4058,7 @@ close_in_error_state(Config) when is_list(Config) -> end. %%-------------------------------------------------------------------- abuse_transport_accept_socket() -> - [{doc,"Only ssl:handshake is allowed for transport_accept:sockets"}]. + [{doc,"Only ssl:handshake and ssl:controlling_process is allowed for transport_accept:sockets"}]. abuse_transport_accept_socket(Config) when is_list(Config) -> ServerOpts = ssl_test_lib:ssl_options(server_opts, Config), ClientOpts = ssl_test_lib:ssl_options(client_opts, Config), @@ -4077,6 +4078,28 @@ abuse_transport_accept_socket(Config) when is_list(Config) -> ssl_test_lib:close(Server), ssl_test_lib:close(Client). + +%%-------------------------------------------------------------------- +controlling_process_transport_accept_socket() -> + [{doc,"Only ssl:handshake and ssl:controlling_process is allowed for transport_accept:sockets"}]. +controlling_process_transport_accept_socket(Config) when is_list(Config) -> + ServerOpts = ssl_test_lib:ssl_options(server_opts, Config), + ClientOpts = ssl_test_lib:ssl_options(client_opts, Config), + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server_transport_control([{node, ServerNode}, + {port, 0}, + {from, self()}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + + _Client = ssl_test_lib:start_client_error([{node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {options, ClientOpts}]), + ssl_test_lib:check_result(Server, ok), + ssl_test_lib:close(Server). + %%-------------------------------------------------------------------- run_error_server_close([Pid | Opts]) -> {ok, Listen} = ssl:listen(0, Opts), diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl index 289793bac8..8a2f0824fb 100644 --- a/lib/ssl/test/ssl_test_lib.erl +++ b/lib/ssl/test/ssl_test_lib.erl @@ -204,6 +204,14 @@ start_server_transport_abuse_socket(Args) -> Result end. +start_server_transport_control(Args) -> + Result = spawn_link(?MODULE, transport_switch_control, [Args]), + receive + {listen, up} -> + Result + end. + + transport_accept_abuse(Opts) -> Node = proplists:get_value(node, Opts), Port = proplists:get_value(port, Opts), @@ -220,6 +228,23 @@ transport_accept_abuse(Opts) -> _ = rpc:call(Node, ssl, handshake, [AcceptSocket, infinity]), Pid ! {self(), ok}. + +transport_switch_control(Opts) -> + Node = proplists:get_value(node, Opts), + Port = proplists:get_value(port, Opts), + Options = proplists:get_value(options, Opts), + Pid = proplists:get_value(from, Opts), + Transport = proplists:get_value(transport, Opts, ssl), + ct:log("~p:~p~nssl:listen(~p, ~p)~n", [?MODULE,?LINE, Port, Options]), + {ok, ListenSocket} = rpc:call(Node, Transport, listen, [Port, Options]), + Pid ! {listen, up}, + send_selected_port(Pid, Port, ListenSocket), + {ok, AcceptSocket} = rpc:call(Node, ssl, transport_accept, + [ListenSocket]), + ok = rpc:call(Node, ssl, controlling_process, [AcceptSocket, self()]), + Pid ! {self(), ok}. + + remove_close_msg(0) -> ok; remove_close_msg(ReconnectTimes) -> |