aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl2
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl266
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl17
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl166
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key13
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub11
-rw-r--r--lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl15
-rw-r--r--lib/common_test/test/telnet_server.erl16
-rw-r--r--lib/compiler/src/beam_validator.erl106
-rw-r--r--lib/compiler/test/beam_validator_SUITE.erl120
-rw-r--r--lib/erl_docgen/priv/css/otp_doc.css5
-rw-r--r--lib/erl_docgen/priv/dtd/common.dtd7
-rw-r--r--lib/erl_docgen/priv/xsl/db_html.xsl107
-rw-r--r--lib/erl_docgen/priv/xsl/db_man.xsl12
-rw-r--r--lib/erl_docgen/priv/xsl/db_pdf.xsl26
-rw-r--r--lib/runtime_tools/test/dyntrace_lttng_SUITE.erl12
-rw-r--r--lib/ssh/doc/src/ssh.xml8
-rw-r--r--lib/ssh/doc/src/ssh_sftp.xml14
-rw-r--r--lib/ssh/src/ssh.erl85
-rw-r--r--lib/ssh/src/ssh_acceptor_sup.erl2
-rw-r--r--lib/ssh/src/ssh_channel_sup.erl2
-rw-r--r--lib/ssh/src/ssh_cli.erl15
-rw-r--r--lib/ssh/src/ssh_client_key_api.erl24
-rw-r--r--lib/ssh/src/ssh_connection_sup.erl2
-rw-r--r--lib/ssh/src/ssh_file.erl23
-rw-r--r--lib/ssh/src/ssh_server_key_api.erl15
-rw-r--r--lib/ssh/src/ssh_sftp.erl23
-rw-r--r--lib/ssh/src/ssh_sftpd.erl16
-rw-r--r--lib/ssh/src/ssh_shell.erl15
-rw-r--r--lib/ssh/src/ssh_subsystem_sup.erl2
-rw-r--r--lib/ssh/src/ssh_sup.erl2
-rw-r--r--lib/ssh/src/ssh_system_sup.erl2
-rw-r--r--lib/ssh/src/sshc_sup.erl2
-rw-r--r--lib/ssh/src/sshd_sup.erl2
-rw-r--r--lib/ssh/test/ssh_algorithms_SUITE.erl23
-rw-r--r--lib/ssh/test/ssh_basic_SUITE.erl178
-rw-r--r--lib/ssh/test/ssh_benchmark_SUITE.erl26
-rw-r--r--lib/ssh/test/ssh_connection_SUITE.erl108
-rw-r--r--lib/ssh/test/ssh_options_SUITE.erl78
-rw-r--r--lib/ssh/test/ssh_property_test_SUITE.erl2
-rw-r--r--lib/ssh/test/ssh_protocol_SUITE.erl14
-rw-r--r--lib/ssh/test/ssh_renegotiate_SUITE.erl12
-rw-r--r--lib/ssh/test/ssh_sftp_SUITE.erl303
-rw-r--r--lib/ssh/test/ssh_sftpd_SUITE.erl88
-rw-r--r--lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl42
-rw-r--r--lib/ssh/test/ssh_sup_SUITE.erl30
-rw-r--r--lib/ssh/test/ssh_test_lib.erl8
-rw-r--r--lib/ssh/test/ssh_to_openssh_SUITE.erl14
-rw-r--r--lib/ssh/test/ssh_upgrade_SUITE.erl6
-rw-r--r--lib/ssl/doc/src/ssl_distribution.xml11
-rw-r--r--lib/ssl/src/ssl.app.src2
-rw-r--r--lib/ssl/src/ssl.erl40
-rw-r--r--lib/ssl/src/ssl_connection.erl20
-rw-r--r--lib/ssl/src/ssl_handshake.hrl3
-rw-r--r--lib/ssl/src/ssl_tls_dist_proxy.erl30
-rw-r--r--lib/ssl/src/tls_connection.erl95
-rw-r--r--lib/ssl/test/ssl_ECC_SUITE.erl10
-rw-r--r--lib/ssl/test/ssl_basic_SUITE.erl5
-rw-r--r--lib/ssl/test/ssl_dist_SUITE.erl273
-rw-r--r--lib/stdlib/test/gen_server_SUITE.erl4
60 files changed, 1623 insertions, 957 deletions
diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
index c64774cd4f..0b3f834732 100644
--- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl
@@ -74,7 +74,7 @@ test_get_known_variable(_)->
test_localtime_update(_)->
Seconds = 5,
LT1 = ct:get_config(localtime),
- ct:sleep(Seconds*1000),
+ timer:sleep(Seconds*1000), % don't want scaling of this timer
LT2 = ct:reload_config(localtime),
case is_diff_ok(LT1, LT2, Seconds) of
{false, Actual, Exp}->
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index 065639dd36..f34969683c 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
@@ -123,41 +123,37 @@ init_per_testcase(_Case, Config) ->
end_per_testcase(_Case, _Config) ->
ok.
-init_per_suite() ->
- [{timetrap,2*?default_timeout}]. % making dsa files can be slow
init_per_suite(Config) ->
case catch ssh:start() of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("ssh started",[]),
- {ok, _} = netconfc_test_lib:get_id_keys(Config),
- netconfc_test_lib:make_dsa_files(Config),
- ct:log("dsa files created",[]),
- Server = ?NS:start(?config(data_dir,Config)),
+ SshDir = filename:join(filename:dirname(code:which(?MODULE)),
+ "ssh_dir"),
+ Server = ?NS:start(SshDir),
ct:log("netconf server started",[]),
- [{server,Server}|Config];
+ [{netconf_server,Server},{ssh_dir,SshDir}|Config];
Other ->
ct:log("could not start ssh: ~p",[Other]),
{skip, "SSH could not be started!"}
end.
end_per_suite(Config) ->
- ?NS:stop(?config(server,Config)),
+ ?NS:stop(?config(netconf_server,Config)),
ssh:stop(),
crypto:stop(),
- netconfc_test_lib:remove_id_keys(Config),
Config.
hello(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
hello_from_server_first(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1),
- {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(DataDir)),
+ {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(SshDir)),
ct:sleep(500),
?NS:expect(hello),
?ok = ct_netconfc:hello(Client, [{capability, ["urn:com:ericsson:ebase:1.1.0"]}], infinity),
@@ -166,8 +162,8 @@ hello_from_server_first(Config) ->
ok.
hello_named(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(any_name,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(any_name,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
@@ -175,8 +171,8 @@ hello_named(Config) ->
hello_configured() ->
[{require, netconf1}].
hello_configured(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_configured_success(netconf1,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_configured_success(netconf1,SshDir),
?NS:expect_do_reply('close-session',close,ok),
{error, {no_such_name,netconf1}} = ct_netconfc:close_session(netconf1),
?ok = ct_netconfc:close_session(Client),
@@ -185,10 +181,10 @@ hello_configured(Config) ->
hello_configured_extraopts() ->
[{require, netconf1}].
hello_configured_extraopts(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
%% Test that the cofiguration overwrites the ExtraOpts parameter
%% to ct_netconfc:open/2.
- {ok,Client} = open_configured_success(netconf1,DataDir,[{password,"faulty"}]),
+ {ok,Client} = open_configured_success(netconf1,SshDir,[{password,"faulty"}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
@@ -196,8 +192,8 @@ hello_configured_extraopts(Config) ->
hello_required() ->
[{require, my_named_connection, netconf1}].
hello_required(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,_Client} = open_configured_success(my_named_connection,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,_Client} = open_configured_success(my_named_connection,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ok.
@@ -205,69 +201,69 @@ hello_required(Config) ->
hello_required_exists() ->
[{require, my_named_connection, netconf1}].
hello_required_exists(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,_Client1} = open_configured_success(my_named_connection,DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,_Client1} = open_configured_success(my_named_connection,SshDir),
%% Check that same name can not be used twice
{error,{connection_exists,_Client1}} =
- ct_netconfc:open(my_named_connection,[{user_dir,DataDir}]),
+ ct_netconfc:open(my_named_connection,[{user_dir,SshDir}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ct:sleep(500),
%% Then check that it can be used again after the first is closed
- {ok,_Client2} = open_configured_success(my_named_connection,DataDir),
+ {ok,_Client2} = open_configured_success(my_named_connection,SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(my_named_connection),
ok.
hello_global_pwd(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir,[{user,"any-user"},
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir,[{user,"any-user"},
{password,"global-xxx"}]),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
ok.
hello_no_session_id(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(no_session_id),
?NS:expect(no_session_id,hello),
- {error,{incorrect_hello,no_session_id_found}} = open(DataDir),
+ {error,{incorrect_hello,no_session_id_found}} = open(SshDir),
ok.
hello_incomp_base_vsn(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,{base,"1.1"}),
?NS:expect(hello),
- {error,{incompatible_base_capability_vsn,"1.1"}} = open(DataDir),
+ {error,{incompatible_base_capability_vsn,"1.1"}} = open(SshDir),
ok.
hello_no_base_cap(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,no_base),
?NS:expect(hello),
- {error,{incorrect_hello,no_base_capability_found}} = open(DataDir),
+ {error,{incorrect_hello,no_base_capability_found}} = open(SshDir),
ok.
hello_no_caps(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1,no_caps),
?NS:expect(hello),
- {error,{incorrect_hello,capabilities_not_found}} = open(DataDir),
+ {error,{incorrect_hello,capabilities_not_found}} = open(SshDir),
ok.
no_server_hello(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:expect(undefined,hello),
- {error,{hello_session_failed,timeout}} = open(DataDir,[{timeout,2000}]),
+ {error,{hello_session_failed,timeout}} = open(SshDir,[{timeout,2000}]),
ok.
no_client_hello(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
?NS:hello(1),
- {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(DataDir)),
+ {ok,Client} = ct_netconfc:only_open(?DEFAULT_SSH_OPTS(SshDir)),
%% Allow server hello to arrive
ct:sleep(500),
@@ -280,8 +276,8 @@ no_client_hello(Config) ->
ok.
get_session_id(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
1 = ct_netconfc:get_session_id(Client),
@@ -290,8 +286,8 @@ get_session_id(Config) ->
ok.
get_capabilities(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Caps = ct_netconfc:get_capabilities(Client),
BaseCap = ?NETCONF_BASE_CAP ++ ?NETCONF_BASE_CAP_VSN,
@@ -302,49 +298,49 @@ get_capabilities(Config) ->
ok.
faulty_user(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,
"Unable to connect using the available authentication methods"}} =
- open(DataDir,[{user,"yyy"}]),
+ open(SshDir,[{user,"yyy"}]),
ok.
faulty_passwd(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,
"Unable to connect using the available authentication methods"}} =
- open(DataDir,[{password,"yyy"}]),
+ open(SshDir,[{password,"yyy"}]),
ok.
faulty_port(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
{error,{ssh,could_not_connect_to_server,econnrefused}} =
- open(DataDir,[{port,2062}]),
+ open(SshDir,[{port,2062}]),
ok.
no_host(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts = lists:keydelete(ssh,1,?DEFAULT_SSH_OPTS(DataDir)),
+ SshDir = ?config(ssh_dir,Config),
+ Opts = lists:keydelete(ssh,1,?DEFAULT_SSH_OPTS(SshDir)),
{error,no_host_address} = ct_netconfc:open(Opts),
ok.
no_port(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts = lists:keydelete(port,1,?DEFAULT_SSH_OPTS(DataDir)),
+ SshDir = ?config(ssh_dir,Config),
+ Opts = lists:keydelete(port,1,?DEFAULT_SSH_OPTS(SshDir)),
{error,no_port} = ct_netconfc:open(Opts),
ok.
invalid_opt(Config) ->
- DataDir = ?config(data_dir,Config),
- Opts1 = ?DEFAULT_SSH_OPTS(DataDir) ++ [{timeout,invalidvalue}],
+ SshDir = ?config(ssh_dir,Config),
+ Opts1 = ?DEFAULT_SSH_OPTS(SshDir) ++ [{timeout,invalidvalue}],
{error,{invalid_option,{timeout,invalidvalue}}} = ct_netconfc:open(Opts1),
- Opts2 = ?DEFAULT_SSH_OPTS(DataDir) ++ [{some_other_opt,true}],
+ Opts2 = ?DEFAULT_SSH_OPTS(SshDir) ++ [{some_other_opt,true}],
{error,{ssh,could_not_connect_to_server,{options,_}}} =
ct_netconfc:open(Opts2),
ok.
timeout_close_session(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect('close-session'),
true = erlang:is_process_alive(Client),
{error,timeout} = ct_netconfc:close_session(Client,1000),
@@ -352,8 +348,8 @@ timeout_close_session(Config) ->
ok.
get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get',{data,Data}),
{ok,Data} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]}),
@@ -362,8 +358,8 @@ get(Config) ->
ok.
get_a_lot(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Descr = lists:append(lists:duplicate(1000,"Description of myserver! ")),
Server = {server,[{xmlns,"myns"}],[{name,[],["myserver"]},
{description,[],[Descr]}]},
@@ -375,8 +371,8 @@ get_a_lot(Config) ->
ok.
timeout_get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect('get'),
{error,timeout} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]},1000),
?NS:expect_do_reply('close-session',close,ok),
@@ -392,8 +388,8 @@ timeout_get(Config) ->
%% Note that we can only hope that the test case triggers the problem
%% every now and then, as it is very timing dependent...
flush_timeout_get(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get',{data,Data}),
timer:sleep(1000),
@@ -406,8 +402,8 @@ flush_timeout_get(Config) ->
ok.
get_xpath(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply({'get',xpath},{data,Data}),
{ok,Data} = ct_netconfc:get(Client,{xpath,"/server"}),
@@ -416,8 +412,8 @@ get_xpath(Config) ->
ok.
get_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply('get-config',{data,Data}),
{ok,Data} = ct_netconfc:get_config(Client,running,
@@ -427,8 +423,8 @@ get_config(Config) ->
ok.
get_config_xpath(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
?NS:expect_reply({'get-config',xpath},{data,Data}),
{ok,Data} = ct_netconfc:get_config(Client,running,{xpath,"/server"}),
@@ -437,8 +433,8 @@ get_config_xpath(Config) ->
ok.
edit_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('edit-config',ok),
?ok = ct_netconfc:edit_config(Client,running,
{server,[{xmlns,"myns"}],
@@ -448,8 +444,8 @@ edit_config(Config) ->
ok.
edit_config_opt_params(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'edit-config',{'default-operation',"none"}},ok),
?ok = ct_netconfc:edit_config(Client,running,
{server,[{xmlns,"myns"}],
@@ -460,8 +456,8 @@ edit_config_opt_params(Config) ->
ok.
copy_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('copy-config',ok),
?ok = ct_netconfc:copy_config(Client,startup,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -469,8 +465,8 @@ copy_config(Config) ->
ok.
delete_config(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('delete-config',ok),
?ok = ct_netconfc:delete_config(Client,startup),
?NS:expect_do_reply('close-session',close,ok),
@@ -478,8 +474,8 @@ delete_config(Config) ->
ok.
lock(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('lock',ok),
?ok = ct_netconfc:lock(Client,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -487,8 +483,8 @@ lock(Config) ->
ok.
unlock(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply('unlock',ok),
?ok = ct_netconfc:unlock(Client,running),
?NS:expect_do_reply('close-session',close,ok),
@@ -496,12 +492,12 @@ unlock(Config) ->
ok.
kill_session(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:hello(2),
?NS:expect(2,hello),
- {ok,_OtherClient} = open(DataDir),
+ {ok,_OtherClient} = open(SshDir),
?NS:expect_do_reply('kill-session',{kill,2},ok),
?ok = ct_netconfc:kill_session(Client,2),
@@ -512,8 +508,8 @@ kill_session(Config) ->
ok.
get_no_such_client(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client),
@@ -529,8 +525,8 @@ get_no_such_client(Config) ->
ok.
action(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{myactionreturn,[{xmlns,"myns"}],["value"]}],
%% test either to receive {data,Data} or {ok,Data},
%% both need to be handled
@@ -549,8 +545,8 @@ action(Config) ->
ok.
send_any_rpc(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
GetConf = {'get-config',
[{source,["running"]},
@@ -571,8 +567,8 @@ send_any_rpc(Config) ->
ok.
send_any(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Correct get-config rpc
Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}],
@@ -604,8 +600,8 @@ send_any(Config) ->
ok.
hide_password(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
Password = "my_very_secret_password",
Data = [{passwords,[{xmlns,"myns"}],
[{password,[{xmlns,"pwdns"}],[Password]},
@@ -633,8 +629,8 @@ hide_password(Config) ->
ok.
not_proper_xml(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
NS = list_to_binary(?NETCONF_NAMESPACE),
NotProper = <<"<rpc-reply message-id=\"1\" xmlns=\"",
NS/binary,"\"><data></rpc-reply>">>,
@@ -646,8 +642,8 @@ not_proper_xml(Config) ->
ok.
prefixed_namespace(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
NS = list_to_binary(?NETCONF_NAMESPACE),
%% Test that data element can be properly decoded and that
@@ -679,8 +675,8 @@ prefixed_namespace(Config) ->
%% i.e. when the complete rpc-reply is not contained in one single ssh
%% data message.
receive_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -727,8 +723,8 @@ receive_chunked_data(Config) ->
%% Same as receive_chunked_data, but timeout waiting for last part.
timeout_receive_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -773,8 +769,8 @@ timeout_receive_chunked_data(Config) ->
%% Same as receive_chunked_data, but close while waiting for last part.
close_while_waiting_for_chunked_data(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Construct the data to return from netconf server
Data = [{servers,[{xmlns,"myns"}],
@@ -816,8 +812,8 @@ close_while_waiting_for_chunked_data(Config) ->
ok.
connection_crash(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
%% Test that if the test survives killing the connection
%% process. Earlier this caused ct_util_server to terminate, and
@@ -828,8 +824,8 @@ connection_crash(Config) ->
ok.
get_event_streams(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
StreamNames = ["NETCONF","stream1","stream2"],
Streams = [{N,[{description,"descr of " ++ N}]} || N <- StreamNames],
StreamsXml = [{stream,[{name,[N]}|[{Tag,[Value]} || {Tag,Value} <- Data]]}
@@ -849,31 +845,31 @@ get_event_streams(Config) ->
ok.
create_subscription(Config) ->
- DataDir = ?config(data_dir,Config),
+ SshDir = ?config(ssh_dir,Config),
%% All defaults
- {ok,Client1} = open_success(DataDir),
+ {ok,Client1} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client1),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1),
%% All defaults with timeout
- {ok,Client1a} = open_success(DataDir),
+ {ok,Client1a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client1a,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1a),
%% All defaults timing out
- {ok,Client1b} = open_success(DataDir),
+ {ok,Client1b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream]}),
{error,timeout} = ct_netconfc:create_subscription(Client1b,100),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client1b),
%% Stream
- {ok,Client2} = open_success(DataDir),
+ {ok,Client2} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
Stream = "some_stream",
?ok = ct_netconfc:create_subscription(Client2,Stream),
@@ -881,7 +877,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client2),
%% Filter
- {ok,Client3} = open_success(DataDir),
+ {ok,Client3} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
Filter = {notification,?NETMOD_NOTIF_NAMESPACE_ATTR,
[eventTime]},
@@ -890,28 +886,28 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client3),
%% Filter with timeout
- {ok,Client3a} = open_success(DataDir),
+ {ok,Client3a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
?ok = ct_netconfc:create_subscription(Client3a,Filter,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client3a),
%% Filter timing out
- {ok,Client3b} = open_success(DataDir),
+ {ok,Client3b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream,filter]}),
{error,timeout}=ct_netconfc:create_subscription(Client3b,Filter,100),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client3b),
%% Stream and filter
- {ok,Client4} = open_success(DataDir),
+ {ok,Client4} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
?ok = ct_netconfc:create_subscription(Client4,Stream,Filter),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client4),
%% Start/stop time
- {ok,Client5} = open_success(DataDir),
+ {ok,Client5} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
StartTime = xs_datetime({D,{H,M,S}}= calendar:local_time()),
StopTime = xs_datetime({D,{H+2,M,S}}),
@@ -920,14 +916,14 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client5),
%% Start/stop time with timeout
- {ok,Client5a} = open_success(DataDir),
+ {ok,Client5a} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
?ok = ct_netconfc:create_subscription(Client5a,StartTime,StopTime,5000),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client5a),
%% Start/stop time timing out
- {ok,Client5b} = open_success(DataDir),
+ {ok,Client5b} = open_success(SshDir),
?NS:expect({'create-subscription',[stream,startTime,stopTime]}),
{error,timeout} =
ct_netconfc:create_subscription(Client5b,StartTime,StopTime,100),
@@ -935,14 +931,14 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client5b),
%% Stream and start/stop time
- {ok,Client6} = open_success(DataDir),
+ {ok,Client6} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,startTime,stopTime]},ok),
?ok = ct_netconfc:create_subscription(Client6,Stream,StartTime,StopTime),
?NS:expect_do_reply('close-session',close,ok),
?ok = ct_netconfc:close_session(Client6),
%% Filter and start/stop time
- {ok,Client7} = open_success(DataDir),
+ {ok,Client7} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter,startTime,stopTime]},
ok),
?ok = ct_netconfc:create_subscription(Client7,Filter,
@@ -951,7 +947,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client7),
%% Stream, filter and start/stop time
- {ok,Client8} = open_success(DataDir),
+ {ok,Client8} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter,startTime,stopTime]},
ok),
?ok = ct_netconfc:create_subscription(Client8,Stream,Filter,
@@ -960,7 +956,7 @@ create_subscription(Config) ->
?ok = ct_netconfc:close_session(Client8),
%% Multiple filters
- {ok,Client9} = open_success(DataDir),
+ {ok,Client9} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream,filter]},ok),
MultiFilters = [{event,[{xmlns,"http://my.namespaces.com/event"}],
[{eventClass,["fault"]},
@@ -975,8 +971,8 @@ create_subscription(Config) ->
ok.
receive_one_event(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1002,8 +998,8 @@ receive_one_event(Config) ->
ok.
receive_multiple_events(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1043,8 +1039,8 @@ receive_multiple_events(Config) ->
ok.
receive_event_and_rpc(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
@@ -1103,8 +1099,8 @@ receive_event_and_rpc(Config) ->
receive_event_and_rpc_in_chunks(Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(DataDir),
+ SshDir = ?config(ssh_dir,Config),
+ {ok,Client} = open_success(SshDir),
?NS:expect_reply({'create-subscription',[stream]},ok),
?ok = ct_netconfc:create_subscription(Client),
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
index 04bfe75187..0a49cdabbb 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_remote_SUITE.erl
@@ -51,7 +51,7 @@ init_per_testcase(Case, Config) ->
stop_node(Case),
Config.
-end_per_testcase(Case, Config) ->
+end_per_testcase(Case, _Config) ->
stop_node(Case),
ok.
@@ -61,16 +61,13 @@ stop_node(Case) ->
rpc:call(Node,erlang,halt,[]).
-init_per_suite() ->
- [{timetrap,2*?default_timeout}]. % making dsa files can be slow
init_per_suite(Config) ->
case ssh:start() of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started locally",[]),
- {ok, _} = netconfc_test_lib:get_id_keys(Config),
- netconfc_test_lib:make_dsa_files(Config),
- ct:log("dsa files created",[]),
- Config;
+ SshDir = filename:join(filename:dirname(code:which(?MODULE)),
+ "ssh_dir"),
+ [{ssh_dir,SshDir}|Config];
Other ->
ct:log("could not start ssh locally: ~p",[Other]),
{skip, "SSH could not be started locally!"}
@@ -79,7 +76,6 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
ssh:stop(),
crypto:stop(),
- netconfc_test_lib:remove_id_keys(Config),
Config.
%% This test case is related to seq12645
@@ -93,7 +89,7 @@ remote_crash(Config) ->
case rpc:call(Node,ssh,start,[]) of
Ok when Ok==ok; Ok=={error,{already_started,ssh}} ->
ct:log("SSH started remote",[]),
- Server = rpc:call(Node,?NS,start,[?config(data_dir,Config)]),
+ ns(Node,start,[?config(ssh_dir,Config)]),
ct:log("netconf server started remote",[]),
remote_crash(Node,Config);
Other ->
@@ -102,8 +98,7 @@ remote_crash(Config) ->
end.
remote_crash(Node,Config) ->
- DataDir = ?config(data_dir,Config),
- {ok,Client} = open_success(Node,DataDir),
+ {ok,Client} = open_success(Node,?config(ssh_dir,Config)),
ns(Node,expect_reply,[{'create-subscription',[stream]},ok]),
?ok = ct_netconfc:create_subscription(Client),
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl
deleted file mode 100644
index e058bc7600..0000000000
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc_test_lib.erl
+++ /dev/null
@@ -1,166 +0,0 @@
--module(netconfc_test_lib).
-
--export([get_id_keys/1, remove_id_keys/1, make_dsa_files/1]).
--include_lib("common_test/include/ct.hrl").
--include_lib("public_key/include/public_key.hrl").
-
-%%%-----------------------------------------------------------------
-%%% BEGIN SSH key management
-%% copy private keys to given dir from ~/.ssh
-get_id_keys(Config) ->
- DstDir = ?config(priv_dir, Config),
- SrcDir = filename:join(os:getenv("HOME"), ".ssh"),
- RsaOk = copyfile(SrcDir, DstDir, "id_rsa"),
- DsaOk = copyfile(SrcDir, DstDir, "id_dsa"),
- case {RsaOk, DsaOk} of
- {{ok, _}, {ok, _}} -> {ok, both};
- {{ok, _}, _} -> {ok, rsa};
- {_, {ok, _}} -> {ok, dsa};
- {Error, _} -> Error
- end.
-
-%% Remove later on. Use make_dsa_files instead.
-remove_id_keys(Config) ->
- Dir = ?config(priv_dir, Config),
- file:delete(filename:join(Dir, "id_rsa")),
- file:delete(filename:join(Dir, "id_dsa")).
-
-
-make_dsa_files(Config) ->
- make_dsa_files(Config, rfc4716_public_key).
-make_dsa_files(Config, Type) ->
- {DSA, EncodedKey} = gen_dsa(128, 20),
- PKey = DSA#'DSAPrivateKey'.y,
- P = DSA#'DSAPrivateKey'.p,
- Q = DSA#'DSAPrivateKey'.q,
- G = DSA#'DSAPrivateKey'.g,
- Dss = #'Dss-Parms'{p=P, q=Q, g=G},
- {ok, Hostname} = inet:gethostname(),
- {ok, {A, B, C, D}} = inet:getaddr(Hostname, inet),
- IP = lists:concat([A, ".", B, ".", C, ".", D]),
- Attributes = [], % Could be [{comment,"user@" ++ Hostname}],
- HostNames = [{hostnames,[IP, IP]}],
- PublicKey = [{{PKey, Dss}, Attributes}],
- KnownHosts = [{{PKey, Dss}, HostNames}],
-
- KnownHostsEnc = public_key:ssh_encode(KnownHosts, known_hosts),
- KnownHosts = public_key:ssh_decode(KnownHostsEnc, known_hosts),
-
- PublicKeyEnc = public_key:ssh_encode(PublicKey, Type),
-
- SystemTmpDir = ?config(data_dir, Config),
- filelib:ensure_dir(SystemTmpDir),
- file:make_dir(SystemTmpDir),
-
- DSAFile = filename:join(SystemTmpDir, "ssh_host_dsa_key.pub"),
- file:delete(DSAFile),
-
- DSAPrivateFile = filename:join(SystemTmpDir, "ssh_host_dsa_key"),
- file:delete(DSAPrivateFile),
-
- KHFile = filename:join(SystemTmpDir, "known_hosts"),
- file:delete(KHFile),
-
- PemBin = public_key:pem_encode([EncodedKey]),
-
- file:write_file(DSAFile, PublicKeyEnc),
- file:write_file(KHFile, KnownHostsEnc),
- file:write_file(DSAPrivateFile, PemBin),
- ok.
-
-
-%%--------------------------------------------------------------------
-%% @doc Creates a dsa key (OBS: for testing only)
-%% the sizes are in bytes
-%% @spec (::integer()) -> {::atom(), ::binary(), ::opaque()}
-%% @end
-%%--------------------------------------------------------------------
-gen_dsa(LSize,NSize) when is_integer(LSize), is_integer(NSize) ->
- Key = gen_dsa2(LSize, NSize),
- {Key, encode_key(Key)}.
-
-encode_key(Key = #'DSAPrivateKey'{}) ->
- Der = public_key:der_encode('DSAPrivateKey', Key),
- {'DSAPrivateKey', Der, not_encrypted}.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% DSA key generation (OBS: for testing only)
-%% See http://en.wikipedia.org/wiki/Digital_Signature_Algorithm
-%% and the fips_186-3.pdf
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-gen_dsa2(LSize, NSize) ->
- Q = prime(NSize), %% Choose N-bit prime Q
- X0 = prime(LSize),
- P0 = prime((LSize div 2) +1),
-
- %% Choose L-bit prime modulus P such that p-1 is a multiple of q.
- case dsa_search(X0 div (2*Q*P0), P0, Q, 1000) of
- error ->
- gen_dsa2(LSize, NSize);
- P ->
- G = crypto:mod_pow(2, (P-1) div Q, P), % Choose G a number whose multiplicative order modulo p is q.
- %% such that This may be done by setting g = h^(p-1)/q mod p, commonly h=2 is used.
-
- X = prime(20), %% Choose x by some random method, where 0 < x < q.
- Y = crypto:mod_pow(G, X, P), %% Calculate y = g^x mod p.
-
- #'DSAPrivateKey'{version=0, p = P, q = Q,
- g = crypto:bytes_to_integer(G), y = crypto:bytes_to_integer(Y), x = X}
- end.
-
-%% See fips_186-3.pdf
-dsa_search(T, P0, Q, Iter) when Iter > 0 ->
- P = 2*T*Q*P0 + 1,
- case is_prime(P, 50) of
- true -> P;
- false -> dsa_search(T+1, P0, Q, Iter-1)
- end;
-dsa_search(_,_,_,_) ->
- error.
-
-
-%%%%%%% Crypto Math %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-prime(ByteSize) ->
- Rand = odd_rand(ByteSize),
- prime_odd(Rand, 0).
-
-prime_odd(Rand, N) ->
- case is_prime(Rand, 50) of
- true ->
- Rand;
- false ->
- prime_odd(Rand+2, N+1)
- end.
-
-%% see http://en.wikipedia.org/wiki/Fermat_primality_test
-is_prime(_, 0) -> true;
-is_prime(Candidate, Test) ->
- CoPrime = odd_rand(10000, Candidate),
- Result = crypto:mod_pow(CoPrime, Candidate, Candidate) ,
- is_prime(CoPrime, crypto:bytes_to_integer(Result), Candidate, Test).
-
-is_prime(CoPrime, CoPrime, Candidate, Test) ->
- is_prime(Candidate, Test-1);
-is_prime(_,_,_,_) ->
- false.
-
-odd_rand(Size) ->
- Min = 1 bsl (Size*8-1),
- Max = (1 bsl (Size*8))-1,
- odd_rand(Min, Max).
-
-odd_rand(Min,Max) ->
- Rand = crypto:rand_uniform(Min,Max),
- case Rand rem 2 of
- 0 ->
- Rand + 1;
- _ ->
- Rand
- end.
-
-copyfile(SrcDir, DstDir, Fn) ->
- file:copy(filename:join(SrcDir, Fn),
- filename:join(DstDir, Fn)).
-
-%%% END SSH key management
-%%%-----------------------------------------------------------------
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key
new file mode 100644
index 0000000000..4ee0b8657e
--- /dev/null
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key
@@ -0,0 +1,13 @@
+-----BEGIN DSA PRIVATE KEY-----
+MIIBvQIBAAKBgQDuGhXsDoUC/x98Q1KEgdf+pQjzBXFu0gMf6C2P47FILALVjvzt
+HvpXarT8Y0XZb4/i5XndcKazmRArEVmPzRT0Pp7gSJpOclY/f1YrplvtMjeQaZ/Y
+eD5JoQFpgIUduiifdRRt0r5gXYejCfACa+ZSFiXTvI+ZXpHC7rH+qRCRdwIVAL6Z
+VUd15Rm/C4NrLD/nIL8tnnE3AoGBAOo9qlMBtN1MdmvJZ+Pa/x8O5+VxQvAVNysb
+DDIZQtT58ko5r3sRA783zHtUft80FA8pUAhkrnRKnqn+bK42Xrm/IMXJd8Wi9LBy
+pN5Pg37B/k6pXs2qzLDYnCCBEW9EBBUn6fyZMK7DDs/BTU7Rf0dCh1/YsxRrm0yJ
+reFOd+1gAoGBAJTq0lPrrUB62NXllTbVNAusIQX870BHBHuo3K3OFYGYD85z1gwy
+e495snKyYOT9QfkBiuH/VGxP2BgIQH+cr5hTWsFZ/09mdhEC5sj/bVDrhwexklVx
+ZeHxpIVmpB97jXomdXVR2ZoP92Gco+qU8tXcBdopQQcybk5j4fUxa+KQAhUAmGWZ
+bHhbiRb/ip5oN6edhUe47TU=
+-----END DSA PRIVATE KEY-----
+
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub
new file mode 100644
index 0000000000..bca37299b0
--- /dev/null
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/ssh_dir/ssh_host_dsa_key.pub
@@ -0,0 +1,11 @@
+---- BEGIN SSH2 PUBLIC KEY ----
+AAAAB3NzaC1kc3MAAACBAO4aFewOhQL/H3xDUoSB1/6lCPMFcW7SAx/oLY/jsUgsAtWO
+/O0e+ldqtPxjRdlvj+Lled1wprOZECsRWY/NFPQ+nuBImk5yVj9/ViumW+0yN5Bpn9h4
+PkmhAWmAhR26KJ91FG3SvmBdh6MJ8AJr5lIWJdO8j5lekcLusf6pEJF3AAAAFQC+mVVH
+deUZvwuDayw/5yC/LZ5xNwAAAIEA6j2qUwG03Ux2a8ln49r/Hw7n5XFC8BU3KxsMMhlC
+1PnySjmvexEDvzfMe1R+3zQUDylQCGSudEqeqf5srjZeub8gxcl3xaL0sHKk3k+DfsH+
+TqlezarMsNicIIERb0QEFSfp/JkwrsMOz8FNTtF/R0KHX9izFGubTImt4U537WAAAACB
+AJTq0lPrrUB62NXllTbVNAusIQX870BHBHuo3K3OFYGYD85z1gwye495snKyYOT9QfkB
+iuH/VGxP2BgIQH+cr5hTWsFZ/09mdhEC5sj/bVDrhwexklVxZeHxpIVmpB97jXomdXVR
+2ZoP92Gco+qU8tXcBdopQQcybk5j4fUxa+KQ
+---- END SSH2 PUBLIC KEY ----
diff --git a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
index 9dc9095f47..985fa40ad2 100644
--- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
+++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl
@@ -308,8 +308,19 @@ large_string(_) ->
VerifyStr = [C || C <- lists:flatten(Data1), C/=$ , C/=$\r, C/=$\n, C/=$>],
ok = ct_telnet:send(Handle, "echo_sep "++BigString),
- ct:sleep(50),
- {ok,Data2} = ct_telnet:get_data(Handle),
+ %% On some slow machines, 50 ms might not be enough to get the
+ %% first packet of data. We will therefore keep trying for a
+ %% second before we give up this...
+ F = fun RepeatUntilData(N) ->
+ ct:sleep(50),
+ case ct_telnet:get_data(Handle) of
+ {ok,[]} when N>1 ->
+ RepeatUntilData(N-1);
+ Other ->
+ Other
+ end
+ end,
+ {ok,Data2} = F(20),
ct:log("[GET DATA #2] Received ~w chars: ~s", [length(lists:flatten(Data2)),Data2]),
VerifyStr = [C || C <- lists:flatten(Data2), C/=$ , C/=$\r, C/=$\n, C/=$>],
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 107d98d72c..2c33cb268a 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -59,7 +59,7 @@ init(Opts) ->
accept(State),
ok = gen_tcp:close(LSock),
dbg("telnet_server closed the listen socket ~p\n", [LSock]),
- ct:sleep(1000),
+ timer:sleep(1000),
ok.
listen(0, _Port, _Opts) ->
@@ -68,7 +68,7 @@ listen(Retries, Port, Opts) ->
case gen_tcp:listen(Port, Opts) of
{error,eaddrinuse} ->
dbg("Listen port not released, trying again..."),
- ct:sleep(5000),
+ timer:sleep(5000),
listen(Retries-1, Port, Opts);
Ok = {ok,_LSock} ->
Ok;
@@ -193,6 +193,9 @@ handle_cmd([?AYT|T],State) ->
%% Used when testing 'newline' option in ct_telnet:send and ct_telnet:cmd.
send("yes\r\n> ",State),
handle_data(T,State);
+handle_cmd([?NOP|T],State) ->
+ %% Used for 'keep alive'
+ handle_data(T,State);
handle_cmd([_H|T],State) ->
%% Not responding to this command
handle_cmd(T,State);
@@ -203,6 +206,9 @@ handle_break_cmd([$q|T],State) ->
%% Dummy cmd allowed in break mode - quit break mode
send("\r\n> ",State),
handle_data(T,State#state{break=false});
+handle_break_cmd([_H|T],State) ->
+ %% Unknown command i break mode - ignore
+ handle_break_cmd(T,State);
handle_break_cmd([],State) ->
{ok,State}.
@@ -220,7 +226,7 @@ do_handle_data("echo_sep " ++ Data,State) ->
Msgs = string:tokens(Data," "),
lists:foreach(fun(Msg) ->
send(Msg,State),
- ct:sleep(10)
+ timer:sleep(10)
end, Msgs),
send("\r\n> ",State),
{ok,State};
@@ -245,7 +251,7 @@ do_handle_data("echo_loop " ++ Data,State) ->
do_handle_data("echo_delayed_prompt "++Data,State) ->
[MsStr|EchoData] = string:tokens(Data, " "),
send(string:join(EchoData,"\n"),State),
- ct:sleep(list_to_integer(MsStr)),
+ timer:sleep(list_to_integer(MsStr)),
send("\r\n> ",State),
{ok,State};
do_handle_data("disconnect_after " ++WaitStr,State) ->
@@ -298,7 +304,7 @@ send_loop(T0,T,Data,State) ->
ok;
true ->
send(Data,State),
- ct:sleep(500),
+ timer:sleep(500),
send_loop(T0,T,Data,State)
end.
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 1af17dc641..13aa31b7c9 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -161,6 +161,13 @@ validate_0(Module, [{function,Name,Ar,Entry,Code}|Fs], Ft) ->
% in the module (those that start with bs_start_match2).
}).
+%% Match context type.
+-record(ms,
+ {id=make_ref() :: reference(), %Unique ID.
+ valid=0 :: non_neg_integer(), %Valid slots
+ slots=0 :: non_neg_integer() %Number of slots
+ }).
+
validate_1(Is, Name, Arity, Entry, Ft) ->
validate_2(labels(Is), Name, Arity, Entry, Ft).
@@ -274,7 +281,7 @@ valfun_1({bs_context_to_binary,Ctx}, #vst{current=#st{x=Xs}}=Vst) ->
case Ctx of
{Tag,X} when Tag =:= x; Tag =:= y ->
Type = case gb_trees:lookup(X, Xs) of
- {value,{match_context,_,_}} -> term;
+ {value,#ms{}} -> term;
_ -> get_term_type(Ctx, Vst)
end,
set_type_reg(Type, Ctx, Vst);
@@ -575,7 +582,7 @@ valfun_4({test,bs_start_match2,{f,Fail},Live,[Ctx,NeedSlots],Ctx}, Vst0) ->
verify_live(Live, Vst0),
Vst1 = prune_x_regs(Live, Vst0),
BranchVst = case CtxType of
- {match_context,_,_} ->
+ #ms{} ->
%% The failure branch will never be taken when Ctx
%% is a match context. Therefore, the type for Ctx
%% at the failure label must not be match_context
@@ -828,7 +835,7 @@ kill_state_1(Vst) ->
%% The stackframe must be initialized.
%% The instruction will return to the instruction following the call.
call(Name, Live, #vst{current=St}=Vst) ->
- verify_live(Live, Vst),
+ verify_call_args(Name, Live, Vst),
verify_y_init(Vst),
case return_type(Name, Vst) of
Type when Type =/= exception ->
@@ -840,44 +847,74 @@ call(Name, Live, #vst{current=St}=Vst) ->
%% Tail call.
%% The stackframe must have a known size and be initialized.
%% Does not return to the instruction following the call.
-tail_call(Name, Live, Vst) ->
+tail_call(Name, Live, Vst0) ->
+ verify_y_init(Vst0),
+ Vst = deallocate(Vst0),
verify_call_args(Name, Live, Vst),
- verify_y_init(Vst),
verify_no_ct(Vst),
kill_state(Vst).
verify_call_args(_, 0, #vst{}) ->
ok;
verify_call_args({f,Lbl}, Live, Vst) when is_integer(Live)->
- Verify = fun(R) ->
- case get_move_term_type(R, Vst) of
- {match_context,_,_} ->
- verify_call_match_context(Lbl, Vst);
- _ ->
- ok
- end
- end,
- verify_call_args_1(Live, Verify, Vst);
+ verify_local_call(Lbl, Live, Vst);
verify_call_args(_, Live, Vst) when is_integer(Live)->
- Verify = fun(R) -> get_term_type(R, Vst) end,
- verify_call_args_1(Live, Verify, Vst);
+ verify_call_args_1(Live, Vst);
verify_call_args(_, Live, _) ->
error({bad_number_of_live_regs,Live}).
-verify_call_args_1(0, _, _) -> ok;
-verify_call_args_1(N, Verify, Vst) ->
+verify_call_args_1(0, _) -> ok;
+verify_call_args_1(N, Vst) ->
X = N - 1,
- Verify({x,X}),
- verify_call_args_1(X, Verify, Vst).
+ get_term_type({x,X}, Vst),
+ verify_call_args_1(X, Vst).
+
+verify_local_call(Lbl, Live, Vst) ->
+ case all_ms_in_x_regs(Live, Vst) of
+ [{R,Ctx}] ->
+ %% Verify that there is a suitable bs_start_match2 instruction.
+ verify_call_match_context(Lbl, R, Vst),
+
+ %% Since the callee has consumed the match context,
+ %% there must be no additional copies in Y registers.
+ #ms{id=Id} = Ctx,
+ case ms_in_y_regs(Id, Vst) of
+ [] ->
+ ok;
+ [_|_]=Ys ->
+ error({multiple_match_contexts,[R|Ys]})
+ end;
+ [_,_|_]=Xs0 ->
+ Xs = [R || {R,_} <- Xs0],
+ error({multiple_match_contexts,Xs});
+ [] ->
+ ok
+ end.
+
+all_ms_in_x_regs(0, _Vst) ->
+ [];
+all_ms_in_x_regs(Live0, Vst) ->
+ Live = Live0 - 1,
+ R = {x,Live},
+ case get_move_term_type(R, Vst) of
+ #ms{}=M ->
+ [{R,M}|all_ms_in_x_regs(Live, Vst)];
+ _ ->
+ all_ms_in_x_regs(Live, Vst)
+ end.
+
+ms_in_y_regs(Id, #vst{current=#st{y=Ys0}}) ->
+ Ys = gb_trees:to_list(Ys0),
+ [Y || {Y,#ms{id=OtherId}} <- Ys, OtherId =:= Id].
-verify_call_match_context(Lbl, #vst{ft=Ft}) ->
+verify_call_match_context(Lbl, Ctx, #vst{ft=Ft}) ->
case gb_trees:lookup(Lbl, Ft) of
none ->
error(no_bs_start_match2);
{value,[{test,bs_start_match2,_,_,[Ctx,_],Ctx}|_]} ->
ok;
- {value,[{test,bs_start_match2,_,_,[Bin,_,_],Ctx}|_]} ->
- error({binary_and_context_regs_different,Bin,Ctx})
+ {value,[{test,bs_start_match2,_,_,_,_}=I|_]} ->
+ error({unsuitable_bs_start_match2,I})
end.
allocate(Zero, Stk, Heap, Live, #vst{current=#st{numy=none}=St}=Vst0) ->
@@ -1009,7 +1046,7 @@ assert_unique_map_keys([_,_|_]=Ls) ->
%%%
bsm_match_state(Slots) ->
- {match_context,0,Slots}.
+ #ms{slots=Slots}.
bsm_validate_context(Reg, Vst) ->
_ = bsm_get_context(Reg, Vst),
@@ -1017,7 +1054,7 @@ bsm_validate_context(Reg, Vst) ->
bsm_get_context({x,X}=Reg, #vst{current=#st{x=Xs}}=_Vst) when is_integer(X) ->
case gb_trees:lookup(X, Xs) of
- {value,{match_context,_,_}=Ctx} -> Ctx;
+ {value,#ms{}=Ctx} -> Ctx;
_ -> error({no_bsm_context,Reg})
end;
bsm_get_context(Reg, _) -> error({bad_source,Reg}).
@@ -1029,8 +1066,8 @@ bsm_save(Reg, {atom,start}, Vst) ->
Vst;
bsm_save(Reg, SavePoint, Vst) ->
case bsm_get_context(Reg, Vst) of
- {match_context,Bits,Slots} when SavePoint < Slots ->
- Ctx = {match_context,Bits bor (1 bsl SavePoint),Slots},
+ #ms{valid=Bits,slots=Slots}=Ctxt0 when SavePoint < Slots ->
+ Ctx = Ctxt0#ms{valid=Bits bor (1 bsl SavePoint),slots=Slots},
set_type_reg(Ctx, Reg, Vst);
_ -> error({illegal_save,SavePoint})
end.
@@ -1042,7 +1079,7 @@ bsm_restore(Reg, {atom,start}, Vst) ->
Vst;
bsm_restore(Reg, SavePoint, Vst) ->
case bsm_get_context(Reg, Vst) of
- {match_context,Bits,Slots} when SavePoint < Slots ->
+ #ms{valid=Bits,slots=Slots} when SavePoint < Slots ->
case Bits band (1 bsl SavePoint) of
0 -> error({illegal_restore,SavePoint,not_set});
_ -> Vst
@@ -1123,7 +1160,7 @@ assert_term(Src, Vst) ->
%% Thus 'exception' is never stored as type descriptor
%% for a register.
%%
-%% {match_context,_,_} A matching context for bit syntax matching. We do allow
+%% #ms{} A match context for bit syntax matching. We do allow
%% it to moved/to from stack, but otherwise it must only
%% be accessed by bit syntax matching instructions.
%%
@@ -1230,7 +1267,7 @@ get_term_type(Src, Vst) ->
initialized -> error({unassigned,Src});
{catchtag,_} -> error({catchtag,Src});
{trytag,_} -> error({trytag,Src});
- {match_context,_,_} -> error({match_context,Src});
+ #ms{} -> error({match_context,Src});
Type -> Type
end.
@@ -1382,11 +1419,12 @@ merge_types(bool, {atom,A}) ->
merge_bool(A);
merge_types({atom,A}, bool) ->
merge_bool(A);
-merge_types({match_context,B0,Slots},{match_context,B1,Slots}) ->
- {match_context,B0 bor B1,Slots};
-merge_types({match_context,_,_}=M, _) ->
+merge_types(#ms{id=Id,valid=B0,slots=Slots}=M,
+ #ms{id=Id,valid=B1,slots=Slots}) ->
+ M#ms{valid=B0 bor B1,slots=Slots};
+merge_types(#ms{}=M, _) ->
M;
-merge_types(_, {match_context,_,_}=M) ->
+merge_types(_, #ms{}=M) ->
M;
merge_types(T1, T2) when T1 =/= T2 ->
%% Too different. All we know is that the type is a 'term'.
diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl
index 7c4e88ca3e..263fd2ca7e 100644
--- a/lib/compiler/test/beam_validator_SUITE.erl
+++ b/lib/compiler/test/beam_validator_SUITE.erl
@@ -32,7 +32,7 @@
bad_bin_match/1,bad_dsetel/1,
state_after_fault_in_catch/1,no_exception_in_catch/1,
undef_label/1,illegal_instruction/1,failing_gc_guard_bif/1,
- map_field_lists/1]).
+ map_field_lists/1,cover_bin_opt/1]).
-include_lib("common_test/include/ct.hrl").
@@ -60,7 +60,7 @@ groups() ->
freg_state,bad_bin_match,bad_dsetel,
state_after_fault_in_catch,no_exception_in_catch,
undef_label,illegal_instruction,failing_gc_guard_bif,
- map_field_lists]}].
+ map_field_lists,cover_bin_opt]}].
init_per_suite(Config) ->
Config.
@@ -406,8 +406,124 @@ map_field_lists(Config) ->
empty_field_list}}
] = Errors.
+%% Coverage and smoke test of beam_validator.
+cover_bin_opt(_Config) ->
+ Ms = [beam_utils_SUITE,
+ bs_match_SUITE,
+ bs_bincomp_SUITE,
+ bs_bit_binaries_SUITE,
+ bs_utf_SUITE],
+ test_lib:p_run(fun try_bin_opt/1, Ms),
+ ok.
+
+try_bin_opt(Mod) ->
+ try
+ do_bin_opt(Mod)
+ catch
+ Class:Error ->
+ io:format("~p: ~p ~p\n~p\n",
+ [Mod,Class,Error,erlang:get_stacktrace()]),
+ error
+ end.
+
+do_bin_opt(Mod) ->
+ Beam = code:which(Mod),
+ {ok,{Mod,[{abstract_code,
+ {raw_abstract_v1,Abstr}}]}} =
+ beam_lib:chunks(Beam, [abstract_code]),
+ {ok,Mod,Asm} = compile:forms(Abstr, ['S']),
+ do_bin_opt(Mod, Asm).
+
+do_bin_opt(Mod, Asm) ->
+ do_bin_opt(fun enable_bin_opt/1, Mod, Asm),
+ do_bin_opt(fun remove_bs_start_match/1, Mod, Asm),
+ do_bin_opt(fun remove_bs_save/1, Mod, Asm),
+ do_bin_opt(fun destroy_ctxt/1, Mod, Asm),
+ do_bin_opt(fun destroy_save_point/1, Mod, Asm),
+ ok.
+
+do_bin_opt(Transform, Mod, Asm0) ->
+ Asm = Transform(Asm0),
+ case compile:forms(Asm, [from_asm,no_postopt,return]) of
+ {ok,[],Code,_Warnings} when is_binary(Code) ->
+ ok;
+ {error,Errors0,_} ->
+ %% beam_validator must return errors, not simply crash,
+ %% when illegal code is found.
+ ModString = atom_to_list(Mod),
+ [{ModString,Errors}] = Errors0,
+ _ = [verify_bin_opt_error(E) || E <- Errors],
+ ok
+ end.
+
+verify_bin_opt_error({beam_validator,_}) ->
+ ok.
+
+enable_bin_opt(Module) ->
+ transform_is(fun enable_bin_opt_body/1, Module).
+
+enable_bin_opt_body([_,{'%',{no_bin_opt,_Reason,_Anno}}|Is]) ->
+ enable_bin_opt_body(Is);
+enable_bin_opt_body([I|Is]) ->
+ [I|enable_bin_opt_body(Is)];
+enable_bin_opt_body([]) ->
+ [].
+
+remove_bs_start_match(Module) ->
+ transform_remove(fun({test,bs_start_match2,_,_,_,_}) -> true;
+ (_) -> false
+ end, Module).
+
+remove_bs_save(Module) ->
+ transform_remove(fun({bs_save2,_,_}) -> true;
+ (_) -> false
+ end, Module).
+
+destroy_save_point(Module) ->
+ transform_i(fun do_destroy_save_point/1, Module).
+
+do_destroy_save_point({I,Ctx,_Point})
+ when I =:= bs_save2; I =:= bs_restore2 ->
+ {I,Ctx,42};
+do_destroy_save_point(I) ->
+ I.
+
+destroy_ctxt(Module) ->
+ transform_i(fun do_destroy_ctxt/1, Module).
+
+do_destroy_ctxt({bs_save2=I,Ctx,Point}) ->
+ {I,destroy_reg(Ctx),Point};
+do_destroy_ctxt({bs_restore2=I,Ctx,Point}) ->
+ {I,destroy_reg(Ctx),Point};
+do_destroy_ctxt({bs_context_to_binary=I,Ctx}) ->
+ {I,destroy_reg(Ctx)};
+do_destroy_ctxt(I) ->
+ I.
+
+destroy_reg({Tag,N}) ->
+ case rand:uniform() of
+ R when R < 0.6 ->
+ {Tag,N+1};
+ _ ->
+ {y,N+1}
+ end.
+
%%%-------------------------------------------------------------------------
+transform_remove(Remove, Module) ->
+ transform_is(fun(Is) -> [I || I <- Is, not Remove(I)] end, Module).
+
+transform_i(Transform, Module) ->
+ transform_is(fun(Is) -> [Transform(I) || I <- Is] end, Module).
+
+transform_is(Transform, {Mod,Exp,Imp,Fs0,Lc}) ->
+ Fs = [transform_is_1(Transform, F) || F <- Fs0],
+ {Mod,Exp,Imp,Fs,Lc}.
+
+transform_is_1(Transform, {function,N,A,E,Is0}) ->
+ Is = Transform(Is0),
+ {function,N,A,E,Is}.
+
do_val(Mod, Config) ->
Data = proplists:get_value(data_dir, Config),
Base = atom_to_list(Mod),
diff --git a/lib/erl_docgen/priv/css/otp_doc.css b/lib/erl_docgen/priv/css/otp_doc.css
index 347782eb1e..219740a557 100644
--- a/lib/erl_docgen/priv/css/otp_doc.css
+++ b/lib/erl_docgen/priv/css/otp_doc.css
@@ -122,6 +122,11 @@ span.code { font-family: Courier, monospace; font-weight: normal }
font-size: 90%;
padding: 5px 10px;
}
+
+.quote {
+ font-style: italic
+}
+
.example {
background-color:#eeeeff;
padding: 0px 10px;
diff --git a/lib/erl_docgen/priv/dtd/common.dtd b/lib/erl_docgen/priv/dtd/common.dtd
index 961bcd3fc2..b1578ad9d4 100644
--- a/lib/erl_docgen/priv/dtd/common.dtd
+++ b/lib/erl_docgen/priv/dtd/common.dtd
@@ -12,7 +12,7 @@
limitations under the License.
The Initial Developer of the Original Code is Ericsson AB.
- Portions created by Ericsson are Copyright 1999-2007, Ericsson AB.
+ Portions created by Ericsson are Copyright 1999-2016, Ericsson AB.
All Rights Reserved.''
$Id$
@@ -24,7 +24,7 @@
<!ENTITY % block "p|pre|code|list|taglist|codeinclude|
erleval" >
-<!ENTITY % inline "#PCDATA|c|i|em|term|cite|br|path|seealso|
+<!ENTITY % inline "#PCDATA|c|i|em|strong|term|cite|br|path|seealso|
url|marker|anno" >
<!-- XXX -->
<!ELEMENT p (%inline;)* >
@@ -40,6 +40,7 @@
<!ELEMENT c (#PCDATA|anno)* >
<!ELEMENT i (#PCDATA|c|anno)* >
<!ELEMENT em (#PCDATA|c|anno)* >
+<!ELEMENT strong (#PCDATA|c|anno)* >
<!ELEMENT anno (#PCDATA) >
<!-- XXX -->
@@ -68,7 +69,7 @@
<!ATTLIST list type (ordered|bulleted) "bulleted" >
<!ELEMENT taglist (tag,item+)+ >
<!ELEMENT tag (#PCDATA|c|i|em|br|seealso|url|marker|anno)* >
-<!ELEMENT item (%inline;|%block;|warning|note|dont|do)* >
+<!ELEMENT item (%inline;|%block;|warning|note|dont|do|quote)* >
<!-- References -->
diff --git a/lib/erl_docgen/priv/xsl/db_html.xsl b/lib/erl_docgen/priv/xsl/db_html.xsl
index c2d7d40446..75399992f2 100644
--- a/lib/erl_docgen/priv/xsl/db_html.xsl
+++ b/lib/erl_docgen/priv/xsl/db_html.xsl
@@ -785,39 +785,36 @@
<!-- Book -->
<xsl:template match="/book">
-
- <xsl:apply-templates name="parts"/>
- <xsl:apply-templates name="applications"/>
-
+ <xsl:apply-templates select="parts"/>
+ <xsl:apply-templates select="applications"/>
+ <xsl:apply-templates select="releasenotes"/>
</xsl:template>
<!-- Parts -->
<xsl:template match="parts">
- <xsl:apply-templates name="part"/>
+ <xsl:apply-templates select="part"/>
</xsl:template>
<!-- Applications -->
<xsl:template match="applications">
- <xsl:apply-templates name="application"/>
+ <xsl:apply-templates select="application"/>
</xsl:template>
-
<!-- Header -->
- <xsl:template match="header">
- </xsl:template>
-
- <!-- Section/Title -->
- <xsl:template match="section/title">
- </xsl:template>
-
- <xsl:template match="pagetext">
- </xsl:template>
+ <xsl:template match="header"/>
+
+ <!-- Section/Title -->
+ <xsl:template match="section/title"/>
+ <xsl:template match="pagetext"/>
- <!-- Chapter/Section -->
+ <!-- Chapter/Section, subsection level 1-->
<xsl:template match="chapter/section">
<xsl:param name="chapnum"/>
<h3>
+ <xsl:for-each select="marker">
+ <xsl:call-template name="marker-before-title"/>
+ </xsl:for-each>
<a name="{generate-id(title)}">
<xsl:value-of select="$chapnum"/>.<xsl:number/>&#160;
<xsl:value-of select="title"/>
@@ -829,11 +826,14 @@
</xsl:apply-templates>
</xsl:template>
- <!-- Subsections lvl 3 and ... -->
+ <!-- Subsections lvl 2 -->
<xsl:template match="section/section">
<xsl:param name="chapnum"/>
<xsl:param name="sectnum"/>
<h4>
+ <xsl:for-each select="marker">
+ <xsl:call-template name="marker-before-title"/>
+ </xsl:for-each>
<!-- xsl:value-of select="$partnum"/>.<xsl:value-of select="$chapnum"/>.<xsl:value-of select="$sectnum"/>.<xsl:number/ -->
<xsl:value-of select="title"/>
</h4>
@@ -842,10 +842,29 @@
</xsl:apply-templates>
</xsl:template>
+ <!-- Subsections lvl 3 and ... -->
+ <xsl:template match="section/section/section">
+ <xsl:param name="chapnum"/>
+ <xsl:param name="sectnum"/>
+ <h5>
+ <xsl:for-each select="marker">
+ <xsl:call-template name="marker-before-title"/>
+ </xsl:for-each>
+ <!-- xsl:value-of select="$partnum"/>.<xsl:value-of select="$chapnum"/>.<xsl:value-of select="$sectnum"/>.<xsl:number/ -->
+ <xsl:value-of select="title"/>
+ </h5>
+ <xsl:apply-templates>
+ <xsl:with-param name="chapnum" select="$chapnum"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
<!-- *ref/Section -->
<xsl:template match="erlref/section|cref/section|comref/section|fileref/section|appref/section">
<xsl:param name="chapnum"/>
<h3>
+ <xsl:for-each select="marker">
+ <xsl:call-template name="marker-before-title"/>
+ </xsl:for-each>
<a name="{generate-id(title)}">
<xsl:value-of select="title"/>
</a>
@@ -873,7 +892,6 @@
<!-- Lists -->
-
<xsl:template match="list">
<xsl:param name="chapnum"/>
<ul>
@@ -981,6 +999,18 @@
</div>
</xsl:template>
+ <!-- Quote -->
+ <xsl:template match="quote">
+ <xsl:param name="chapnum"/>
+ <div class="quote">
+ <p>
+ <xsl:apply-templates>
+ <xsl:with-param name="chapnum" select="$chapnum"/>
+ </xsl:apply-templates>
+ </p>
+ </div>
+ </xsl:template>
+
<!-- Paragraph -->
<xsl:template match="p">
<p>
@@ -989,10 +1019,6 @@
</xsl:template>
<!-- Inline elements -->
- <xsl:template match="b">
- <strong><xsl:apply-templates/></strong>
- </xsl:template>
-
<xsl:template match="i">
<i><xsl:apply-templates/></i>
</xsl:template>
@@ -1009,6 +1035,10 @@
<strong><xsl:apply-templates/></strong>
</xsl:template>
+ <xsl:template match="strong">
+ <strong><xsl:apply-templates/></strong>
+ </xsl:template>
+
<!-- Code -->
<xsl:template match="code">
<xsl:param name="chapnum"/>
@@ -1095,11 +1125,11 @@
<xsl:param name="chapnum"/>
<xsl:param name="fignum"/>
- <em>Figure
+ <p><em>Figure
<xsl:value-of select="$chapnum"/>.<xsl:value-of select="$fignum"/>:
&#160;
<xsl:apply-templates/>
- </em>
+ </em></p>
</xsl:template>
@@ -1286,9 +1316,7 @@
<xsl:with-param name="type">ref_man</xsl:with-param>
</xsl:call-template-->
-
<xsl:document href="{$outdir}/index.html" method="html" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN">
-
<xsl:call-template name="pagelayout"/>
</xsl:document>
</xsl:template>
@@ -2003,7 +2031,7 @@
</xsl:template>
<xsl:template match="seealso">
- <xsl:call-template name="seealso"/>
+ <xsl:call-template name="seealso"/>
</xsl:template>
<xsl:template name="seealso">
@@ -2085,16 +2113,27 @@
</xsl:template>
-
<xsl:template match="url">
<span class="bold_code"><a href="{@href}"><xsl:apply-templates/></a></span>
</xsl:template>
-
<xsl:template match="marker">
- <a name="{@id}"><xsl:apply-templates/></a>
+ <xsl:choose>
+ <xsl:when test="not(parent::section and following-sibling::title)">
+ <a name="{@id}"><xsl:apply-templates/></a>
+ </xsl:when>
+ </xsl:choose>
</xsl:template>
+ <xsl:template name="marker-before-title">
+ <xsl:choose>
+ <xsl:when test="self::marker and parent::section and following-sibling::title">
+ <a name="{@id}"><xsl:apply-templates/></a>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
<xsl:template match="term">
<xsl:value-of select="@id"/>
<!-- xsl:choose>
@@ -2373,7 +2412,11 @@
<xsl:template name="nl">
<xsl:text>
-</xsl:text>
+ </xsl:text>
+ </xsl:template>
+
+ <xsl:template match="seealso//text()">
+ <xsl:value-of select="normalize-space(.)"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/lib/erl_docgen/priv/xsl/db_man.xsl b/lib/erl_docgen/priv/xsl/db_man.xsl
index f75615c105..03b6b0691d 100644
--- a/lib/erl_docgen/priv/xsl/db_man.xsl
+++ b/lib/erl_docgen/priv/xsl/db_man.xsl
@@ -589,12 +589,6 @@
</xsl:template>
<!-- Inline elements -->
- <xsl:template match="b">
- <xsl:text>\fB</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>\fR\&amp; </xsl:text>
- </xsl:template>
-
<xsl:template match="i">
<xsl:text>\fI</xsl:text>
<xsl:apply-templates/>
@@ -622,6 +616,12 @@
<xsl:text>\fI</xsl:text> <xsl:apply-templates/><xsl:text>\fR\&amp;</xsl:text>
</xsl:template>
+ <xsl:template match="strong">
+ <xsl:text>\fB</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>\fR\&amp; </xsl:text>
+ </xsl:template>
+
<xsl:template match="seealso">
<xsl:choose>
<xsl:when test="ancestor::head">
diff --git a/lib/erl_docgen/priv/xsl/db_pdf.xsl b/lib/erl_docgen/priv/xsl/db_pdf.xsl
index e5e624ac4c..99263847fb 100644
--- a/lib/erl_docgen/priv/xsl/db_pdf.xsl
+++ b/lib/erl_docgen/priv/xsl/db_pdf.xsl
@@ -1171,6 +1171,16 @@
</fo:block>
</xsl:template>
+ <!-- Quote -->
+ <xsl:template match="quote">
+ <xsl:param name="chapnum"/>
+ <fo:block font-style="italic">
+ <xsl:apply-templates>
+ <xsl:with-param name="chapnum" select="$chapnum"/>
+ </xsl:apply-templates>
+ </fo:block>
+ </xsl:template>
+
<!-- Paragraph -->
<xsl:template match="p">
<fo:block xsl:use-attribute-sets="p">
@@ -1180,14 +1190,8 @@
<!-- Inline elements -->
- <xsl:template match="b">
- <fo:inline font-weight="bold">
- <xsl:apply-templates/>
- </fo:inline>
- </xsl:template>
-
<xsl:template match="i">
- <fo:inline font-weight="italic">
+ <fo:inline font-style="italic">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
@@ -1203,7 +1207,13 @@
</xsl:template>
<xsl:template match="em">
- <fo:inline font-style="italic">
+ <fo:inline font-weight="bold">
+ <xsl:apply-templates/>
+ </fo:inline>
+ </xsl:template>
+
+ <xsl:template match="strong">
+ <fo:inline font-weight="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
diff --git a/lib/runtime_tools/test/dyntrace_lttng_SUITE.erl b/lib/runtime_tools/test/dyntrace_lttng_SUITE.erl
index e6c147b003..07707c6a12 100644
--- a/lib/runtime_tools/test/dyntrace_lttng_SUITE.erl
+++ b/lib/runtime_tools/test/dyntrace_lttng_SUITE.erl
@@ -247,10 +247,16 @@ t_call_silent(Config) when is_list(Config) ->
t_receive(Config) when is_list(Config) ->
ok = lttng_start_event("com_ericsson_dyntrace:message_receive", Config),
_ = erlang:trace(new, true, [{tracer, dyntrace, []},'receive']),
+ timer:sleep(20),
+
+ Pid1 = spawn_link(fun() -> waiter() end),
+ Pid1 ! {self(), ok},
+ ok = receive {Pid1,ok} -> ok end,
+
+ Pid2 = spawn_link(fun() -> waiter() end),
+ Pid2 ! {self(), ok},
+ ok = receive {Pid2,ok} -> ok end,
- Pid = spawn_link(fun() -> waiter() end),
- Pid ! {self(), ok},
- ok = receive {Pid,ok} -> ok end,
timer:sleep(10),
_ = erlang:trace(all, false, ['receive']),
Res = lttng_stop_and_view(Config),
diff --git a/lib/ssh/doc/src/ssh.xml b/lib/ssh/doc/src/ssh.xml
index ff2d6e082a..bd330e479f 100644
--- a/lib/ssh/doc/src/ssh.xml
+++ b/lib/ssh/doc/src/ssh.xml
@@ -124,9 +124,11 @@
</func>
<func>
+ <name>connect(TcpSocket, Options) -> </name>
+ <name>connect(TcpSocket, Options, Timeout) -> </name>
<name>connect(Host, Port, Options) -> </name>
- <name>connect(Host, Port, Options, Timeout) -> {ok,
- ssh_connection_ref()} | {error, Reason}</name>
+ <name>connect(Host, Port, Options, Timeout) ->
+ {ok, ssh_connection_ref()} | {error, Reason}</name>
<fsummary>Connects to an SSH server.</fsummary>
<type>
<v>Host = string()</v>
@@ -137,6 +139,8 @@
<v>Timeout = infinity | integer()</v>
<d>Negotiation time-out in milli-seconds. The default value is <c>infinity</c>.
For connection time-out, use option <c>{connect_timeout, timeout()}</c>.</d>
+ <v>TcpSocket = port()</v>
+ <d>The socket is supposed to be from <c>gen_tcp:connect</c> with option <c>{active,false}</c></d>
</type>
<desc>
<p>Connects to an SSH server. No channel is started. This is done
diff --git a/lib/ssh/doc/src/ssh_sftp.xml b/lib/ssh/doc/src/ssh_sftp.xml
index 071d46ec57..67531b7d99 100644
--- a/lib/ssh/doc/src/ssh_sftp.xml
+++ b/lib/ssh/doc/src/ssh_sftp.xml
@@ -526,16 +526,24 @@
</func>
<func>
+ <name>start_channel(TcpSocket) -></name>
+ <name>start_channel(TcpSocket, Options) ->
+ {ok, Pid, ConnectionRef} | {error, reason()|term()}</name>
+
<name>start_channel(ConnectionRef) -></name>
- <name>start_channel(ConnectionRef, Options) -></name>
+ <name>start_channel(ConnectionRef, Options) ->
+ {ok, Pid} | {error, reason()|term()}</name>
+
<name>start_channel(Host, Options) -></name>
- <name>start_channel(Host, Port, Options) -> {ok, Pid} | {ok, Pid, ConnectionRef} |
- {error, reason()|term()}</name>
+ <name>start_channel(Host, Port, Options) ->
+ {ok, Pid, ConnectionRef} | {error, reason()|term()}</name>
<fsummary>Starts an SFTP client.</fsummary>
<type>
<v>Host = string()</v>
<v>ConnectionRef = ssh_connection_ref()</v>
<v>Port = integer()</v>
+ <v>TcpSocket = port()</v>
+ <d>The socket is supposed to be from <c>gen_tcp:connect</c> with option <c>{active,false}</c></d>
<v>Options = [{Option, Value}]</v>
</type>
<desc>
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 09b07b7a2a..50dfe55798 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -27,7 +27,9 @@
-include_lib("public_key/include/public_key.hrl").
-include_lib("kernel/include/file.hrl").
--export([start/0, start/1, stop/0, connect/3, connect/4, close/1, connection_info/2,
+-export([start/0, start/1, stop/0,
+ connect/2, connect/3, connect/4,
+ close/1, connection_info/2,
channel_info/3,
daemon/1, daemon/2, daemon/3,
daemon_info/1,
@@ -70,13 +72,46 @@ stop() ->
application:stop(ssh).
%%--------------------------------------------------------------------
--spec connect(string(), integer(), proplists:proplist()) -> {ok, pid()} | {error, term()}.
+-spec connect(port(), proplists:proplist()) -> {ok, pid()} | {error, term()}.
+
+-spec connect(port(), proplists:proplist(), timeout()) -> {ok, pid()} | {error, term()}
+ ; (string(), integer(), proplists:proplist()) -> {ok, pid()} | {error, term()}.
+
-spec connect(string(), integer(), proplists:proplist(), timeout()) -> {ok, pid()} | {error, term()}.
%%
%% Description: Starts an ssh connection.
%%--------------------------------------------------------------------
-connect(Host, Port, Options) ->
+connect(Socket, Options) ->
+ connect(Socket, Options, infinity).
+
+connect(Socket, Options, Timeout) when is_port(Socket) ->
+ case handle_options(Options) of
+ {error, _Reason} = Error ->
+ Error;
+ {_SocketOptions, SshOptions} ->
+ case proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}) of
+ {tcp,_,_} ->
+ %% Is the socket a valid tcp socket?
+ case {{ok,[]} =/= inet:getopts(Socket, [delay_send]),
+ {ok,[{active,false}]} == inet:getopts(Socket, [active])
+ }
+ of
+ {true, true} ->
+ {ok, {Host,_Port}} = inet:sockname(Socket),
+ Opts = [{user_pid,self()}, {host,fmt_host(Host)} | SshOptions],
+ ssh_connection_handler:start_connection(client, Socket, Opts, Timeout);
+ {true, false} ->
+ {error, not_passive_mode};
+ _ ->
+ {error, not_tcp_socket}
+ end;
+ {L4,_,_} ->
+ {error, {unsupported,L4}}
+ end
+ end;
+connect(Host, Port, Options) when is_integer(Port), Port>0 ->
connect(Host, Port, Options, infinity).
+
connect(Host, Port, Options, Timeout) ->
case handle_options(Options) of
{error, _Reason} = Error ->
@@ -199,8 +234,8 @@ stop_daemon(Address, Port) ->
stop_daemon(Address, Port, Profile) ->
ssh_system_sup:stop_system(Address, Port, Profile).
%%--------------------------------------------------------------------
--spec shell(string()) -> _.
--spec shell(string(), proplists:proplist()) -> _.
+-spec shell(port() | string()) -> _.
+-spec shell(port() | string(), proplists:proplist()) -> _.
-spec shell(string(), integer(), proplists:proplist()) -> _.
%% Host = string()
@@ -212,27 +247,34 @@ stop_daemon(Address, Port, Profile) ->
%% and will not return until the remote shell is ended.(e.g. on
%% exit from the shell)
%%--------------------------------------------------------------------
+shell(Socket) when is_port(Socket) ->
+ shell(Socket, []);
shell(Host) ->
shell(Host, ?SSH_DEFAULT_PORT, []).
+
+shell(Socket, Options) when is_port(Socket) ->
+ start_shell( connect(Socket, Options) );
shell(Host, Options) ->
shell(Host, ?SSH_DEFAULT_PORT, Options).
+
shell(Host, Port, Options) ->
- case connect(Host, Port, Options) of
- {ok, ConnectionRef} ->
- case ssh_connection:session_channel(ConnectionRef, infinity) of
- {ok,ChannelId} ->
- success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId, []),
- Args = [{channel_cb, ssh_shell},
- {init_args,[ConnectionRef, ChannelId]},
- {cm, ConnectionRef}, {channel_id, ChannelId}],
- {ok, State} = ssh_channel:init([Args]),
- ssh_channel:enter_loop(State);
- Error ->
- Error
- end;
+ start_shell( connect(Host, Port, Options) ).
+
+
+start_shell({ok, ConnectionRef}) ->
+ case ssh_connection:session_channel(ConnectionRef, infinity) of
+ {ok,ChannelId} ->
+ success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId, []),
+ Args = [{channel_cb, ssh_shell},
+ {init_args,[ConnectionRef, ChannelId]},
+ {cm, ConnectionRef}, {channel_id, ChannelId}],
+ {ok, State} = ssh_channel:init([Args]),
+ ssh_channel:enter_loop(State);
Error ->
Error
- end.
+ end;
+start_shell(Error) ->
+ Error.
%%--------------------------------------------------------------------
%%--------------------------------------------------------------------
@@ -835,3 +877,8 @@ handle_user_pref_pubkey_algs([H|T], Acc) ->
false ->
false
end.
+
+fmt_host({A,B,C,D}) ->
+ lists:concat([A,".",B,".",C,".",D]);
+fmt_host(T={_,_,_,_,_,_,_,_}) ->
+ lists:flatten(string:join([io_lib:format("~.16B",[A]) || A <- tuple_to_list(T)], ":")).
diff --git a/lib/ssh/src/ssh_acceptor_sup.erl b/lib/ssh/src/ssh_acceptor_sup.erl
index 4f76dbe6f0..129f85a3e0 100644
--- a/lib/ssh/src/ssh_acceptor_sup.erl
+++ b/lib/ssh/src/ssh_acceptor_sup.erl
@@ -36,6 +36,8 @@
-define(DEFAULT_TIMEOUT, 50000).
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
%%%=========================================================================
%%% API
%%%=========================================================================
diff --git a/lib/ssh/src/ssh_channel_sup.erl b/lib/ssh/src/ssh_channel_sup.erl
index 8eaa85f795..6b01dc334d 100644
--- a/lib/ssh/src/ssh_channel_sup.erl
+++ b/lib/ssh/src/ssh_channel_sup.erl
@@ -43,6 +43,8 @@ start_child(Sup, ChildSpec) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init(_Args) ->
RestartStrategy = one_for_one,
MaxR = 10,
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl
index 2d60008de6..74cd2e081a 100644
--- a/lib/ssh/src/ssh_cli.erl
+++ b/lib/ssh/src/ssh_cli.erl
@@ -47,6 +47,21 @@
%%====================================================================
%% ssh_channel callbacks
%%====================================================================
+-spec init(Args :: term()) ->
+ {ok, State :: term()} | {ok, State :: term(), timeout() | hibernate} |
+ {stop, Reason :: term()} | ignore.
+
+-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} |
+ term()),
+ State :: term()) ->
+ term().
+
+-spec handle_msg(Msg ::term(), State :: term()) ->
+ {ok, State::term()} | {stop, ChannelId::integer(), State::term()}.
+-spec handle_ssh_msg({ssh_cm, ConnectionRef::term(), SshMsg::term()},
+ State::term()) -> {ok, State::term()} |
+ {stop, ChannelId::integer(),
+ State::term()}.
%%--------------------------------------------------------------------
%% Function: init(Args) -> {ok, State}
diff --git a/lib/ssh/src/ssh_client_key_api.erl b/lib/ssh/src/ssh_client_key_api.erl
index 039a7dea9b..6e994ff292 100644
--- a/lib/ssh/src/ssh_client_key_api.erl
+++ b/lib/ssh/src/ssh_client_key_api.erl
@@ -23,14 +23,26 @@
-include_lib("public_key/include/public_key.hrl").
-include("ssh.hrl").
--callback is_host_key(PublicKey :: #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term() , Host :: string(),
- Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->
+-export_type([algorithm/0]).
+
+-type algorithm() :: 'ssh-rsa'
+ | 'ssh-dss'
+ | 'ecdsa-sha2-nistp256'
+ | 'ecdsa-sha2-nistp384'
+ | 'ecdsa-sha2-nistp521'
+ .
+
+-callback is_host_key(PublicKey :: public_key:public_key(),
+ Host :: string(),
+ Algorithm :: algorithm(),
+ ConnectOptions :: proplists:proplist()) ->
boolean().
--callback user_key(Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), ConnectOptions :: proplists:proplist()) ->
- {ok, PrivateKey :: #'RSAPrivateKey'{}| #'DSAPrivateKey'{} | term()} | {error, string()}.
+-callback user_key(Algorithm :: algorithm(),
+ ConnectOptions :: proplists:proplist()) ->
+ {ok, PrivateKey::public_key:private_key()} | {error, term()}.
--callback add_host_key(Host :: string(), PublicKey :: #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term(),
- Options :: list()) ->
+-callback add_host_key(Host :: string(), PublicKey :: public_key:public_key(),
+ Options :: proplists:proplist()) ->
ok | {error, Error::term()}.
diff --git a/lib/ssh/src/ssh_connection_sup.erl b/lib/ssh/src/ssh_connection_sup.erl
index 8c7628e909..0f54053f52 100644
--- a/lib/ssh/src/ssh_connection_sup.erl
+++ b/lib/ssh/src/ssh_connection_sup.erl
@@ -45,6 +45,8 @@ start_child(Sup, Args) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init(_) ->
RestartStrategy = simple_one_for_one,
MaxR = 0,
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index 4486d36fe4..216f65f33a 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -43,7 +43,28 @@
-define(PERM_644, 8#644).
-%% API
+%%% API
+
+%%% client
+-spec add_host_key(string(),
+ public_key:public_key(),
+ proplists:proplist()) -> ok | {error,term()}.
+
+-spec is_host_key(public_key:public_key(),
+ string(),
+ ssh_client_key_api:algorithm(),
+ proplists:proplist()) -> boolean().
+
+-spec user_key(ssh_client_key_api:algorithm(),
+ proplists:proplist()) -> {ok, public_key:private_key()} | {error,term()}.
+
+%%% server
+-spec host_key(ssh_server_key_api:algorithm(),
+ proplists:proplist()) -> {ok, public_key:private_key()} | {error,term()}.
+
+-spec is_auth_key(public_key:public_key(),
+ string(), proplists:proplist()) -> boolean().
+
%% Used by server
host_key(Algorithm, Opts) ->
diff --git a/lib/ssh/src/ssh_server_key_api.erl b/lib/ssh/src/ssh_server_key_api.erl
index c1d43a486c..3f1b886fa7 100644
--- a/lib/ssh/src/ssh_server_key_api.erl
+++ b/lib/ssh/src/ssh_server_key_api.erl
@@ -23,9 +23,16 @@
-include_lib("public_key/include/public_key.hrl").
-include("ssh.hrl").
--callback host_key(Algorithm :: 'ssh-rsa'| 'ssh-dss'| atom(), DaemonOptions :: proplists:proplist()) ->
- {ok, PrivateKey :: #'RSAPrivateKey'{}| #'DSAPrivateKey'{} | term()} | {error, string()}.
+-export_type([algorithm/0]).
--callback is_auth_key(PublicKey :: #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term(),
- User :: string(), DaemonOptions :: proplists:proplist()) ->
+-type algorithm() :: ssh_client_key_api:algorithm().
+
+
+-callback host_key(Algorithm :: algorithm(),
+ DaemonOptions :: proplists:proplist()) ->
+ {ok, PrivateKey :: public_key:private_key()} | {error, term()}.
+
+-callback is_auth_key(PublicKey :: public_key:public_key(),
+ User :: string(),
+ DaemonOptions :: proplists:proplist()) ->
boolean().
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl
index b03652a136..afc2fb88ff 100644
--- a/lib/ssh/src/ssh_sftp.erl
+++ b/lib/ssh/src/ssh_sftp.erl
@@ -95,8 +95,31 @@
%%====================================================================
start_channel(Cm) when is_pid(Cm) ->
start_channel(Cm, []);
+start_channel(Socket) when is_port(Socket) ->
+ start_channel(Socket, []);
start_channel(Host) when is_list(Host) ->
start_channel(Host, []).
+
+start_channel(Socket, Options) when is_port(Socket) ->
+ Timeout =
+ %% A mixture of ssh:connect and ssh_sftp:start_channel:
+ case proplists:get_value(connect_timeout, Options, undefined) of
+ undefined ->
+ proplists:get_value(timeout, Options, infinity);
+ TO ->
+ TO
+ end,
+ case ssh:connect(Socket, Options, Timeout) of
+ {ok,Cm} ->
+ case start_channel(Cm, Options) of
+ {ok, Pid} ->
+ {ok, Pid, Cm};
+ Error ->
+ Error
+ end;
+ Error ->
+ Error
+ end;
start_channel(Cm, Opts) when is_pid(Cm) ->
Timeout = proplists:get_value(timeout, Opts, infinity),
{_, ChanOpts, SftpOpts} = handle_options(Opts, [], [], []),
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index 819cba697e..dca018f20f 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -57,6 +57,22 @@
%%====================================================================
%% API
%%====================================================================
+-spec init(Args :: term()) ->
+ {ok, State :: term()} | {ok, State :: term(), timeout() | hibernate} |
+ {stop, Reason :: term()} | ignore.
+
+-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} |
+ term()),
+ State :: term()) ->
+ term().
+
+-spec handle_msg(Msg ::term(), State :: term()) ->
+ {ok, State::term()} | {stop, ChannelId::integer(), State::term()}.
+-spec handle_ssh_msg({ssh_cm, ConnectionRef::term(), SshMsg::term()},
+ State::term()) -> {ok, State::term()} |
+ {stop, ChannelId::integer(),
+ State::term()}.
+
subsystem_spec(Options) ->
{"sftp", {?MODULE, Options}}.
diff --git a/lib/ssh/src/ssh_shell.erl b/lib/ssh/src/ssh_shell.erl
index d31d5a297d..17224b6ef4 100644
--- a/lib/ssh/src/ssh_shell.erl
+++ b/lib/ssh/src/ssh_shell.erl
@@ -45,6 +45,21 @@
%%====================================================================
%% ssh_channel callbacks
%%====================================================================
+-spec init(Args :: term()) ->
+ {ok, State :: term()} | {ok, State :: term(), timeout() | hibernate} |
+ {stop, Reason :: term()} | ignore.
+
+-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} |
+ term()),
+ State :: term()) ->
+ term().
+
+-spec handle_msg(Msg ::term(), State :: term()) ->
+ {ok, State::term()} | {stop, ChannelId::integer(), State::term()}.
+-spec handle_ssh_msg({ssh_cm, ConnectionRef::term(), SshMsg::term()},
+ State::term()) -> {ok, State::term()} |
+ {stop, ChannelId::integer(),
+ State::term()}.
%%--------------------------------------------------------------------
%% Function: init(Args) -> {ok, State}
diff --git a/lib/ssh/src/ssh_subsystem_sup.erl b/lib/ssh/src/ssh_subsystem_sup.erl
index 11e02491c4..637f5f398f 100644
--- a/lib/ssh/src/ssh_subsystem_sup.erl
+++ b/lib/ssh/src/ssh_subsystem_sup.erl
@@ -51,6 +51,8 @@ channel_supervisor(SupPid) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init([Opts]) ->
RestartStrategy = one_for_all,
MaxR = 0,
diff --git a/lib/ssh/src/ssh_sup.erl b/lib/ssh/src/ssh_sup.erl
index f827594717..8b57387589 100644
--- a/lib/ssh/src/ssh_sup.erl
+++ b/lib/ssh/src/ssh_sup.erl
@@ -31,6 +31,8 @@
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init([]) ->
SupFlags = {one_for_one, 10, 3600},
Children = children(),
diff --git a/lib/ssh/src/ssh_system_sup.erl b/lib/ssh/src/ssh_system_sup.erl
index 9a9786a914..5035bc8f80 100644
--- a/lib/ssh/src/ssh_system_sup.erl
+++ b/lib/ssh/src/ssh_system_sup.erl
@@ -125,6 +125,8 @@ restart_acceptor(Address, Port, Profile) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init([ServerOpts]) ->
RestartStrategy = one_for_one,
MaxR = 0,
diff --git a/lib/ssh/src/sshc_sup.erl b/lib/ssh/src/sshc_sup.erl
index 71b5c2c46a..15858f36e1 100644
--- a/lib/ssh/src/sshc_sup.erl
+++ b/lib/ssh/src/sshc_sup.erl
@@ -51,6 +51,8 @@ stop_child(Client) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init(Args) ->
RestartStrategy = simple_one_for_one,
MaxR = 0,
diff --git a/lib/ssh/src/sshd_sup.erl b/lib/ssh/src/sshd_sup.erl
index ac9e232b3a..04d2df30f7 100644
--- a/lib/ssh/src/sshd_sup.erl
+++ b/lib/ssh/src/sshd_sup.erl
@@ -75,6 +75,8 @@ system_name(SysSup) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
+-spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
+
init([Servers]) ->
RestartStrategy = one_for_one,
MaxR = 10,
diff --git a/lib/ssh/test/ssh_algorithms_SUITE.erl b/lib/ssh/test/ssh_algorithms_SUITE.erl
index 6894f83547..ed9e7aacaa 100644
--- a/lib/ssh/test/ssh_algorithms_SUITE.erl
+++ b/lib/ssh/test/ssh_algorithms_SUITE.erl
@@ -111,7 +111,7 @@ init_per_group(Group, Config) ->
false ->
%% An algorithm group
Tag = proplists:get_value(name,
- hd(?config(tc_group_path, Config))),
+ hd(proplists:get_value(tc_group_path, Config))),
Alg = Group,
PA =
case split(Alg) of
@@ -128,10 +128,10 @@ init_per_group(Group, Config) ->
end.
end_per_group(_Alg, Config) ->
- case ?config(srvr_pid,Config) of
+ case proplists:get_value(srvr_pid,Config) of
Pid when is_pid(Pid) ->
ssh:stop_daemon(Pid),
- ct:log("stopped ~p",[?config(srvr_addr,Config)]);
+ ct:log("stopped ~p",[proplists:get_value(srvr_addr,Config)]);
_ ->
ok
end.
@@ -139,17 +139,16 @@ end_per_group(_Alg, Config) ->
init_per_testcase(sshc_simple_exec_os_cmd, Config) ->
- start_pubkey_daemon([?config(pref_algs,Config)], Config);
-
+ start_pubkey_daemon([proplists:get_value(pref_algs,Config)], Config);
init_per_testcase(_TC, Config) ->
Config.
end_per_testcase(sshc_simple_exec_os_cmd, Config) ->
- case ?config(srvr_pid,Config) of
+ case proplists:get_value(srvr_pid,Config) of
Pid when is_pid(Pid) ->
ssh:stop_daemon(Pid),
- ct:log("stopped ~p",[?config(srvr_addr,Config)]);
+ ct:log("stopped ~p",[proplists:get_value(srvr_addr,Config)]);
_ ->
ok
end;
@@ -161,13 +160,13 @@ end_per_testcase(_TC, Config) ->
%%--------------------------------------------------------------------
%% A simple sftp transfer
simple_sftp(Config) ->
- {Host,Port} = ?config(srvr_addr, Config),
+ {Host,Port} = proplists:get_value(srvr_addr, Config),
ssh_test_lib:std_simple_sftp(Host, Port, Config).
%%--------------------------------------------------------------------
%% A simple exec call
simple_exec(Config) ->
- {Host,Port} = ?config(srvr_addr, Config),
+ {Host,Port} = proplists:get_value(srvr_addr, Config),
ssh_test_lib:std_simple_exec(Host, Port, Config).
%%--------------------------------------------------------------------
@@ -378,8 +377,8 @@ start_pubkey_daemon(Opts0, Config) ->
setup_pubkey(Config) ->
- DataDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, UserDir),
ssh_test_lib:setup_rsa(DataDir, UserDir),
ssh_test_lib:setup_ecdsa("256", DataDir, UserDir),
@@ -389,7 +388,7 @@ setup_pubkey(Config) ->
simple_exec_group(I, Config) when is_integer(I) ->
simple_exec_group({I,I,I}, Config);
simple_exec_group({Min,I,Max}, Config) ->
- {Host,Port} = ?config(srvr_addr, Config),
+ {Host,Port} = proplists:get_value(srvr_addr, Config),
ssh_test_lib:std_simple_exec(Host, Port, Config,
[{dh_gex_limits,{Min,I,Max}}]).
diff --git a/lib/ssh/test/ssh_basic_SUITE.erl b/lib/ssh/test/ssh_basic_SUITE.erl
index 0fa44ded4f..4991816850 100644
--- a/lib/ssh/test/ssh_basic_SUITE.erl
+++ b/lib/ssh/test/ssh_basic_SUITE.erl
@@ -137,21 +137,21 @@ end_per_suite(_Config) ->
%%--------------------------------------------------------------------
init_per_group(dsa_key, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, PrivDir),
Config;
init_per_group(rsa_key, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_rsa(DataDir, PrivDir),
Config;
init_per_group(ecdsa_sha2_nistp256_key, Config) ->
case lists:member('ecdsa-sha2-nistp256',
ssh_transport:default_algorithms(public_key)) of
true ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_ecdsa("256", DataDir, PrivDir),
Config;
false ->
@@ -161,8 +161,8 @@ init_per_group(ecdsa_sha2_nistp384_key, Config) ->
case lists:member('ecdsa-sha2-nistp384',
ssh_transport:default_algorithms(public_key)) of
true ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_ecdsa("384", DataDir, PrivDir),
Config;
false ->
@@ -172,28 +172,28 @@ init_per_group(ecdsa_sha2_nistp521_key, Config) ->
case lists:member('ecdsa-sha2-nistp521',
ssh_transport:default_algorithms(public_key)) of
true ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_ecdsa("521", DataDir, PrivDir),
Config;
false ->
{skip, unsupported_pub_key}
end;
init_per_group(rsa_pass_key, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_rsa_pass_pharse(DataDir, PrivDir, "Password"),
[{pass_phrase, {rsa_pass_phrase, "Password"}}| Config];
init_per_group(dsa_pass_key, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa_pass_pharse(DataDir, PrivDir, "Password"),
[{pass_phrase, {dsa_pass_phrase, "Password"}}| Config];
init_per_group(host_user_key_differs, Config) ->
- Data = ?config(data_dir, Config),
- Sys = filename:join(?config(priv_dir, Config), system_rsa),
+ Data = proplists:get_value(data_dir, Config),
+ Sys = filename:join(proplists:get_value(priv_dir, Config), system_rsa),
SysUsr = filename:join(Sys, user),
- Usr = filename:join(?config(priv_dir, Config), user_ecdsa_256),
+ Usr = filename:join(proplists:get_value(priv_dir, Config), user_ecdsa_256),
file:make_dir(Sys),
file:make_dir(SysUsr),
file:make_dir(Usr),
@@ -205,18 +205,18 @@ init_per_group(host_user_key_differs, Config) ->
ssh_test_lib:setup_rsa_known_host(Sys, Usr),
Config;
init_per_group(key_cb, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, PrivDir),
Config;
init_per_group(internal_error, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, PrivDir),
file:delete(filename:join(PrivDir, "system/ssh_host_dsa_key")),
Config;
init_per_group(dir_options, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
%% Make unreadable dir:
Dir_unreadable = filename:join(PrivDir, "unread"),
ok = file:make_dir(Dir_unreadable),
@@ -261,27 +261,27 @@ init_per_group(_, Config) ->
Config.
end_per_group(dsa_key, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(PrivDir),
Config;
end_per_group(rsa_key, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_rsa(PrivDir),
Config;
end_per_group(dsa_pass_key, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(PrivDir),
Config;
end_per_group(rsa_pass_key, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_rsa(PrivDir),
Config;
end_per_group(key_cb, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(PrivDir),
Config;
end_per_group(internal_error, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(PrivDir),
Config;
@@ -290,9 +290,9 @@ end_per_group(_, Config) ->
%%--------------------------------------------------------------------
init_per_testcase(TC, Config) when TC==shell_no_unicode ;
TC==shell_unicode_string ->
- PrivDir = ?config(priv_dir, Config),
- UserDir = ?config(priv_dir, Config),
- SysDir = ?config(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
ssh:start(),
Sftpd = {_Pid, _Host, Port} =
ssh_test_lib:daemon([{system_dir, SysDir},
@@ -321,12 +321,12 @@ init_per_testcase(_TestCase, Config) ->
end_per_testcase(TestCase, Config) when TestCase == server_password_option;
TestCase == server_userpassword_option ->
- UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), nopubkey),
ssh_test_lib:del_dirs(UserDir),
end_per_testcase(Config);
end_per_testcase(TC, Config) when TC==shell_no_unicode ;
TC==shell_unicode_string ->
- case ?config(sftpd, Config) of
+ case proplists:get_value(sftpd, Config) of
{Pid, _, _} ->
ssh:stop_daemon(Pid),
ssh:stop();
@@ -355,8 +355,8 @@ appup_test(Config) when is_list(Config) ->
%%% some options not yet present are not decided if we should support or
%%% if they need thier own test case.
misc_ssh_options(Config) when is_list(Config) ->
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
CMiscOpt0 = [{connect_timeout, 1000}, {user_dir, UserDir}],
CMiscOpt1 = [{connect_timeout, infinity}, {user_dir, UserDir}],
@@ -369,8 +369,8 @@ misc_ssh_options(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% Test configuring IPv4
inet_option(Config) when is_list(Config) ->
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
ClientOpts = [{silently_accept_hosts, true},
{user_dir, UserDir},
@@ -385,8 +385,8 @@ inet_option(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% Test configuring IPv6
inet6_option(Config) when is_list(Config) ->
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
ClientOpts = [{silently_accept_hosts, true},
{user_dir, UserDir},
@@ -402,8 +402,8 @@ inet6_option(Config) when is_list(Config) ->
%%% Test api function ssh_connection:exec
exec(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -449,8 +449,8 @@ exec_compressed(Config) when is_list(Config) ->
true ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},{user_dir, UserDir},
{preferred_algorithms,[{compression, [zlib]}]},
@@ -478,8 +478,8 @@ exec_compressed(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% Idle timeout test
idle_time(Config) ->
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -501,8 +501,8 @@ idle_time(Config) ->
%%% Test that ssh:shell/2 works
shell(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},{user_dir, UserDir},
{failfun, fun ssh_test_lib:failfun/2}]),
@@ -536,9 +536,9 @@ exec_key_differs(Config, UserPKAlgs) ->
of
[] ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system_rsa),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system_rsa),
SystemUserDir = filename:join(SystemDir, user),
- UserDir = filename:join(?config(priv_dir, Config), user_ecdsa_256),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), user_ecdsa_256),
{_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, SystemUserDir},
@@ -570,9 +570,9 @@ exec_key_differs(Config, UserPKAlgs) ->
%%--------------------------------------------------------------------
exec_key_differs_fail(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system_rsa),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system_rsa),
SystemUserDir = filename:join(SystemDir, user),
- UserDir = filename:join(?config(priv_dir, Config), user_ecdsa_256),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), user_ecdsa_256),
{_Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, SystemUserDir},
@@ -597,10 +597,10 @@ exec_key_differs_fail(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
cli(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
- TmpDir = filename:join(?config(priv_dir,Config), "tmp"),
+ TmpDir = filename:join(proplists:get_value(priv_dir,Config), "tmp"),
ok = ssh_test_lib:del_dirs(TmpDir),
ok = file:make_dir(TmpDir),
@@ -639,8 +639,8 @@ cli(Config) when is_list(Config) ->
%%% Test that get correct error message if you try to start a daemon
%%% on an adress that already runs a daemon see also seq10667
daemon_already_started(Config) when is_list(Config) ->
- SystemDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, _Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -654,8 +654,8 @@ daemon_already_started(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% check that known_hosts is updated correctly
known_hosts(Config) when is_list(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{user_dir, PrivDir},{system_dir, SystemDir},
{failfun, fun ssh_test_lib:failfun/2}]),
@@ -681,9 +681,9 @@ known_hosts(Config) when is_list(Config) ->
%%% Test that we can use keyes protected by pass phrases
pass_phrase(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
- PhraseArg = ?config(pass_phrase, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
+ PhraseArg = proplists:get_value(pass_phrase, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -700,8 +700,8 @@ pass_phrase(Config) when is_list(Config) ->
%%% Test that we can use key callback
key_callback(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
NoPubKeyDir = filename:join(UserDir, "nopubkey"),
file:make_dir(NoPubKeyDir),
@@ -724,8 +724,8 @@ key_callback(Config) when is_list(Config) ->
%%% Test that we can use key callback with callback options
key_callback_options(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
NoPubKeyDir = filename:join(UserDir, "nopubkey"),
file:make_dir(NoPubKeyDir),
@@ -751,8 +751,8 @@ key_callback_options(Config) when is_list(Config) ->
%%% Test that client does not hang if disconnects due to internal error
internal_error(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -768,8 +768,8 @@ internal_error(Config) when is_list(Config) ->
%%% Test ssh_connection:send/3
send(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -788,8 +788,8 @@ send(Config) when is_list(Config) ->
%%% Test ssh:connection_info([peername, sockname])
peername_sockname(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{_Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -838,8 +838,8 @@ ips(Name) when is_list(Name) ->
%%% Client receives close when server closes
close(Config) when is_list(Config) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Server, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -861,8 +861,8 @@ close(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% Simulate that we try to close an already closed connection
double_close(Config) when is_list(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
@@ -881,8 +881,8 @@ double_close(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
daemon_opt_fd(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
@@ -908,8 +908,8 @@ daemon_opt_fd(Config) ->
%%--------------------------------------------------------------------
multi_daemon_opt_fd(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
@@ -943,8 +943,8 @@ multi_daemon_opt_fd(Config) ->
%%--------------------------------------------------------------------
packet_size_zero(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
@@ -974,7 +974,7 @@ packet_size_zero(Config) ->
%%--------------------------------------------------------------------
shell_no_unicode(Config) ->
- new_do_shell(?config(io,Config),
+ new_do_shell(proplists:get_value(io,Config),
[new_prompt,
{type,"io:format(\"hej ~p~n\",[42])."},
{expect,"hej 42"},
@@ -985,7 +985,7 @@ shell_no_unicode(Config) ->
%%--------------------------------------------------------------------
shell_unicode_string(Config) ->
- new_do_shell(?config(io,Config),
+ new_do_shell(proplists:get_value(io,Config),
[new_prompt,
{type,"io:format(\"こにちわ~ts~n\",[\"四二\"])."},
{expect,"こにちわ四二"},
@@ -1002,8 +1002,8 @@ openssh_zlib_basic_test(Config) ->
{skip, io_lib:format("~p compression is not supported",[L])};
true ->
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{user_dir, UserDir},
@@ -1023,11 +1023,11 @@ openssh_zlib_basic_test(Config) ->
%%--------------------------------------------------------------------
ssh_info_print(Config) ->
%% Just check that ssh_print:info() crashes
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
PrintFile = filename:join(PrivDir,info),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
UnexpFun = fun(Msg,_Peer) ->
@@ -1103,8 +1103,8 @@ check_error(Error) ->
ct:fail(Error).
basic_test(Config) ->
- ClientOpts = ?config(client_opts, Config),
- ServerOpts = ?config(server_opts, Config),
+ ClientOpts = proplists:get_value(client_opts, Config),
+ ServerOpts = proplists:get_value(server_opts, Config),
{Pid, Host, Port} = ssh_test_lib:daemon(ServerOpts),
{ok, CM} = ssh:connect(Host, Port, ClientOpts),
diff --git a/lib/ssh/test/ssh_benchmark_SUITE.erl b/lib/ssh/test/ssh_benchmark_SUITE.erl
index 5d8c94be73..c2bfc48449 100644
--- a/lib/ssh/test/ssh_benchmark_SUITE.erl
+++ b/lib/ssh/test/ssh_benchmark_SUITE.erl
@@ -29,7 +29,9 @@
-include_lib("ssh/src/ssh_userauth.hrl").
-suite() -> [{ct_hooks,[{ts_install_cth,[{nodenames,2}]}]}].
+suite() -> [{ct_hooks,[{ts_install_cth,[{nodenames,2}]}]},
+ {timetrap,{minutes,3}}
+ ].
%%suite() -> [{ct_hooks,[ts_install_cth]}].
all() -> [{group, opensshc_erld}
@@ -63,8 +65,8 @@ end_per_suite(_Config) ->
init_per_group(opensshc_erld, Config) ->
case ssh_test_lib:ssh_type() of
openSSH ->
- DataDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, UserDir),
ssh_test_lib:setup_rsa(DataDir, UserDir),
ssh_test_lib:setup_ecdsa("256", DataDir, UserDir),
@@ -97,7 +99,7 @@ end_per_testcase(_Func, _Conf) ->
init_sftp_dirs(Config) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
SrcDir = filename:join(UserDir, "sftp_src"),
ok = file:make_dir(SrcDir),
SrcFile = "big_data",
@@ -127,8 +129,8 @@ openssh_client_shell(Config) ->
openssh_client_shell(Config, Options) ->
- SystemDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
KnownHosts = filename:join(UserDir, "known_hosts"),
{ok, TracerPid} = erlang_trace(),
@@ -200,11 +202,11 @@ openssh_client_sftp(Config) ->
openssh_client_sftp(Config, Options) ->
- SystemDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
- SftpSrcDir = ?config(sftp_src_dir, Config),
- SrcFile = ?config(src_file, Config),
- SrcSize = ?config(sftp_size, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
+ SftpSrcDir = proplists:get_value(sftp_src_dir, Config),
+ SrcFile = proplists:get_value(src_file, Config),
+ SrcSize = proplists:get_value(sftp_size, Config),
KnownHosts = filename:join(UserDir, "known_hosts"),
{ok, TracerPid} = erlang_trace(),
@@ -275,7 +277,7 @@ variants(Tag, Config) ->
[A|_] when is_atom(A) -> two_way
end,
[ [{Tag,tag_value(TagType,Alg)}]
- || Alg <- proplists:get_value(Tag, ?config(common_algs,Config))
+ || Alg <- proplists:get_value(Tag, proplists:get_value(common_algs,Config))
].
tag_value(two_way, Alg) -> [Alg];
diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl
index 0f757a0322..c9a321fbbd 100644
--- a/lib/ssh/test/ssh_connection_SUITE.erl
+++ b/lib/ssh/test/ssh_connection_SUITE.erl
@@ -47,6 +47,7 @@ all() ->
start_shell,
start_shell_exec,
start_shell_exec_fun,
+ start_shell_sock_exec_fun,
gracefull_invalid_version,
gracefull_invalid_start,
gracefull_invalid_long_start,
@@ -60,6 +61,9 @@ groups() ->
payload() ->
[simple_exec,
+ simple_exec_sock,
+ connect_sock_not_tcp,
+ connect_sock_not_passive,
small_cat,
big_cat,
send_after_exit].
@@ -111,6 +115,18 @@ simple_exec() ->
simple_exec(Config) when is_list(Config) ->
ConnectionRef = ssh_test_lib:connect(?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
{user_interaction, false}]),
+ do_simple_exec(ConnectionRef).
+
+
+simple_exec_sock(Config) ->
+ {ok, Sock} = gen_tcp:connect("localhost", ?SSH_DEFAULT_PORT, [{active,false}]),
+ {ok, ConnectionRef} = ssh:connect(Sock, [{silently_accept_hosts, true},
+ {user_interaction, false}]),
+ do_simple_exec(ConnectionRef).
+
+
+
+do_simple_exec(ConnectionRef) ->
{ok, ChannelId0} = ssh_connection:session_channel(ConnectionRef, infinity),
success = ssh_connection:exec(ConnectionRef, ChannelId0,
"echo testing", infinity),
@@ -143,6 +159,18 @@ simple_exec(Config) when is_list(Config) ->
end.
%%--------------------------------------------------------------------
+connect_sock_not_tcp(Config) ->
+ {ok,Sock} = gen_udp:open(0, []),
+ {error, not_tcp_socket} = ssh:connect(Sock, []),
+ gen_udp:close(Sock).
+
+%%--------------------------------------------------------------------
+connect_sock_not_passive(Config) ->
+ {ok,Sock} = gen_tcp:connect("localhost", ?SSH_DEFAULT_PORT, []),
+ {error, not_passive_mode} = ssh:connect(Sock, []),
+ gen_tcp:close(Sock).
+
+%%--------------------------------------------------------------------
small_cat() ->
[{doc, "Use 'cat' to echo small data block back to us."}].
@@ -316,10 +344,10 @@ ptty_alloc_pixel(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
interrupted_send(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
@@ -359,10 +387,10 @@ start_shell() ->
[{doc, "Start a shell"}].
start_shell(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
@@ -391,10 +419,10 @@ start_shell_exec() ->
[{doc, "start shell to exec command"}].
start_shell_exec(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
@@ -425,10 +453,10 @@ start_shell_exec_fun() ->
[{doc, "start shell to exec command"}].
start_shell_exec_fun(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
@@ -456,12 +484,48 @@ start_shell_exec_fun(Config) when is_list(Config) ->
ssh:stop_daemon(Pid).
%%--------------------------------------------------------------------
+start_shell_sock_exec_fun() ->
+ [{doc, "start shell on tcp-socket to exec command"}].
+
+start_shell_sock_exec_fun(Config) when is_list(Config) ->
+ PrivDir = proplists:get_value(priv_dir, Config),
+ UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
+ file:make_dir(UserDir),
+ SysDir = proplists:get_value(data_dir, Config),
+ {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
+ {user_dir, UserDir},
+ {password, "morot"},
+ {exec, fun ssh_exec/1}]),
+
+ {ok, Sock} = gen_tcp:connect(Host, Port, [{active,false}]),
+ {ok,ConnectionRef} = ssh:connect(Sock, [{silently_accept_hosts, true},
+ {user, "foo"},
+ {password, "morot"},
+ {user_interaction, true},
+ {user_dir, UserDir}]),
+
+ {ok, ChannelId0} = ssh_connection:session_channel(ConnectionRef, infinity),
+
+ success = ssh_connection:exec(ConnectionRef, ChannelId0,
+ "testing", infinity),
+
+ receive
+ {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"testing\r\n">>}} ->
+ ok
+ after 5000 ->
+ ct:fail("Exec Timeout")
+ end,
+
+ ssh:close(ConnectionRef),
+ ssh:stop_daemon(Pid).
+
+%%--------------------------------------------------------------------
gracefull_invalid_version(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{_Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
@@ -481,10 +545,10 @@ gracefull_invalid_version(Config) when is_list(Config) ->
end.
gracefull_invalid_start(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{_Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"}]),
@@ -503,10 +567,10 @@ gracefull_invalid_start(Config) when is_list(Config) ->
end.
gracefull_invalid_long_start(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{_Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"}]),
@@ -526,10 +590,10 @@ gracefull_invalid_long_start(Config) when is_list(Config) ->
gracefull_invalid_long_start_no_nl(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{_Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"}]),
@@ -551,10 +615,10 @@ stop_listener() ->
[{doc, "start ssh daemon, setup connections, stop listener, restart listner"}].
stop_listener(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid0, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
@@ -610,10 +674,10 @@ stop_listener(Config) when is_list(Config) ->
end.
start_subsystem_on_closed_channel(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
@@ -639,10 +703,10 @@ max_channels_option() ->
[{doc, "Test max_channels option"}].
max_channels_option(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
diff --git a/lib/ssh/test/ssh_options_SUITE.erl b/lib/ssh/test/ssh_options_SUITE.erl
index 4ca6a473fa..d1e3d6cb0e 100644
--- a/lib/ssh/test/ssh_options_SUITE.erl
+++ b/lib/ssh/test/ssh_options_SUITE.erl
@@ -133,12 +133,12 @@ end_per_suite(_Config) ->
%%--------------------------------------------------------------------
init_per_group(hardening_tests, Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, PrivDir),
Config;
init_per_group(dir_options, Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
%% Make unreadable dir:
Dir_unreadable = filename:join(PrivDir, "unread"),
ok = file:make_dir(Dir_unreadable),
@@ -193,7 +193,7 @@ end_per_testcase(TestCase, Config) when TestCase == server_password_option;
TestCase == server_userpassword_option;
TestCase == server_pwdfun_option;
TestCase == server_pwdfun_4_option ->
- UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), nopubkey),
ssh_test_lib:del_dirs(UserDir),
end_per_testcase(Config);
end_per_testcase(_TestCase, Config) ->
@@ -210,10 +210,10 @@ end_per_testcase(_Config) ->
%%% validate to server that uses the 'password' option
server_password_option(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"}]),
@@ -243,10 +243,10 @@ server_password_option(Config) when is_list(Config) ->
%%% validate to server that uses the 'password' option
server_userpassword_option(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, PrivDir},
{user_passwords, [{"vego", "morot"}]}]),
@@ -278,10 +278,10 @@ server_userpassword_option(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
%%% validate to server that uses the 'pwdfun' option
server_pwdfun_option(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
CHKPWD = fun("foo",Pwd) -> Pwd=="bar";
(_,_) -> false
end,
@@ -316,10 +316,10 @@ server_pwdfun_option(Config) ->
%%--------------------------------------------------------------------
%%% validate to server that uses the 'pwdfun/4' option
server_pwdfun_4_option(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
PWDFUN = fun("foo",Pwd,{_,_},undefined) -> Pwd=="bar";
("fie",Pwd,{_,_},undefined) -> {Pwd=="bar",new_state};
("bandit",_,_,_) -> disconnect;
@@ -376,10 +376,10 @@ server_pwdfun_4_option(Config) ->
%%--------------------------------------------------------------------
server_pwdfun_4_option_repeat(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
%% Test that the state works
Parent = self(),
PWDFUN = fun("foo",P="bar",_,S) -> Parent!{P,S},true;
@@ -471,10 +471,10 @@ user_dir_option(Config) ->
%%--------------------------------------------------------------------
%%% validate client that uses the 'ssh_msg_debug_fun' option
ssh_msg_debug_fun_option_client(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
@@ -511,10 +511,10 @@ ssh_msg_debug_fun_option_client(Config) ->
%%--------------------------------------------------------------------
connectfun_disconnectfun_server(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
Ref = make_ref(),
@@ -549,10 +549,10 @@ connectfun_disconnectfun_server(Config) ->
%%--------------------------------------------------------------------
connectfun_disconnectfun_client(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
Ref = make_ref(),
@@ -580,10 +580,10 @@ connectfun_disconnectfun_client(Config) ->
%%--------------------------------------------------------------------
%%% validate client that uses the 'ssh_msg_debug_fun' option
ssh_msg_debug_fun_option_server(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
DbgFun = fun(ConnRef,Displ,Msg,Lang) -> Parent ! {msg_dbg,{ConnRef,Displ,Msg,Lang}} end,
@@ -624,10 +624,10 @@ ssh_msg_debug_fun_option_server(Config) ->
%%--------------------------------------------------------------------
disconnectfun_option_server(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
DisConnFun = fun(Reason) -> Parent ! {disconnect,Reason} end,
@@ -659,10 +659,10 @@ disconnectfun_option_server(Config) ->
%%--------------------------------------------------------------------
disconnectfun_option_client(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
DisConnFun = fun(Reason) -> Parent ! {disconnect,Reason} end,
@@ -693,10 +693,10 @@ disconnectfun_option_client(Config) ->
%%--------------------------------------------------------------------
unexpectedfun_option_server(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
ConnFun = fun(_,_,_) -> Parent ! {connection_pid,self()} end,
@@ -736,10 +736,10 @@ unexpectedfun_option_server(Config) ->
%%--------------------------------------------------------------------
unexpectedfun_option_client(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
- SysDir = ?config(data_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
Parent = self(),
UnexpFun = fun(Msg,Peer) ->
@@ -859,8 +859,8 @@ ms_passed(T0) ->
%%--------------------------------------------------------------------
ssh_daemon_minimal_remote_max_packet_size_option(Config) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
@@ -957,8 +957,8 @@ ssh_connect_negtimeout_sequential(Config) -> ssh_connect_negtimeout(Config,false
ssh_connect_negtimeout(Config, Parallel) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
NegTimeOut = 2000, % ms
ct:log("Parallel: ~p",[Parallel]),
@@ -990,8 +990,8 @@ ssh_connect_nonegtimeout_connected_sequential(Config) ->
ssh_connect_nonegtimeout_connected(Config, Parallel) ->
process_flag(trap_exit, true),
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
NegTimeOut = 2000, % ms
ct:log("Parallel: ~p",[Parallel]),
@@ -1067,7 +1067,7 @@ connect_fun(ssh__connect, Config) ->
fun(Host,Port) ->
ssh_test_lib:connect(Host, Port,
[{silently_accept_hosts, true},
- {user_dir, ?config(priv_dir,Config)},
+ {user_dir, proplists:get_value(priv_dir,Config)},
{user_interaction, false},
{user, "carni"},
{password, "meat"}
@@ -1092,8 +1092,8 @@ max_sessions(Config, ParallelLogin, Connect0) when is_function(Connect0,2) ->
ct:log("Connect(~p,~p) -> ~p",[Host,Port,R]),
R
end,
- SystemDir = filename:join(?config(priv_dir, Config), system),
- UserDir = ?config(priv_dir, Config),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
+ UserDir = proplists:get_value(priv_dir, Config),
MaxSessions = 5,
{Pid, Host, Port} = ssh_test_lib:daemon([
{system_dir, SystemDir},
diff --git a/lib/ssh/test/ssh_property_test_SUITE.erl b/lib/ssh/test/ssh_property_test_SUITE.erl
index c5cc36c45e..c8aabcedb7 100644
--- a/lib/ssh/test/ssh_property_test_SUITE.erl
+++ b/lib/ssh/test/ssh_property_test_SUITE.erl
@@ -57,7 +57,7 @@ init_per_suite(Config) ->
%%% One group in this suite happens to support only QuickCheck, so skip it
%%% if we run proper.
init_per_group(client_server, Config) ->
- case ?config(property_test_tool,Config) of
+ case proplists:get_value(property_test_tool,Config) of
eqc -> Config;
X -> {skip, lists:concat([X," is not supported"])}
end;
diff --git a/lib/ssh/test/ssh_protocol_SUITE.erl b/lib/ssh/test/ssh_protocol_SUITE.erl
index 57404f40db..41faf951e1 100644
--- a/lib/ssh/test/ssh_protocol_SUITE.erl
+++ b/lib/ssh/test/ssh_protocol_SUITE.erl
@@ -107,11 +107,11 @@ init_per_testcase(TC, Config) when TC == gex_client_init_option_groups ;
gex_client_init_option_groups ->
[{dh_gex_groups, [{2345, 3, 41}]}];
gex_client_init_option_groups_file ->
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
F = filename:join(DataDir, "dh_group_test"),
[{dh_gex_groups, {file,F}}];
gex_client_init_option_groups_moduli_file ->
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
F = filename:join(DataDir, "dh_group_test.moduli"),
[{dh_gex_groups, {ssh_moduli_file,F}}];
_ when TC == gex_server_gex_limit ;
@@ -589,21 +589,21 @@ stop_apps(_Config) ->
setup_dirs(Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_rsa(DataDir, PrivDir),
Config.
-system_dir(Config) -> filename:join(?config(priv_dir, Config), system).
+system_dir(Config) -> filename:join(proplists:get_value(priv_dir, Config), system).
-user_dir(Config) -> ?config(priv_dir, Config).
+user_dir(Config) -> proplists:get_value(priv_dir, Config).
%%%----------------------------------------------------------------
start_std_daemon(Config) ->
start_std_daemon(Config, []).
start_std_daemon(Config, ExtraOpts) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
UserPasswords = [{"user1","pwd1"}],
diff --git a/lib/ssh/test/ssh_renegotiate_SUITE.erl b/lib/ssh/test/ssh_renegotiate_SUITE.erl
index f1a909cbd0..300816276a 100644
--- a/lib/ssh/test/ssh_renegotiate_SUITE.erl
+++ b/lib/ssh/test/ssh_renegotiate_SUITE.erl
@@ -108,10 +108,10 @@ rekey(Config) ->
rekey_limit() -> [{timetrap,{seconds,400}}].
rekey_limit(Config) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
DataFile = filename:join(UserDir, "rekey.data"),
- Algs = ?config(preferred_algorithms, Config),
+ Algs = proplists:get_value(preferred_algorithms, Config),
{Pid, Host, Port} = ssh_test_lib:std_daemon(Config,[{max_random_length_padding,0},
{preferred_algorithms,Algs}]),
@@ -154,10 +154,10 @@ rekey_limit(Config) ->
%%% Test rekeying with simulataneous send request
renegotiate1(Config) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
DataFile = filename:join(UserDir, "renegotiate1.data"),
- Algs = ?config(preferred_algorithms, Config),
+ Algs = proplists:get_value(preferred_algorithms, Config),
{Pid, Host, DPort} = ssh_test_lib:std_daemon(Config,[{max_random_length_padding,0},
{preferred_algorithms,Algs}]),
@@ -194,10 +194,10 @@ renegotiate1(Config) ->
%%% Test rekeying with inflight messages from peer
renegotiate2(Config) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
DataFile = filename:join(UserDir, "renegotiate2.data"),
- Algs = ?config(preferred_algorithms, Config),
+ Algs = proplists:get_value(preferred_algorithms, Config),
{Pid, Host, DPort} = ssh_test_lib:std_daemon(Config,[{max_random_length_padding,0},
{preferred_algorithms,Algs}]),
diff --git a/lib/ssh/test/ssh_sftp_SUITE.erl b/lib/ssh/test/ssh_sftp_SUITE.erl
index 26fe0935e1..4d40b4647c 100644
--- a/lib/ssh/test/ssh_sftp_SUITE.erl
+++ b/lib/ssh/test/ssh_sftp_SUITE.erl
@@ -86,13 +86,14 @@ groups() ->
write_file, write_file_iolist, write_big_file, sftp_read_big_file,
rename_file, mk_rm_dir, remove_file, links,
retrieve_attributes, set_attributes, async_read,
- async_write, position, pos_read, pos_write
+ async_write, position, pos_read, pos_write,
+ start_channel_sock
]}
].
init_per_group(not_unicode, Config) ->
ct:comment("Begin ~p",[grps(Config)]),
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
[{user, "Alladin"},
{passwd, "Sesame"},
{data, <<"Hello world!">>},
@@ -110,7 +111,7 @@ init_per_group(unicode, Config) ->
of
true ->
ct:comment("Begin ~p",[grps(Config)]),
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
NewConfig =
[{user, "åke高兴"},
{passwd, "ärlig日本じん"},
@@ -131,7 +132,7 @@ init_per_group(unicode, Config) ->
]
)
],
- FN = fn(?config(tar_F1_txt,NewConfig), NewConfig),
+ FN = fn(proplists:get_value(tar_F1_txt,NewConfig), NewConfig),
case catch file:read_file(FN) of
{ok,FN_contents} ->
ct:log("Readable file:read_file(~tp) ->~n~tp",[FN,FN_contents]),
@@ -147,10 +148,10 @@ init_per_group(unicode, Config) ->
init_per_group(erlang_server, Config) ->
ct:comment("Begin ~p",[grps(Config)]),
- PrivDir = ?config(priv_dir, Config),
- SysDir = ?config(data_dir, Config),
- User = ?config(user, Config),
- Passwd = ?config(passwd, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
+ User = proplists:get_value(user, Config),
+ Passwd = proplists:get_value(passwd, Config),
Sftpd = {_, HostX, PortX} =
ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, PrivDir},
@@ -176,12 +177,12 @@ init_per_group(openssh_server, Config) ->
init_per_group(remote_tar, Config) ->
ct:comment("Begin ~p",[grps(Config)]),
- {Host,Port} = ?config(peer, Config),
- ct:log("Server (~p) at ~p:~p",[?config(group,Config),Host,Port]),
- User = ?config(user, Config),
- Passwd = ?config(passwd, Config),
+ {Host,Port} = proplists:get_value(peer, Config),
+ ct:log("Server (~p) at ~p:~p",[proplists:get_value(group,Config),Host,Port]),
+ User = proplists:get_value(user, Config),
+ Passwd = proplists:get_value(passwd, Config),
{ok, Connection} =
- case ?config(group, Config) of
+ case proplists:get_value(group, Config) of
erlang_server ->
ssh:connect(Host, Port,
[{user, User},
@@ -216,10 +217,10 @@ end_per_group(_, Config) ->
%%--------------------------------------------------------------------
init_per_testcase(sftp_nonexistent_subsystem, Config) ->
- PrivDir = ?config(priv_dir, Config),
- SysDir = ?config(data_dir, Config),
- User = ?config(user, Config),
- Passwd = ?config(passwd, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ SysDir = proplists:get_value(data_dir, Config),
+ User = proplists:get_value(user, Config),
+ Passwd = proplists:get_value(passwd, Config),
Sftpd = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, PrivDir},
{subsystems, []},
@@ -233,9 +234,9 @@ init_per_testcase(version_option, Config0) ->
TmpConfig0 = lists:keydelete(watchdog, 1, Config),
TmpConfig = lists:keydelete(sftp, 1, TmpConfig0),
Dog = ct:timetrap(?default_timeout),
- {_,Host, Port} = ?config(sftpd, Config),
- User = ?config(user, Config),
- Passwd = ?config(passwd, Config),
+ {_,Host, Port} = proplists:get_value(sftpd, Config),
+ User = proplists:get_value(user, Config),
+ Passwd = proplists:get_value(passwd, Config),
{ok, ChannelPid, Connection} =
ssh_sftp:start_channel(Host, Port,
[{sftp_vsn, 3},
@@ -251,13 +252,13 @@ init_per_testcase(Case, Config00) ->
Config1 = lists:keydelete(watchdog, 1, Config0),
Config2 = lists:keydelete(sftp, 1, Config1),
Dog = ct:timetrap(2 * ?default_timeout),
- User = ?config(user, Config0),
- Passwd = ?config(passwd, Config0),
+ User = proplists:get_value(user, Config0),
+ Passwd = proplists:get_value(passwd, Config0),
Config =
- case ?config(group,Config2) of
+ case proplists:get_value(group,Config2) of
erlang_server ->
- {_,Host, Port} = ?config(sftpd, Config2),
+ {_,Host, Port} = proplists:get_value(sftpd, Config2),
{ok, ChannelPid, Connection} =
ssh_sftp:start_channel(Host, Port,
[{user, User},
@@ -283,7 +284,7 @@ init_per_testcase(Case, Config00) ->
%% The 'catch' is for the case of Config={skip,...}
true ->
%% Provide a ChannelPid independent of the sftp-channel already opened.
- {ok,ChPid2} = ssh_sftp:start_channel(?config(connection,Config)),
+ {ok,ChPid2} = ssh_sftp:start_channel(proplists:get_value(connection,Config)),
[{channel_pid2,ChPid2} | Config];
_ ->
Config
@@ -292,16 +293,16 @@ init_per_testcase(Case, Config00) ->
end_per_testcase(sftp_nonexistent_subsystem, Config) ->
Config;
end_per_testcase(rename_file, Config) ->
- NewFileName = ?config(testfile, Config),
+ NewFileName = proplists:get_value(testfile, Config),
file:delete(NewFileName),
end_per_testcase(Config);
end_per_testcase(_, Config) ->
end_per_testcase(Config).
end_per_testcase(Config) ->
- {Sftp, Connection} = ?config(sftp, Config),
+ {Sftp, Connection} = proplists:get_value(sftp, Config),
ok = ssh_sftp:stop_channel(Sftp),
- catch ssh_sftp:stop_channel(?config(channel_pid2, Config)),
+ catch ssh_sftp:stop_channel(proplists:get_value(channel_pid2, Config)),
ok = ssh:close(Connection).
%%--------------------------------------------------------------------
@@ -310,9 +311,9 @@ end_per_testcase(Config) ->
open_close_file() ->
[{doc, "Test API functions open/3 and close/2"}].
open_close_file(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
+ FileName = proplists:get_value(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
ok = open_close_file(Sftp, FileName, [read]),
ok = open_close_file(Sftp, FileName, [write]),
@@ -329,9 +330,9 @@ open_close_file(Server, File, Mode) ->
open_close_dir() ->
[{doc, "Test API functions opendir/2 and close/2"}].
open_close_dir(Config) when is_list(Config) ->
- PrivDir = ?config(sftp_priv_dir, Config),
- {Sftp, _} = ?config(sftp, Config),
- FileName = ?config(filename, Config),
+ PrivDir = proplists:get_value(sftp_priv_dir, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
{ok, Handle} = ssh_sftp:opendir(Sftp, PrivDir),
ok = ssh_sftp:close(Sftp, Handle),
@@ -341,8 +342,8 @@ open_close_dir(Config) when is_list(Config) ->
read_file() ->
[{doc, "Test API funtion read_file/2"}].
read_file(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Data} = ssh_sftp:read_file(Sftp, FileName),
{ok, Data} = ssh_sftp:read_file(Sftp, FileName),
{ok, Data} = file:read_file(FileName).
@@ -351,8 +352,8 @@ read_file(Config) when is_list(Config) ->
read_dir() ->
[{doc,"Test API function list_dir/2"}].
read_dir(Config) when is_list(Config) ->
- PrivDir = ?config(sftp_priv_dir, Config),
- {Sftp, _} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(sftp_priv_dir, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Files} = ssh_sftp:list_dir(Sftp, PrivDir),
ct:log("sftp list dir: ~p~n", [Files]).
@@ -360,8 +361,8 @@ read_dir(Config) when is_list(Config) ->
write_file() ->
[{doc, "Test API function write_file/2"}].
write_file(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary("Hej hopp!"),
ok = ssh_sftp:write_file(Sftp, FileName, [Data]),
@@ -371,8 +372,8 @@ write_file(Config) when is_list(Config) ->
write_file_iolist() ->
[{doc, "Test API function write_file/2 with iolists"}].
write_file_iolist(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary("Hej hopp!"),
lists:foreach(
@@ -392,8 +393,8 @@ write_file_iolist(Config) when is_list(Config) ->
write_big_file() ->
[{doc, "Test API function write_file/2 with big data"}].
write_big_file(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary(lists:duplicate(750000,"a")),
ok = ssh_sftp:write_file(Sftp, FileName, [Data]),
@@ -403,8 +404,8 @@ write_big_file(Config) when is_list(Config) ->
sftp_read_big_file() ->
[{doc, "Test API function read_file/2 with big data"}].
sftp_read_big_file(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary(lists:duplicate(750000,"a")),
ct:log("Data size to write is ~p bytes",[size(Data)]),
@@ -415,9 +416,9 @@ sftp_read_big_file(Config) when is_list(Config) ->
remove_file() ->
[{doc,"Test API function delete/2"}].
remove_file(Config) when is_list(Config) ->
- PrivDir = ?config(sftp_priv_dir, Config),
- FileName = ?config(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(sftp_priv_dir, Config),
+ FileName = proplists:get_value(filename, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Files} = ssh_sftp:list_dir(Sftp, PrivDir),
true = lists:member(filename:basename(FileName), Files),
@@ -429,11 +430,11 @@ remove_file(Config) when is_list(Config) ->
rename_file() ->
[{doc, "Test API function rename_file/2"}].
rename_file(Config) when is_list(Config) ->
- PrivDir = ?config(sftp_priv_dir, Config),
- FileName = ?config(filename, Config),
- NewFileName = ?config(testfile, Config),
+ PrivDir = proplists:get_value(sftp_priv_dir, Config),
+ FileName = proplists:get_value(filename, Config),
+ NewFileName = proplists:get_value(testfile, Config),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Files} = ssh_sftp:list_dir(Sftp, PrivDir),
ct:log("FileName: ~p, Files: ~p~n", [FileName, Files]),
true = lists:member(filename:basename(FileName), Files),
@@ -449,8 +450,8 @@ rename_file(Config) when is_list(Config) ->
mk_rm_dir() ->
[{doc,"Test API functions make_dir/2, del_dir/2"}].
mk_rm_dir(Config) when is_list(Config) ->
- PrivDir = ?config(sftp_priv_dir, Config),
- {Sftp, _} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(sftp_priv_dir, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
DirName = filename:join(PrivDir, "test"),
ok = ssh_sftp:make_dir(Sftp, DirName),
@@ -467,9 +468,9 @@ links(Config) when is_list(Config) ->
{win32, _} ->
{skip, "Links are not fully supported by windows"};
_ ->
- {Sftp, _} = ?config(sftp, Config),
- FileName = ?config(filename, Config),
- LinkFileName = ?config(linktest, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
+ FileName = proplists:get_value(filename, Config),
+ LinkFileName = proplists:get_value(linktest, Config),
ok = ssh_sftp:make_symlink(Sftp, LinkFileName, FileName),
{ok, FileName} = ssh_sftp:read_link(Sftp, LinkFileName)
@@ -479,9 +480,9 @@ links(Config) when is_list(Config) ->
retrieve_attributes() ->
[{doc, "Test API function read_file_info/3"}].
retrieve_attributes(Config) when is_list(Config) ->
- FileName = ?config(filename, Config),
+ FileName = proplists:get_value(filename, Config),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, FileInfo} = ssh_sftp:read_file_info(Sftp, FileName),
{ok, NewFileInfo} = file:read_file_info(FileName),
@@ -492,9 +493,9 @@ retrieve_attributes(Config) when is_list(Config) ->
set_attributes() ->
[{doc,"Test API function write_file_info/3"}].
set_attributes(Config) when is_list(Config) ->
- FileName = ?config(testfile, Config),
+ FileName = proplists:get_value(testfile, Config),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok,Fd} = file:open(FileName, write),
io:put_chars(Fd,"foo"),
ok = ssh_sftp:write_file_info(Sftp, FileName, #file_info{mode=8#400}),
@@ -507,9 +508,9 @@ set_attributes(Config) when is_list(Config) ->
async_read() ->
[{doc,"Test API aread/3"}].
async_read(Config) when is_list(Config) ->
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
- FileName = ?config(filename, Config),
+ FileName = proplists:get_value(filename, Config),
{ok, Handle} = ssh_sftp:open(Sftp, FileName, [read]),
{async, Ref} = ssh_sftp:aread(Sftp, Handle, 20),
@@ -526,8 +527,8 @@ async_read(Config) when is_list(Config) ->
async_write() ->
[{doc,"Test API awrite/3"}].
async_write(Config) when is_list(Config) ->
- {Sftp, _} = ?config(sftp, Config),
- FileName = ?config(testfile, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
+ FileName = proplists:get_value(testfile, Config),
{ok, Handle} = ssh_sftp:open(Sftp, FileName, [write]),
Data = list_to_binary("foobar"),
{async, Ref} = ssh_sftp:awrite(Sftp, Handle, Data),
@@ -544,8 +545,8 @@ async_write(Config) when is_list(Config) ->
position() ->
[{doc, "Test API functions position/3"}].
position(Config) when is_list(Config) ->
- FileName = ?config(testfile, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(testfile, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary("1234567890"),
ok = ssh_sftp:write_file(Sftp, FileName, [Data]),
@@ -573,8 +574,8 @@ position(Config) when is_list(Config) ->
pos_read() ->
[{doc,"Test API functions pread/3 and apread/3"}].
pos_read(Config) when is_list(Config) ->
- FileName = ?config(testfile, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(testfile, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
Data = list_to_binary("Hej hopp!"),
ok = ssh_sftp:write_file(Sftp, FileName, [Data]),
@@ -600,8 +601,8 @@ pos_read(Config) when is_list(Config) ->
pos_write() ->
[{doc,"Test API functions pwrite/4 and apwrite/4"}].
pos_write(Config) when is_list(Config) ->
- FileName = ?config(testfile, Config),
- {Sftp, _} = ?config(sftp, Config),
+ FileName = proplists:get_value(testfile, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Handle} = ssh_sftp:open(Sftp, FileName, [write]),
@@ -625,12 +626,64 @@ pos_write(Config) when is_list(Config) ->
{ok, NewData1} = ssh_sftp:read_file(Sftp, FileName).
%%--------------------------------------------------------------------
+start_channel_sock(Config) ->
+ LoginOpts =
+ case proplists:get_value(group,Config) of
+ erlang_server ->
+ [{user, proplists:get_value(user, Config)},
+ {password, proplists:get_value(passwd, Config)}];
+ openssh_server ->
+ [] % Use public key
+ end,
+
+ Opts = [{user_interaction, false},
+ {silently_accept_hosts, true}
+ | LoginOpts],
+
+ {Host,Port} = proplists:get_value(peer, Config),
+
+ %% Get a tcp socket
+ {ok, Sock} = gen_tcp:connect(Host, Port, [{active,false}]),
+
+ %% and open one channel on one new Connection
+ {ok, ChPid1, Conn} = ssh_sftp:start_channel(Sock, Opts),
+
+ %% Test that the channel is usable
+ FileName = proplists:get_value(filename, Config),
+ ok = open_close_file(ChPid1, FileName, [read]),
+ ok = open_close_file(ChPid1, FileName, [write]),
+
+ %% Try to open a second channel on the Connection
+ {ok, ChPid2} = ssh_sftp:start_channel(Conn, Opts),
+ ok = open_close_file(ChPid1, FileName, [read]),
+ ok = open_close_file(ChPid2, FileName, [read]),
+
+ %% Test that the second channel still works after closing the first one
+ ok = ssh_sftp:stop_channel(ChPid1),
+ ok = open_close_file(ChPid2, FileName, [write]),
+
+ %% Test the Connection survives that all channels are closed
+ ok = ssh_sftp:stop_channel(ChPid2),
+ {ok, ChPid3} = ssh_sftp:start_channel(Conn, Opts),
+ ok = open_close_file(ChPid3, FileName, [write]),
+
+ %% Test that a closed channel really is closed
+ {error, closed} = ssh_sftp:open(ChPid2, FileName, [write]),
+ ok = ssh_sftp:stop_channel(ChPid3),
+
+ %% Test that the socket is closed when the Connection closes
+ ok = ssh:close(Conn),
+ {error,einval} = inet:getopts(Sock, [active]),
+
+ ok.
+
+%%--------------------------------------------------------------------
sftp_nonexistent_subsystem() ->
[{doc, "Try to execute sftp subsystem on a server that does not support it"}].
sftp_nonexistent_subsystem(Config) when is_list(Config) ->
- {_,Host, Port} = ?config(sftpd, Config),
- User = ?config(user, Config),
- Passwd = ?config(passwd, Config),
+ {_,Host, Port} = proplists:get_value(sftpd, Config),
+ User = proplists:get_value(user, Config),
+ Passwd = proplists:get_value(passwd, Config),
{error,"server failed to start sftp subsystem"} =
ssh_sftp:start_channel(Host, Port,
[{user_interaction, false},
@@ -646,20 +699,20 @@ version_option(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
create_empty_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
erl_tar:close(Handle),
- {ChPid,_} = ?config(sftp,Config),
+ {ChPid,_} = proplists:get_value(sftp,Config),
{ok, #file_info{type=regular}} =
ssh_sftp:read_file_info(ChPid, TarFileName).
%%--------------------------------------------------------------------
files_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
- F1 = ?config(tar_F1_txt, Config),
+ F1 = proplists:get_value(tar_F1_txt, Config),
ok = erl_tar:add(Handle, fn(F1,Config), F1, [verbose]),
ok = erl_tar:add(Handle, fn("f2.txt",Config), "f2.txt", [verbose]),
ok = erl_tar:close(Handle),
@@ -667,8 +720,8 @@ files_to_tar(Config) ->
%%--------------------------------------------------------------------
ascii_filename_ascii_contents_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
ok = erl_tar:add(Handle, fn("f2.txt",Config), "f2.txt", [verbose]),
ok = erl_tar:close(Handle),
@@ -676,12 +729,12 @@ ascii_filename_ascii_contents_to_tar(Config) ->
%%--------------------------------------------------------------------
ascii_filename_unicode_contents_to_tar(Config) ->
- case ?config(tar_F3_txt, Config) of
+ case proplists:get_value(tar_F3_txt, Config) of
undefined ->
{skip, "Unicode test"};
Fn ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
ok = erl_tar:add(Handle, fn(Fn,Config), Fn, [verbose]),
ok = erl_tar:close(Handle),
@@ -690,12 +743,12 @@ ascii_filename_unicode_contents_to_tar(Config) ->
%%--------------------------------------------------------------------
unicode_filename_ascii_contents_to_tar(Config) ->
- case ?config(tar_F4_txt, Config) of
+ case proplists:get_value(tar_F4_txt, Config) of
undefined ->
{skip, "Unicode test"};
Fn ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
ok = erl_tar:add(Handle, fn(Fn,Config), Fn, [verbose]),
ok = erl_tar:close(Handle),
@@ -704,8 +757,8 @@ unicode_filename_ascii_contents_to_tar(Config) ->
%%--------------------------------------------------------------------
big_file_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
ok = erl_tar:add(Handle, fn("big.txt",Config), "big.txt", [verbose]),
ok = erl_tar:close(Handle),
@@ -714,18 +767,18 @@ big_file_to_tar(Config) ->
%%--------------------------------------------------------------------
files_chunked_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
- F1 = ?config(tar_F1_txt, Config),
+ F1 = proplists:get_value(tar_F1_txt, Config),
ok = erl_tar:add(Handle, fn(F1,Config), F1, [verbose,{chunks,2}]),
ok = erl_tar:close(Handle),
chk_tar([F1], Config).
%%--------------------------------------------------------------------
directory_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
ok = erl_tar:add(Handle, fn("d1",Config), "d1", [verbose]),
ok = erl_tar:close(Handle),
@@ -733,8 +786,8 @@ directory_to_tar(Config) ->
%%--------------------------------------------------------------------
binaries_to_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
- TarFileName = ?config(tar_filename, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
Bin = <<"A binary">>,
ok = erl_tar:add(Handle, Bin, "b1", [verbose]),
@@ -743,15 +796,15 @@ binaries_to_tar(Config) ->
%%--------------------------------------------------------------------
null_crypto_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
Cinit = fun() -> {ok, no_state, _SendSize=5} end,
Cenc = fun(Bin,CState) -> {ok,Bin,CState,_SendSize=5} end,
Cend = fun(Bin,_CState) -> {ok,Bin} end,
C = {Cinit,Cenc,Cend},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,C}]),
Bin = <<"A binary">>,
- F1 = ?config(tar_F1_txt, Config),
+ F1 = proplists:get_value(tar_F1_txt, Config),
ok = erl_tar:add(Handle, Bin, "b1", [verbose]),
ok = erl_tar:add(Handle, fn(F1,Config), F1, [verbose,{chunks,2}]),
ok = erl_tar:add(Handle, fn("big.txt",Config), "big.txt", [verbose,{chunks,15000}]),
@@ -760,16 +813,16 @@ null_crypto_tar(Config) ->
%%--------------------------------------------------------------------
simple_crypto_tar_small(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
Cinit = fun() -> {ok, no_state, _Size=6} end,
Cenc = fun(Bin,CState) -> {ok,stuff(Bin),CState,_SendSize=5} end,
Cdec = fun(Bin,CState) -> {ok,unstuff(Bin),CState,_Size=4} end,
Cend = fun(Bin,_CState) -> {ok,stuff(Bin)} end,
C = {Cinit,Cenc,Cend},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,C}]),
Bin = <<"A binary">>,
- F1 = ?config(tar_F1_txt, Config),
+ F1 = proplists:get_value(tar_F1_txt, Config),
ok = erl_tar:add(Handle, Bin, "b1", [verbose]),
ok = erl_tar:add(Handle, fn(F1,Config), F1, [verbose,{chunks,2}]),
ok = erl_tar:close(Handle),
@@ -777,16 +830,16 @@ simple_crypto_tar_small(Config) ->
%%--------------------------------------------------------------------
simple_crypto_tar_big(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
Cinit = fun() -> {ok, no_state, _SendSize=6} end,
Cenc = fun(Bin,CState) -> {ok,stuff(Bin),CState,_SendSize=5} end,
Cdec = fun(Bin,CState) -> {ok,unstuff(Bin),CState,_SendSize=4} end,
Cend = fun(Bin,_CState) -> {ok,stuff(Bin)} end,
C = {Cinit,Cenc,Cend},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,Handle} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,C}]),
Bin = <<"A binary">>,
- F1 = ?config(tar_F1_txt, Config),
+ F1 = proplists:get_value(tar_F1_txt, Config),
ok = erl_tar:add(Handle, Bin, "b1", [verbose]),
ok = erl_tar:add(Handle, fn(F1,Config), F1, [verbose,{chunks,2}]),
ok = erl_tar:add(Handle, fn("big.txt",Config), "big.txt", [verbose,{chunks,15000}]),
@@ -799,12 +852,12 @@ unstuff(Bin) -> << <<C>> || <<C,C>> <= Bin >>.
%%--------------------------------------------------------------------
read_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
NameBins = lists:sort(
[{"b1",<<"A binary">>},
{"b2",list_to_binary(lists:duplicate(750000,"a"))}
]),
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,HandleWrite} = ssh_sftp:open_tar(ChPid2, TarFileName, [write]),
[ok = erl_tar:add(HandleWrite, Bin, Name, [verbose])
|| {Name,Bin} <- NameBins],
@@ -814,7 +867,7 @@ read_tar(Config) ->
%%--------------------------------------------------------------------
read_null_crypto_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
NameBins = lists:sort(
[{"b1",<<"A binary">>},
{"b2",list_to_binary(lists:duplicate(750000,"a"))}
@@ -827,7 +880,7 @@ read_null_crypto_tar(Config) ->
Cw = {Cinitw,Cenc,Cendw},
Cr = {Cinitr,Cdec},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,HandleWrite} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,Cw}]),
[ok = erl_tar:add(HandleWrite, Bin, Name, [verbose])
|| {Name,Bin} <- NameBins],
@@ -837,7 +890,7 @@ read_null_crypto_tar(Config) ->
%%--------------------------------------------------------------------
read_crypto_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
NameBins = lists:sort(
[{"b1",<<"A binary">>},
{"b2",list_to_binary(lists:duplicate(750000,"a"))}
@@ -851,7 +904,7 @@ read_crypto_tar(Config) ->
Cw = {Cinitw,Cenc,Cendw},
Cr = {Cinitr,Cdec},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,HandleWrite} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,Cw}]),
[ok = erl_tar:add(HandleWrite, Bin, Name, [verbose])
|| {Name,Bin} <- NameBins],
@@ -861,7 +914,7 @@ read_crypto_tar(Config) ->
%%--------------------------------------------------------------------
aes_cbc256_crypto_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
NameBins = lists:sort(
[{"b1",<<"A binary">>},
{"b2",list_to_binary(lists:duplicate(750000,"a"))},
@@ -891,7 +944,7 @@ aes_cbc256_crypto_tar(Config) ->
end,
Cw = {Cinitw,Cenc,Cendw},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,HandleWrite} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,Cw}]),
[ok = erl_tar:add(HandleWrite, Bin, Name, [verbose]) || {Name,Bin} <- NameBins],
ok = erl_tar:close(HandleWrite),
@@ -906,7 +959,7 @@ pad(BlockSize, Bin) ->
%%--------------------------------------------------------------------
aes_ctr_stream_crypto_tar(Config) ->
- ChPid2 = ?config(channel_pid2, Config),
+ ChPid2 = proplists:get_value(channel_pid2, Config),
NameBins = lists:sort(
[{"b1",<<"A binary">>},
{"b2",list_to_binary(lists:duplicate(750000,"a"))},
@@ -934,7 +987,7 @@ aes_ctr_stream_crypto_tar(Config) ->
end,
Cw = {Cinitw,Cenc,Cendw},
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
{ok,HandleWrite} = ssh_sftp:open_tar(ChPid2, TarFileName, [write,{crypto,Cw}]),
[ok = erl_tar:add(HandleWrite, Bin, Name, [verbose]) || {Name,Bin} <- NameBins],
ok = erl_tar:close(HandleWrite),
@@ -946,11 +999,11 @@ aes_ctr_stream_crypto_tar(Config) ->
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
oldprep(Config) ->
- DataDir = ?config(data_dir, Config),
- TestFile = ?config(filename, Config),
- TestFile1 = ?config(testfile, Config),
- TestLink = ?config(linktest, Config),
- TarFileName = ?config(tar_filename, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ TestFile = proplists:get_value(filename, Config),
+ TestFile1 = proplists:get_value(testfile, Config),
+ TestLink = proplists:get_value(linktest, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
file:delete(TestFile),
file:delete(TestFile1),
@@ -999,12 +1052,12 @@ chk_tar(Items, Config) ->
chk_tar(Items, Config, []).
chk_tar(Items, Config, Opts) ->
- TarFileName = ?config(tar_filename, Config),
+ TarFileName = proplists:get_value(tar_filename, Config),
chk_tar(Items, TarFileName, Config, Opts).
chk_tar(Items, TarFileName, Config, Opts) when is_list(Opts) ->
tar_size(TarFileName, Config),
- {ChPid,_} = ?config(sftp,Config),
+ {ChPid,_} = proplists:get_value(sftp,Config),
{ok,HandleRead} = ssh_sftp:open_tar(ChPid, TarFileName, [read|Opts]),
{ok,NameValueList} = erl_tar:extract(HandleRead,[memory,verbose]),
ok = erl_tar:close(HandleRead),
@@ -1046,7 +1099,7 @@ analyze_report([], []) ->
"".
tar_size(TarFileName, Config) ->
- {ChPid,_} = ?config(sftp,Config),
+ {ChPid,_} = proplists:get_value(sftp,Config),
{ok,Data} = ssh_sftp:read_file(ChPid, TarFileName),
io:format('Tar file ~p is~n ~p bytes.~n',[TarFileName, size(Data)]).
@@ -1073,7 +1126,7 @@ read_item_contents(ItemName, FileName) ->
end.
fn(Name, Config) ->
- Dir = ?config(datadir_tar, Config),
+ Dir = proplists:get_value(datadir_tar, Config),
filename:join(Dir,Name).
fmt_host({A,B,C,D}) -> lists:concat([A,".",B,".",C,".",D]);
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index 9385bd127d..4a69fd36b3 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -72,19 +72,19 @@ groups() ->
%%--------------------------------------------------------------------
init_per_suite(Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa(DataDir, PrivDir),
%% to make sure we don't use public-key-auth
%% this should be tested by other test suites
- UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), nopubkey),
file:make_dir(UserDir),
Config.
end_per_suite(Config) ->
- SysDir = ?config(priv_dir, Config),
+ SysDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(SysDir),
- UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), nopubkey),
file:del_dir(UserDir),
ssh:stop().
@@ -101,9 +101,9 @@ end_per_group(_GroupName, Config) ->
init_per_testcase(TestCase, Config) ->
ssh:start(),
prep(Config),
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
ClientUserDir = filename:join(PrivDir, nopubkey),
- SystemDir = filename:join(?config(priv_dir, Config), system),
+ SystemDir = filename:join(proplists:get_value(priv_dir, Config), system),
Options = [{system_dir, SystemDir},
{user_dir, PrivDir},
@@ -154,8 +154,8 @@ init_per_testcase(TestCase, Config) ->
[{sftp, {Cm, Channel}}, {sftpd, Sftpd }| Config].
end_per_testcase(_TestCase, Config) ->
- ssh_sftpd:stop(?config(sftpd, Config)),
- {Cm, Channel} = ?config(sftp, Config),
+ ssh_sftpd:stop(proplists:get_value(sftpd, Config)),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
ssh_connection:close(Cm, Channel),
ssh:close(Cm),
ssh:stop().
@@ -166,9 +166,9 @@ end_per_testcase(_TestCase, Config) ->
open_close_file() ->
[{doc, "Test SSH_FXP_OPEN and SSH_FXP_CLOSE commands"}].
open_close_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
ReqId = 0,
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
@@ -196,9 +196,9 @@ open_close_file(Config) when is_list(Config) ->
ver3_open_flags() ->
[{doc, "Test open flags"}].
ver3_open_flags(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "not_exist.txt"),
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
ReqId = 0,
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
@@ -230,8 +230,8 @@ ver3_open_flags(Config) when is_list(Config) ->
open_close_dir() ->
[{doc,"Test SSH_FXP_OPENDIR and SSH_FXP_CLOSE commands"}].
open_close_dir(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
- {Cm, Channel} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
@@ -257,11 +257,11 @@ open_close_dir(Config) when is_list(Config) ->
read_file() ->
[{doc, "Test SSH_FXP_READ command"}].
read_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
open_file(FileName, Cm, Channel, ReqId,
@@ -280,8 +280,8 @@ read_file(Config) when is_list(Config) ->
read_dir() ->
[{doc,"Test SSH_FXP_READDIR command"}].
read_dir(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
- {Cm, Channel} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
ReqId = 0,
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
open_dir(PrivDir, Cm, Channel, ReqId),
@@ -291,11 +291,11 @@ read_dir(Config) when is_list(Config) ->
write_file() ->
[{doc, "Test SSH_FXP_WRITE command"}].
write_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
open_file(FileName, Cm, Channel, ReqId,
@@ -315,10 +315,10 @@ write_file(Config) when is_list(Config) ->
remove_file() ->
[{doc, "Test SSH_FXP_REMOVE command"}].
remove_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId),
?UINT32(?SSH_FX_OK), _/binary>>, _} =
@@ -336,11 +336,11 @@ remove_file(Config) when is_list(Config) ->
rename_file() ->
[{doc, "Test SSH_FXP_RENAME command"}].
rename_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
NewFileName = filename:join(PrivDir, "test1.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId),
?UINT32(?SSH_FX_OK), _/binary>>, _} =
@@ -373,8 +373,8 @@ rename_file(Config) when is_list(Config) ->
mk_rm_dir() ->
[{doc, "Test SSH_FXP_MKDIR and SSH_FXP_RMDIR command"}].
mk_rm_dir(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
- {Cm, Channel} = ?config(sftp, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
DirName = filename:join(PrivDir, "test"),
ReqId = 0,
{ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId), ?UINT32(?SSH_FX_OK),
@@ -401,8 +401,8 @@ real_path(Config) when is_list(Config) ->
{skip, "Not a relevant test on windows"};
_ ->
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
- PrivDir = ?config(priv_dir, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
TestDir = filename:join(PrivDir, "ssh_test"),
ok = file:make_dir(TestDir),
@@ -427,8 +427,8 @@ links(Config) when is_list(Config) ->
{skip, "Links are not fully supported by windows"};
_ ->
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
- PrivDir = ?config(priv_dir, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
LinkFileName = filename:join(PrivDir, "link_test.txt"),
@@ -451,10 +451,10 @@ links(Config) when is_list(Config) ->
retrieve_attributes() ->
[{"Test SSH_FXP_STAT, SSH_FXP_LSTAT AND SSH_FXP_FSTAT commands"}].
retrieve_attributes(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, FileInfo} = file:read_file_info(FileName),
@@ -520,10 +520,10 @@ set_attributes(Config) when is_list(Config) ->
{win32, _} ->
{skip, "Known error bug in erts file:read_file_info"};
_ ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, FileInfo} = file:read_file_info(FileName),
@@ -574,11 +574,11 @@ set_attributes(Config) when is_list(Config) ->
ver3_rename() ->
[{doc, "Test that ver3 rename message is handled OTP 6352"}].
ver3_rename(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
NewFileName = filename:join(PrivDir, "test1.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId),
?UINT32(?SSH_FX_OK), _/binary>>, _} =
@@ -589,7 +589,7 @@ relpath() ->
[{doc, "Check that realpath works ok seq10670"}].
relpath(Config) when is_list(Config) ->
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
case os:type() of
{win32, _} ->
@@ -611,11 +611,11 @@ relpath(Config) when is_list(Config) ->
sshd_read_file() ->
[{doc,"Test SSH_FXP_READ command, using sshd-server"}].
sshd_read_file(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(PrivDir, "test.txt"),
ReqId = 0,
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
{ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId), Handle/binary>>, _} =
open_file(FileName, Cm, Channel, ReqId,
@@ -633,9 +633,9 @@ sshd_read_file(Config) when is_list(Config) ->
ver6_basic() ->
[{doc, "Test SFTP Version 6"}].
ver6_basic(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
%FileName = filename:join(PrivDir, "test.txt"),
- {Cm, Channel} = ?config(sftp, Config),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
ReqId = 0,
{ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId), % Ver 6 we have 5
?UINT32(?SSH_FX_FILE_IS_A_DIRECTORY), _/binary>>, _} =
@@ -646,7 +646,7 @@ ver6_basic(Config) when is_list(Config) ->
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
prep(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
TestFile = filename:join(PrivDir, "test.txt"),
TestFile1 = filename:join(PrivDir, "test1.txt"),
@@ -654,7 +654,7 @@ prep(Config) ->
file:delete(TestFile1),
%% Initial config
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
FileName = filename:join(DataDir, "test.txt"),
file:copy(FileName, TestFile),
Mode = 8#00400 bor 8#00200 bor 8#00040, % read & write owner, read group
diff --git a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
index 355ce6a8f5..75b5090c2b 100644
--- a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
@@ -54,8 +54,8 @@ groups() ->
init_per_suite(Config) ->
catch ssh:stop(),
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileAlt = filename:join(DataDir, "ssh_sftpd_file_alt.erl"),
c:c(FileAlt),
FileName = filename:join(DataDir, "test.txt"),
@@ -66,9 +66,9 @@ init_per_suite(Config) ->
Config.
end_per_suite(Config) ->
- UserDir = filename:join(?config(priv_dir, Config), nopubkey),
+ UserDir = filename:join(proplists:get_value(priv_dir, Config), nopubkey),
file:del_dir(UserDir),
- SysDir = ?config(priv_dir, Config),
+ SysDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(SysDir),
ok.
@@ -83,7 +83,7 @@ end_per_group(_GroupName, Config) ->
init_per_testcase(TestCase, Config) ->
ssh:start(),
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
SystemDir = filename:join(PrivDir, system),
Options =
@@ -96,7 +96,7 @@ init_per_testcase(TestCase, Config) ->
{user_dir, PrivDir},
{subsystems, [Spec]}];
"root_dir" ->
- Privdir = ?config(priv_dir, Config),
+ Privdir = proplists:get_value(priv_dir, Config),
Root = filename:join(Privdir, root),
file:make_dir(Root),
Spec = ssh_sftpd:subsystem_spec([{root,Root}]),
@@ -132,8 +132,8 @@ init_per_testcase(TestCase, Config) ->
[{port, Port}, {sftp, {ChannelPid, Connection}}, {sftpd, Sftpd} | NewConfig].
end_per_testcase(_TestCase, Config) ->
- catch ssh_sftpd:stop(?config(sftpd, Config)),
- {Sftp, Connection} = ?config(sftp, Config),
+ catch ssh_sftpd:stop(proplists:get_value(sftpd, Config)),
+ {Sftp, Connection} = proplists:get_value(sftp, Config),
catch ssh_sftp:stop_channel(Sftp),
catch ssh:close(Connection),
ssh:stop().
@@ -146,10 +146,10 @@ close_file() ->
"transfer OTP-6350"}].
close_file(Config) when is_list(Config) ->
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
FileName = filename:join(DataDir, "test.txt"),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
NumOfPorts = length(erlang:ports()),
@@ -167,12 +167,12 @@ quit() ->
"client hanging. OTP-6349"}].
quit(Config) when is_list(Config) ->
- DataDir = ?config(data_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
FileName = filename:join(DataDir, "test.txt"),
- UserDir = ?config(priv_dir, Config),
- Port = ?config(port, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
+ Port = proplists:get_value(port, Config),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, <<_/binary>>} = ssh_sftp:read_file(Sftp, FileName),
@@ -198,13 +198,13 @@ file_cb() ->
" the sftpds filehandling. OTP-6356"}].
file_cb(Config) when is_list(Config) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FileName = filename:join(DataDir, "test.txt"),
register(sftpd_file_alt_tester, self()),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Bin} = ssh_sftp:read_file(Sftp, FileName),
alt_file_handler_check(alt_open),
@@ -242,7 +242,7 @@ file_cb(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
root_dir(Config) when is_list(Config) ->
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
FileName = "test.txt",
Bin = <<"Test file for root dir option">>,
ok = ssh_sftp:write_file(Sftp, FileName, Bin),
@@ -253,7 +253,7 @@ root_dir(Config) when is_list(Config) ->
%%--------------------------------------------------------------------
list_dir_limited(Config) when is_list(Config) ->
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
{ok, Listing} =
ssh_sftp:list_dir(Sftp, "."),
ct:log("Listing: ~p~n", [Listing]).
@@ -262,9 +262,9 @@ list_dir_limited(Config) when is_list(Config) ->
ver6_basic() ->
[{doc, "Test some version 6 features"}].
ver6_basic(Config) when is_list(Config) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
NewDir = filename:join(PrivDir, "testdir2"),
- {Sftp, _} = ?config(sftp, Config),
+ {Sftp, _} = proplists:get_value(sftp, Config),
ok = ssh_sftp:make_dir(Sftp, NewDir),
%%Test file_is_a_directory
{error, file_is_a_directory} = ssh_sftp:delete(Sftp, NewDir).
diff --git a/lib/ssh/test/ssh_sup_SUITE.erl b/lib/ssh/test/ssh_sup_SUITE.erl
index f8929b30ff..574564f6e9 100644
--- a/lib/ssh/test/ssh_sup_SUITE.erl
+++ b/lib/ssh/test/ssh_sup_SUITE.erl
@@ -54,7 +54,7 @@ end_per_group(_GroupName, Config) ->
init_per_suite(Config) ->
Port = ssh_test_lib:inet_port(node()),
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
[{userdir, UserDir},{port, Port}, {host, "localhost"}, {host_ip, any} | Config].
@@ -64,7 +64,7 @@ end_per_suite(_) ->
init_per_testcase(sshc_subtree, Config) ->
ssh:start(),
- SystemDir = ?config(data_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{failfun, fun ssh_test_lib:failfun/2},
{user_passwords,
@@ -75,7 +75,7 @@ init_per_testcase(Case, Config) ->
ssh:start(),
Config.
end_per_testcase(sshc_subtree, Config) ->
- {Pid,_,_} = ?config(server, Config),
+ {Pid,_,_} = proplists:get_value(server, Config),
ssh:stop_daemon(Pid),
ssh:stop();
end_per_testcase(_, _Config) ->
@@ -100,8 +100,8 @@ default_tree(Config) when is_list(Config) ->
sshc_subtree() ->
[{doc, "Make sure the sshc subtree is correct"}].
sshc_subtree(Config) when is_list(Config) ->
- {_Pid, Host, Port} = ?config(server, Config),
- UserDir = ?config(userdir, Config),
+ {_Pid, Host, Port} = proplists:get_value(server, Config),
+ UserDir = proplists:get_value(userdir, Config),
?wait_match([], supervisor:which_children(sshc_sup)),
@@ -128,9 +128,9 @@ sshc_subtree(Config) when is_list(Config) ->
sshd_subtree() ->
[{doc, "Make sure the sshd subtree is correct"}].
sshd_subtree(Config) when is_list(Config) ->
- HostIP = ?config(host_ip, Config),
- Port = ?config(port, Config),
- SystemDir = ?config(data_dir, Config),
+ HostIP = proplists:get_value(host_ip, Config),
+ Port = proplists:get_value(port, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
ssh:daemon(HostIP, Port, [{system_dir, SystemDir},
{failfun, fun ssh_test_lib:failfun/2},
{user_passwords,
@@ -149,10 +149,10 @@ sshd_subtree(Config) when is_list(Config) ->
sshd_subtree_profile() ->
[{doc, "Make sure the sshd subtree using profile option is correct"}].
sshd_subtree_profile(Config) when is_list(Config) ->
- HostIP = ?config(host_ip, Config),
- Port = ?config(port, Config),
- Profile = ?config(profile, Config),
- SystemDir = ?config(data_dir, Config),
+ HostIP = proplists:get_value(host_ip, Config),
+ Port = proplists:get_value(port, Config),
+ Profile = proplists:get_value(profile, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
{ok, _} = ssh:daemon(HostIP, Port, [{system_dir, SystemDir},
{failfun, fun ssh_test_lib:failfun/2},
@@ -171,9 +171,9 @@ sshd_subtree_profile(Config) when is_list(Config) ->
check_sshd_system_tree(Daemon, Config) ->
- Host = ?config(host, Config),
- Port = ?config(port, Config),
- UserDir = ?config(userdir, Config),
+ Host = proplists:get_value(host, Config),
+ Port = proplists:get_value(port, Config),
+ UserDir = proplists:get_value(userdir, Config),
{ok, Client} = ssh:connect(Host, Port, [{silently_accept_hosts, true},
{user_interaction, false},
{user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]),
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index a1291146e4..6233680dce 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -71,7 +71,7 @@ daemon_port(Port, _) -> Port.
std_daemon(Config, ExtraOpts) ->
- PrivDir = ?config(priv_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth
file:make_dir(UserDir),
std_daemon1(Config,
@@ -80,13 +80,13 @@ std_daemon(Config, ExtraOpts) ->
{user_passwords, [{"usr1","pwd1"}]}]).
std_daemon1(Config, ExtraOpts) ->
- SystemDir = ?config(data_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
{_Server, _Host, _Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{failfun, fun ssh_test_lib:failfun/2}
| ExtraOpts]).
std_connect(Config, Host, Port, ExtraOpts) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
_ConnectionRef =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
{user_dir, UserDir},
@@ -99,7 +99,7 @@ std_simple_sftp(Host, Port, Config) ->
std_simple_sftp(Host, Port, Config, []).
std_simple_sftp(Host, Port, Config, Opts) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
DataFile = filename:join(UserDir, "test.data"),
ConnectionRef = ssh_test_lib:std_connect(Config, Host, Port, Opts),
{ok, ChannelRef} = ssh_sftp:start_channel(ConnectionRef),
diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl
index 2be75fd7f3..f96a2cc62b 100644
--- a/lib/ssh/test/ssh_to_openssh_SUITE.erl
+++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl
@@ -73,8 +73,8 @@ end_per_suite(_Config) ->
ok.
init_per_group(erlang_server, Config) ->
- DataDir = ?config(data_dir, Config),
- UserDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:setup_dsa_known_host(DataDir, UserDir),
ssh_test_lib:setup_rsa_known_host(DataDir, UserDir),
Config;
@@ -87,7 +87,7 @@ init_per_group(_, Config) ->
Config.
end_per_group(erlang_server, Config) ->
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_dsa(UserDir),
ssh_test_lib:clean_rsa(UserDir),
Config;
@@ -222,7 +222,7 @@ erlang_client_openssh_server_kexs() ->
[{doc, "Test that we can connect with different KEXs."}].
erlang_client_openssh_server_kexs(Config) when is_list(Config) ->
- KexAlgos = try proplists:get_value(kex, ?config(common_algs,Config))
+ KexAlgos = try proplists:get_value(kex, proplists:get_value(common_algs,Config))
catch _:_ -> []
end,
comment(KexAlgos),
@@ -366,8 +366,8 @@ erlang_server_openssh_client_public_key_rsa(Config) when is_list(Config) ->
erlang_server_openssh_client_public_key_X(Config, PubKeyAlg) ->
- SystemDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ SystemDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
KnownHosts = filename:join(PrivDir, "known_hosts"),
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SystemDir},
{public_key_alg, PubKeyAlg},
@@ -387,7 +387,7 @@ erlang_client_openssh_server_password() ->
[{doc, "Test client password option"}].
erlang_client_openssh_server_password(Config) when is_list(Config) ->
%% to make sure we don't public-key-auth
- UserDir = ?config(data_dir, Config),
+ UserDir = proplists:get_value(data_dir, Config),
{error, Reason0} =
ssh:connect(any, ?SSH_DEFAULT_PORT, [{silently_accept_hosts, true},
{user, "foo"},
diff --git a/lib/ssh/test/ssh_upgrade_SUITE.erl b/lib/ssh/test/ssh_upgrade_SUITE.erl
index 06bef2455e..9d9b2b78fb 100644
--- a/lib/ssh/test/ssh_upgrade_SUITE.erl
+++ b/lib/ssh/test/ssh_upgrade_SUITE.erl
@@ -59,7 +59,7 @@ init_per_suite(Config0) ->
end_per_suite(Config) ->
ct_release_test:cleanup(Config),
ssh:stop(),
- UserDir = ?config(priv_dir, Config),
+ UserDir = proplists:get_value(priv_dir, Config),
ssh_test_lib:clean_rsa(UserDir).
init_per_testcase(_TestCase, Config) ->
@@ -138,8 +138,8 @@ test_soft(State0, FileName) ->
setup_server_client(#state{config=Config} = State) ->
- DataDir = ?config(data_dir, Config),
- PrivDir = ?config(priv_dir, Config),
+ DataDir = proplists:get_value(data_dir, Config),
+ PrivDir = proplists:get_value(priv_dir, Config),
FtpRootDir = filename:join(PrivDir, "ftp_root"),
catch file:make_dir(FtpRootDir),
diff --git a/lib/ssl/doc/src/ssl_distribution.xml b/lib/ssl/doc/src/ssl_distribution.xml
index 7c00b4eae2..495e02d271 100644
--- a/lib/ssl/doc/src/ssl_distribution.xml
+++ b/lib/ssl/doc/src/ssl_distribution.xml
@@ -196,6 +196,9 @@ Eshell V5.0 (abort with ^G)
<item><c>password</c></item>
<item><c>cacertfile</c></item>
<item><c>verify</c></item>
+ <item><c>verify_fun</c> (write as <c>{Module, Function, InitialUserState}</c>)</item>
+ <item><c>crl_check</c></item>
+ <item><c>crl_cache</c> (write as Erlang term)</item>
<item><c>reuse_sessions</c></item>
<item><c>secure_renegotiate</c></item>
<item><c>depth</c></item>
@@ -203,6 +206,10 @@ Eshell V5.0 (abort with ^G)
<item><c>ciphers</c> (use old string format)</item>
</list>
+ <p>Note that <c>verify_fun</c> needs to be written in a different
+ form than the corresponding SSL option, since funs are not
+ accepted on the command line.</p>
+
<p>The server can also take the options <c>dhfile</c> and
<c>fail_if_no_peer_cert</c> (also prefixed).</p>
@@ -210,10 +217,6 @@ Eshell V5.0 (abort with ^G)
initiates a connection to another node. <c>server_</c>-prefixed
options are used when accepting a connection from a remote node.</p>
- <p>More complex options, such as <c>verify_fun</c>, are currently not
- available, but a mechanism to handle such options may be added in
- a future release.</p>
-
<p>Raw socket options, such as <c>packet</c> and <c>size</c> must not
be specified on the command line.</p>
diff --git a/lib/ssl/src/ssl.app.src b/lib/ssl/src/ssl.app.src
index 1a2bf90ccf..937a3b1bd1 100644
--- a/lib/ssl/src/ssl.app.src
+++ b/lib/ssl/src/ssl.app.src
@@ -54,7 +54,7 @@
{applications, [crypto, public_key, kernel, stdlib]},
{env, []},
{mod, {ssl_app, []}},
- {runtime_dependencies, ["stdlib-2.0","public_key-1.0","kernel-3.0",
+ {runtime_dependencies, ["stdlib-3.0","public_key-1.0","kernel-3.0",
"erts-7.0","crypto-3.3", "inets-5.10.7"]}]}.
diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl
index 5dc2e583a5..33d5c1c6d6 100644
--- a/lib/ssl/src/ssl.erl
+++ b/lib/ssl/src/ssl.erl
@@ -97,7 +97,7 @@ connect(Socket, SslOptions) when is_port(Socket) ->
connect(Socket, SslOptions, infinity).
connect(Socket, SslOptions0, Timeout) when is_port(Socket),
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
{Transport,_,_,_} = proplists:get_value(cb_info, SslOptions0,
{gen_tcp, tcp, tcp_closed, tcp_error}),
EmulatedOptions = ssl_socket:emulated_options(),
@@ -123,7 +123,7 @@ connect(Socket, SslOptions0, Timeout) when is_port(Socket),
connect(Host, Port, Options) ->
connect(Host, Port, Options, infinity).
-connect(Host, Port, Options, Timeout) when (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+connect(Host, Port, Options, Timeout) when (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
try handle_options(Options, client) of
{ok, Config} ->
do_connect(Host,Port,Config,Timeout)
@@ -173,7 +173,7 @@ transport_accept(#sslsocket{pid = {ListenSocket,
#config{transport_info = {Transport,_,_, _} =CbInfo,
connection_cb = ConnectionCb,
ssl = SslOpts,
- emulated = Tracker}}}, Timeout) when (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+ emulated = Tracker}}}, Timeout) when (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
case Transport:accept(ListenSocket, Timeout) of
{ok, Socket} ->
{ok, EmOpts} = ssl_socket:get_emulated_opts(Tracker),
@@ -206,25 +206,25 @@ transport_accept(#sslsocket{pid = {ListenSocket,
ssl_accept(ListenSocket) ->
ssl_accept(ListenSocket, infinity).
-ssl_accept(#sslsocket{} = Socket, Timeout) when (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+ssl_accept(#sslsocket{} = Socket, Timeout) when (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
ssl_connection:handshake(Socket, Timeout);
-
-ssl_accept(ListenSocket, SslOptions) when is_port(ListenSocket) ->
+
+ssl_accept(ListenSocket, SslOptions) when is_port(ListenSocket) ->
ssl_accept(ListenSocket, SslOptions, infinity).
-ssl_accept(#sslsocket{} = Socket, [], Timeout) when (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity)->
+ssl_accept(#sslsocket{} = Socket, [], Timeout) when (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity)->
ssl_accept(#sslsocket{} = Socket, Timeout);
-ssl_accept(#sslsocket{fd = {_, _, _, Tracker}} = Socket, SslOpts0, Timeout) when
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity)->
- try
- {ok, EmOpts, InheritedSslOpts} = ssl_socket:get_all_opts(Tracker),
+ssl_accept(#sslsocket{fd = {_, _, _, Tracker}} = Socket, SslOpts0, Timeout) when
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity)->
+ try
+ {ok, EmOpts, InheritedSslOpts} = ssl_socket:get_all_opts(Tracker),
SslOpts = handle_options(SslOpts0, InheritedSslOpts),
ssl_connection:handshake(Socket, {SslOpts, emulated_socket_options(EmOpts, #socket_options{})}, Timeout)
catch
Error = {error, _Reason} -> Error
end;
ssl_accept(Socket, SslOptions, Timeout) when is_port(Socket),
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
{Transport,_,_,_} =
proplists:get_value(cb_info, SslOptions, {gen_tcp, tcp, tcp_closed, tcp_error}),
EmulatedOptions = ssl_socket:emulated_options(),
@@ -252,17 +252,17 @@ close(#sslsocket{pid = {ListenSocket, #config{transport_info={Transport,_, _, _}
Transport:close(ListenSocket).
%%--------------------------------------------------------------------
--spec close(#sslsocket{}, integer() | {pid(), integer()}) -> term().
+-spec close(#sslsocket{}, timeout() | {pid(), integer()}) -> term().
%%
%% Description: Close an ssl connection
%%--------------------------------------------------------------------
-close(#sslsocket{pid = TLSPid},
- {Pid, Timeout} = DownGrade) when is_pid(TLSPid),
- is_pid(Pid),
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+close(#sslsocket{pid = TLSPid},
+ {Pid, Timeout} = DownGrade) when is_pid(TLSPid),
+ is_pid(Pid),
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
ssl_connection:close(TLSPid, {close, DownGrade});
-close(#sslsocket{pid = TLSPid}, Timeout) when is_pid(TLSPid),
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity) ->
+close(#sslsocket{pid = TLSPid}, Timeout) when is_pid(TLSPid),
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity) ->
ssl_connection:close(TLSPid, {close, Timeout});
close(#sslsocket{pid = {ListenSocket, #config{transport_info={Transport,_, _, _}}}}, _) ->
Transport:close(ListenSocket).
@@ -286,7 +286,7 @@ send(#sslsocket{pid = {ListenSocket, #config{transport_info={Transport, _, _, _}
recv(Socket, Length) ->
recv(Socket, Length, infinity).
recv(#sslsocket{pid = Pid}, Length, Timeout) when is_pid(Pid),
- (is_integer(Timeout) andalso Timeout > 0) or (Timeout == infinity)->
+ (is_integer(Timeout) andalso Timeout >= 0) or (Timeout == infinity)->
ssl_connection:recv(Pid, Length, Timeout);
recv(#sslsocket{pid = {Listen,
#config{transport_info = {Transport, _, _, _}}}}, _,_) when is_port(Listen)->
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 22d107ff9c..b45c5c8fc6 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -786,12 +786,24 @@ downgrade(Type, Event, State, Connection) ->
%% Event handling functions called by state functions to handle
%% common or unexpected events for the state.
%%--------------------------------------------------------------------
+handle_common_event(internal, {handshake, {#hello_request{} = Handshake, _}}, connection = StateName,
+ #state{role = client} = State, _) ->
+ %% Should not be included in handshake history
+ {next_state, StateName, State#state{renegotiation = {true, peer}}, [{next_event, internal, Handshake}]};
+handle_common_event(internal, {handshake, {#hello_request{}, _}}, StateName, #state{role = client}, _)
+ when StateName =/= connection ->
+ {keep_state_and_data};
+handle_common_event(internal, {handshake, {Handshake, Raw}}, StateName,
+ #state{tls_handshake_history = Hs0} = State0, Connection) ->
+ %% This function handles client SNI hello extension when Handshake is
+ %% a client_hello, which needs to be determined by the connection callback.
+ %% In other cases this is a noop
+ State = Connection:handle_sni_extension(Handshake, State0),
+ HsHist = ssl_handshake:update_handshake_history(Hs0, Raw),
+ {next_state, StateName, State#state{tls_handshake_history = HsHist},
+ [{next_event, internal, Handshake}]};
handle_common_event(internal, {tls_record, TLSRecord}, StateName, State, Connection) ->
Connection:handle_common_event(internal, TLSRecord, StateName, State);
-handle_common_event(internal, #hello_request{}, StateName, #state{role = client} = State0, Connection)
- when StateName =:= connection ->
- {Record, State} = Connection:next_record(State0),
- Connection:next_event(StateName, Record, State);
handle_common_event(timeout, hibernate, _, _, _) ->
{keep_state_and_data, [hibernate]};
handle_common_event(internal, {application_data, Data}, StateName, State0, Connection) ->
diff --git a/lib/ssl/src/ssl_handshake.hrl b/lib/ssl/src/ssl_handshake.hrl
index e7b118de10..fde92035a2 100644
--- a/lib/ssl/src/ssl_handshake.hrl
+++ b/lib/ssl/src/ssl_handshake.hrl
@@ -53,7 +53,8 @@
-define(NUM_OF_SESSION_ID_BYTES, 32). % TSL 1.1 & SSL 3
-define(NUM_OF_PREMASTERSECRET_BYTES, 48).
-define(DEFAULT_DIFFIE_HELLMAN_GENERATOR, 2).
--define(DEFAULT_DIFFIE_HELLMAN_PRIME, 16#FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF).
+-define(DEFAULT_DIFFIE_HELLMAN_PRIME,
+ 16#FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Handsake protocol - RFC 4346 section 7.4
diff --git a/lib/ssl/src/ssl_tls_dist_proxy.erl b/lib/ssl/src/ssl_tls_dist_proxy.erl
index 2e308a15b7..a920f54ed2 100644
--- a/lib/ssl/src/ssl_tls_dist_proxy.erl
+++ b/lib/ssl/src/ssl_tls_dist_proxy.erl
@@ -402,6 +402,18 @@ ssl_options(server, ["server_verify", Value|T]) ->
[{verify, atomize(Value)} | ssl_options(server,T)];
ssl_options(client, ["client_verify", Value|T]) ->
[{verify, atomize(Value)} | ssl_options(client,T)];
+ssl_options(server, ["server_verify_fun", Value|T]) ->
+ [{verify_fun, verify_fun(Value)} | ssl_options(server,T)];
+ssl_options(client, ["client_verify_fun", Value|T]) ->
+ [{verify_fun, verify_fun(Value)} | ssl_options(client,T)];
+ssl_options(server, ["server_crl_check", Value|T]) ->
+ [{crl_check, atomize(Value)} | ssl_options(server,T)];
+ssl_options(client, ["client_crl_check", Value|T]) ->
+ [{crl_check, atomize(Value)} | ssl_options(client,T)];
+ssl_options(server, ["server_crl_cache", Value|T]) ->
+ [{crl_cache, termify(Value)} | ssl_options(server,T)];
+ssl_options(client, ["client_crl_cache", Value|T]) ->
+ [{crl_cache, termify(Value)} | ssl_options(client,T)];
ssl_options(server, ["server_reuse_sessions", Value|T]) ->
[{reuse_sessions, atomize(Value)} | ssl_options(server,T)];
ssl_options(client, ["client_reuse_sessions", Value|T]) ->
@@ -426,14 +438,28 @@ ssl_options(server, ["server_dhfile", Value|T]) ->
[{dhfile, Value} | ssl_options(server,T)];
ssl_options(server, ["server_fail_if_no_peer_cert", Value|T]) ->
[{fail_if_no_peer_cert, atomize(Value)} | ssl_options(server,T)];
-ssl_options(_,_) ->
- exit(malformed_ssl_dist_opt).
+ssl_options(Type, Opts) ->
+ error(malformed_ssl_dist_opt, [Type, Opts]).
atomize(List) when is_list(List) ->
list_to_atom(List);
atomize(Atom) when is_atom(Atom) ->
Atom.
+termify(String) when is_list(String) ->
+ {ok, Tokens, _} = erl_scan:string(String ++ "."),
+ {ok, Term} = erl_parse:parse_term(Tokens),
+ Term.
+
+verify_fun(Value) ->
+ case termify(Value) of
+ {Mod, Func, State} when is_atom(Mod), is_atom(Func) ->
+ Fun = fun Mod:Func/3,
+ {Fun, State};
+ _ ->
+ error(malformed_ssl_dist_opt, [Value])
+ end.
+
flush_old_controller(Pid, Socket) ->
receive
{tcp, Socket, Data} ->
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
index 91903b4a1f..56e516bce2 100644
--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -50,7 +50,7 @@
%% Handshake handling
-export([renegotiate/2, send_handshake/2, send_change_cipher/2,
- reinit_handshake_data/1]).
+ reinit_handshake_data/1, handle_sni_extension/2]).
%% Alert and close handling
-export([send_alert/2, handle_own_alert/4, handle_close_alert/3,
@@ -228,16 +228,16 @@ error(_, _, _) ->
gen_statem:state_function_result().
%%--------------------------------------------------------------------
hello(internal, #client_hello{client_version = ClientVersion,
- extensions = #hello_extensions{ec_point_formats = EcPointFormats,
- elliptic_curves = EllipticCurves}} = Hello,
- State = #state{connection_states = ConnectionStates0,
- port = Port, session = #session{own_certificate = Cert} = Session0,
- renegotiation = {Renegotiation, _},
- session_cache = Cache,
- session_cache_cb = CacheCb,
- negotiated_protocol = CurrentProtocol,
- key_algorithm = KeyExAlg,
- ssl_options = SslOpts}) ->
+ extensions = #hello_extensions{ec_point_formats = EcPointFormats,
+ elliptic_curves = EllipticCurves}} = Hello,
+ #state{connection_states = ConnectionStates0,
+ port = Port, session = #session{own_certificate = Cert} = Session0,
+ renegotiation = {Renegotiation, _},
+ session_cache = Cache,
+ session_cache_cb = CacheCb,
+ negotiated_protocol = CurrentProtocol,
+ key_algorithm = KeyExAlg,
+ ssl_options = SslOpts} = State) ->
case tls_handshake:hello(Hello, SslOpts, {Port, Session0, Cache, CacheCb,
ConnectionStates0, Cert, KeyExAlg}, Renegotiation) of
@@ -311,7 +311,7 @@ cipher(Type, Event, State) ->
connection(info, Event, State) ->
handle_info(Event, connection, State);
connection(internal, #hello_request{},
- #state{host = Host, port = Port,
+ #state{role = client, host = Host, port = Port,
session = #session{own_certificate = Cert} = Session0,
session_cache = Cache, session_cache_cb = CacheCb,
ssl_options = SslOpts,
@@ -326,14 +326,16 @@ connection(internal, #hello_request{},
= Hello#client_hello.session_id}}),
next_event(hello, Record, State);
connection(internal, #client_hello{} = Hello,
- #state{role = server, allow_renegotiate = true} = State) ->
+ #state{role = server, allow_renegotiate = true} = State0) ->
%% Mitigate Computational DoS attack
%% http://www.educatedguesswork.org/2011/10/ssltls_and_computational_dos.html
%% http://www.thc.org/thc-ssl-dos/ Rather than disabling client
%% initiated renegotiation we will disallow many client initiated
%% renegotiations immediately after each other.
erlang:send_after(?WAIT_TO_ALLOW_RENEGOTIATION, self(), allow_renegotiate),
- {next_state, hello, State#state{allow_renegotiate = false}, [{next_event, internal, Hello}]};
+ {Record, State} = next_record(State0#state{allow_renegotiate = false,
+ renegotiation = {true, peer}}),
+ next_event(hello, Record, State, [{next_event, internal, Hello}]);
connection(internal, #client_hello{},
#state{role = server, allow_renegotiate = false} = State0) ->
Alert = ?ALERT_REC(?WARNING, ?NO_RENEGOTIATION),
@@ -398,39 +400,12 @@ handle_common_event(internal, #ssl_tls{type = ?HANDSHAKE, fragment = Data},
StateName, #state{protocol_buffers =
#protocol_buffers{tls_handshake_buffer = Buf0} = Buffers,
negotiated_version = Version} = State0) ->
-
- Handle =
- fun({#hello_request{} = Packet, _}, {connection, HState}) ->
- %% This message should not be included in handshake
- %% message hashes. Starts new handshake (renegotiation)
- Hs0 = ssl_handshake:init_handshake_history(),
- {HState#state{tls_handshake_history = Hs0,
- renegotiation = {true, peer}},
- {next_event, internal, Packet}};
- ({#hello_request{}, _}, {next_state, _SName, HState}) ->
- %% This message should not be included in handshake
- %% message hashes. Already in negotiation so it will be ignored!
- {HState, []};
- ({#client_hello{} = Packet, Raw}, {connection, HState0}) ->
- HState = handle_sni_extension(Packet, HState0),
- Version = Packet#client_hello.client_version,
- Hs0 = ssl_handshake:init_handshake_history(),
- Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw),
- {HState#state{tls_handshake_history = Hs1,
- renegotiation = {true, peer}},
- {next_event, internal, Packet}};
-
- ({Packet, Raw}, {_SName, HState0 = #state{tls_handshake_history=Hs0}}) ->
- HState = handle_sni_extension(Packet, HState0),
- Hs1 = ssl_handshake:update_handshake_history(Hs0, Raw),
- {HState#state{tls_handshake_history=Hs1}, {next_event, internal, Packet}}
- end,
- try
+ try
{Packets, Buf} = tls_handshake:get_tls_handshake(Version,Data,Buf0),
- State1 = State0#state{protocol_buffers =
- Buffers#protocol_buffers{tls_packets = Packets,
- tls_handshake_buffer = Buf}},
- {State, Events} = tls_handshake_events(Handle, StateName, State1, []),
+ State =
+ State0#state{protocol_buffers =
+ Buffers#protocol_buffers{tls_handshake_buffer = Buf}},
+ Events = tls_handshake_events(Packets),
case StateName of
connection ->
ssl_connection:hibernate_after(StateName, State, Events);
@@ -779,24 +754,12 @@ send_or_reply(_, Pid, _From, Data) ->
send_user(Pid, Msg) ->
Pid ! Msg.
-tls_handshake_events(Handle, StateName,
- #state{protocol_buffers =
- #protocol_buffers{tls_packets = [Packet]} = Buffers} = State0, Acc) ->
- {State, Event} = Handle(Packet, {StateName,
- State0#state{protocol_buffers =
- Buffers#protocol_buffers{tls_packets = []}}}),
- {State, lists:reverse([Event |Acc])};
-tls_handshake_events(Handle, StateName,
- #state{protocol_buffers =
- #protocol_buffers{tls_packets =
- [Packet | Packets]} = Buffers} = State0, Acc) ->
- {State, Event} = Handle(Packet, {StateName, State0#state{protocol_buffers =
- Buffers#protocol_buffers{tls_packets =
- Packets}}}),
- tls_handshake_events(Handle, StateName, State, [Event | Acc]);
-
-tls_handshake_events(_Handle, _, #state{}, _) ->
- throw(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE)).
+tls_handshake_events([]) ->
+ throw(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE, malformed_handshake));
+tls_handshake_events(Packets) ->
+ lists:map(fun(Packet) ->
+ {next_event, internal, {handshake, Packet}}
+ end, Packets).
write_application_data(Data0, From,
#state{socket = Socket,
@@ -1065,5 +1028,5 @@ handle_sni_extension(#client_hello{extensions = HelloExtensions}, State0) ->
}
end
end;
-handle_sni_extension(_, State0) ->
- State0.
+handle_sni_extension(_, State) ->
+ State.
diff --git a/lib/ssl/test/ssl_ECC_SUITE.erl b/lib/ssl/test/ssl_ECC_SUITE.erl
index 3a1fd00c06..b8a03f578d 100644
--- a/lib/ssl/test/ssl_ECC_SUITE.erl
+++ b/lib/ssl/test/ssl_ECC_SUITE.erl
@@ -343,6 +343,12 @@ new_ca(FileName, CA, OwnCa) ->
E1 = public_key:pem_decode(P1),
{ok, P2} = file:read_file(OwnCa),
E2 = public_key:pem_decode(P2),
- Pem = public_key:pem_encode(E2 ++E1),
- file:write_file(FileName, Pem),
+ case os:cmd("openssl version") of
+ "OpenSSL 1.0.1p-freebsd" ++ _ ->
+ Pem = public_key:pem_encode(E1 ++E2),
+ file:write_file(FileName, Pem);
+ _ ->
+ Pem = public_key:pem_encode(E2 ++E1),
+ file:write_file(FileName, Pem)
+ end,
FileName.
diff --git a/lib/ssl/test/ssl_basic_SUITE.erl b/lib/ssl/test/ssl_basic_SUITE.erl
index 686cdc569d..99f7c9b780 100644
--- a/lib/ssl/test/ssl_basic_SUITE.erl
+++ b/lib/ssl/test/ssl_basic_SUITE.erl
@@ -2631,7 +2631,7 @@ client_no_wrap_sequence_number(Config) when is_list(Config) ->
{ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
ErlData = "From erlang to erlang",
- N = 10,
+ N = 12,
Server =
ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
@@ -2668,7 +2668,7 @@ server_no_wrap_sequence_number(Config) when is_list(Config) ->
{ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
Data = "From erlang to erlang",
- N = 10,
+ N = 12,
Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
{from, self()},
@@ -3939,6 +3939,7 @@ prf_verify_value(Socket, TlsVer, Expected, Algo) ->
send_recv_result_timeout_client(Socket) ->
{error, timeout} = ssl:recv(Socket, 11, 500),
+ {error, timeout} = ssl:recv(Socket, 11, 0),
ssl:send(Socket, "Hello world"),
receive
Msg ->
diff --git a/lib/ssl/test/ssl_dist_SUITE.erl b/lib/ssl/test/ssl_dist_SUITE.erl
index d90ec428ee..f0ce82f4fe 100644
--- a/lib/ssl/test/ssl_dist_SUITE.erl
+++ b/lib/ssl/test/ssl_dist_SUITE.erl
@@ -21,6 +21,7 @@
-module(ssl_dist_SUITE).
-include_lib("common_test/include/ct.hrl").
+-include_lib("public_key/include/public_key.hrl").
%% Note: This directive should only be used in test suites.
-compile(export_all).
@@ -41,7 +42,9 @@
%%--------------------------------------------------------------------
all() ->
[basic, payload, plain_options, plain_verify_options, nodelay_option,
- listen_port_options, listen_options, connect_options, use_interface].
+ listen_port_options, listen_options, connect_options, use_interface,
+ verify_fun_fail, verify_fun_pass, crl_check_pass, crl_check_fail,
+ crl_check_best_effort, crl_cache_check_pass, crl_cache_check_fail].
groups() ->
[].
@@ -418,6 +421,255 @@ use_interface(Config) when is_list(Config) ->
stop_ssl_node(NH1),
success(Config).
+%%--------------------------------------------------------------------
+verify_fun_fail() ->
+ [{doc,"Test specifying verify_fun with a function that always fails"}].
+verify_fun_fail(Config) when is_list(Config) ->
+ DistOpts = "-ssl_dist_opt "
+ "server_verify verify_peer server_verify_fun "
+ "\"{ssl_dist_SUITE,verify_fail_always,{}}\" "
+ "client_verify verify_peer client_verify_fun "
+ "\"{ssl_dist_SUITE,verify_fail_always,{}}\" ",
+
+ NH1 = start_ssl_node([{additional_dist_opts, DistOpts} | Config]),
+ NH2 = start_ssl_node([{additional_dist_opts, DistOpts} | Config]),
+ Node2 = NH2#node_handle.nodename,
+
+ pang = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ %% Check that the function ran on the client node.
+ [{verify_fail_always_ran, true}] =
+ apply_on_ssl_node(NH1, fun () -> ets:tab2list(verify_fun_ran) end),
+ %% On the server node, it wouldn't run, because the server didn't
+ %% request a certificate from the client.
+ undefined =
+ apply_on_ssl_node(NH2, fun () -> ets:info(verify_fun_ran) end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+verify_fail_always(_Certificate, _Event, _State) ->
+ %% Create an ETS table, to record the fact that the verify function ran.
+ %% Spawn a new process, to avoid the ETS table disappearing.
+ Parent = self(),
+ spawn(
+ fun() ->
+ ets:new(verify_fun_ran, [public, named_table]),
+ ets:insert(verify_fun_ran, {verify_fail_always_ran, true}),
+ Parent ! go_ahead,
+ timer:sleep(infinity)
+ end),
+ receive go_ahead -> ok end,
+ {fail, bad_certificate}.
+
+%%--------------------------------------------------------------------
+verify_fun_pass() ->
+ [{doc,"Test specifying verify_fun with a function that always succeeds"}].
+verify_fun_pass(Config) when is_list(Config) ->
+ DistOpts = "-ssl_dist_opt "
+ "server_verify verify_peer server_verify_fun "
+ "\"{ssl_dist_SUITE,verify_pass_always,{}}\" "
+ "server_fail_if_no_peer_cert true "
+ "client_verify verify_peer client_verify_fun "
+ "\"{ssl_dist_SUITE,verify_pass_always,{}}\" ",
+
+ NH1 = start_ssl_node([{additional_dist_opts, DistOpts} | Config]),
+ Node1 = NH1#node_handle.nodename,
+ NH2 = start_ssl_node([{additional_dist_opts, DistOpts} | Config]),
+ Node2 = NH2#node_handle.nodename,
+
+ pong = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [Node2] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [Node1] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ %% Check that the function ran on the client node.
+ [{verify_pass_always_ran, true}] =
+ apply_on_ssl_node(NH1, fun () -> ets:tab2list(verify_fun_ran) end),
+ %% Check that it ran on the server node as well. The server
+ %% requested and verified the client's certificate because we
+ %% passed fail_if_no_peer_cert.
+ [{verify_pass_always_ran, true}] =
+ apply_on_ssl_node(NH2, fun () -> ets:tab2list(verify_fun_ran) end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+verify_pass_always(_Certificate, _Event, State) ->
+ %% Create an ETS table, to record the fact that the verify function ran.
+ %% Spawn a new process, to avoid the ETS table disappearing.
+ Parent = self(),
+ spawn(
+ fun() ->
+ ets:new(verify_fun_ran, [public, named_table]),
+ ets:insert(verify_fun_ran, {verify_pass_always_ran, true}),
+ Parent ! go_ahead,
+ timer:sleep(infinity)
+ end),
+ receive go_ahead -> ok end,
+ {valid, State}.
+%%--------------------------------------------------------------------
+crl_check_pass() ->
+ [{doc,"Test crl_check with non-revoked certificate"}].
+crl_check_pass(Config) when is_list(Config) ->
+ DistOpts = "-ssl_dist_opt client_crl_check true",
+ NewConfig =
+ [{many_verify_opts, true}, {additional_dist_opts, DistOpts}] ++ Config,
+
+ NH1 = start_ssl_node(NewConfig),
+ Node1 = NH1#node_handle.nodename,
+ NH2 = start_ssl_node(NewConfig),
+ Node2 = NH2#node_handle.nodename,
+
+ PrivDir = ?config(priv_dir, Config),
+ cache_crls_on_ssl_nodes(PrivDir, ["erlangCA", "otpCA"], [NH1, NH2]),
+
+ %% The server's certificate is not revoked, so connection succeeds.
+ pong = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [Node2] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [Node1] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+%%--------------------------------------------------------------------
+crl_check_fail() ->
+ [{doc,"Test crl_check with revoked certificate"}].
+crl_check_fail(Config) when is_list(Config) ->
+ DistOpts = "-ssl_dist_opt client_crl_check true",
+ NewConfig =
+ [{many_verify_opts, true},
+ %% The server uses a revoked certificate.
+ {server_cert_dir, "revoked"},
+ {additional_dist_opts, DistOpts}] ++ Config,
+
+ NH1 = start_ssl_node(NewConfig),
+ %%Node1 = NH1#node_handle.nodename,
+ NH2 = start_ssl_node(NewConfig),
+ Node2 = NH2#node_handle.nodename,
+
+ PrivDir = ?config(priv_dir, Config),
+ cache_crls_on_ssl_nodes(PrivDir, ["erlangCA", "otpCA"], [NH1, NH2]),
+
+ %% The server's certificate is revoked, so connection fails.
+ pang = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+%%--------------------------------------------------------------------
+crl_check_best_effort() ->
+ [{doc,"Test specifying crl_check as best_effort"}].
+crl_check_best_effort(Config) when is_list(Config) ->
+ DistOpts = "-ssl_dist_opt "
+ "server_verify verify_peer server_crl_check best_effort",
+ NewConfig =
+ [{many_verify_opts, true}, {additional_dist_opts, DistOpts}] ++ Config,
+
+ %% We don't have the correct CRL at hand, but since crl_check is
+ %% best_effort, we accept it anyway.
+ NH1 = start_ssl_node(NewConfig),
+ Node1 = NH1#node_handle.nodename,
+ NH2 = start_ssl_node(NewConfig),
+ Node2 = NH2#node_handle.nodename,
+
+ pong = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [Node2] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [Node1] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+%%--------------------------------------------------------------------
+crl_cache_check_pass() ->
+ [{doc,"Test specifying crl_check with custom crl_cache module"}].
+crl_cache_check_pass(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ NodeDir = filename:join([PrivDir, "Certs"]),
+ DistOpts = "-ssl_dist_opt "
+ "client_crl_check true "
+ "client_crl_cache "
+ "\"{ssl_dist_SUITE,{\\\"" ++ NodeDir ++ "\\\",[]}}\"",
+ NewConfig =
+ [{many_verify_opts, true}, {additional_dist_opts, DistOpts}] ++ Config,
+
+ NH1 = start_ssl_node(NewConfig),
+ Node1 = NH1#node_handle.nodename,
+ NH2 = start_ssl_node(NewConfig),
+ Node2 = NH2#node_handle.nodename,
+
+ pong = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [Node2] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [Node1] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+%%--------------------------------------------------------------------
+crl_cache_check_fail() ->
+ [{doc,"Test custom crl_cache module with revoked certificate"}].
+crl_cache_check_fail(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ NodeDir = filename:join([PrivDir, "Certs"]),
+ DistOpts = "-ssl_dist_opt "
+ "client_crl_check true "
+ "client_crl_cache "
+ "\"{ssl_dist_SUITE,{\\\"" ++ NodeDir ++ "\\\",[]}}\"",
+ NewConfig =
+ [{many_verify_opts, true},
+ %% The server uses a revoked certificate.
+ {server_cert_dir, "revoked"},
+ {additional_dist_opts, DistOpts}] ++ Config,
+
+ NH1 = start_ssl_node(NewConfig),
+ NH2 = start_ssl_node(NewConfig),
+ Node2 = NH2#node_handle.nodename,
+
+ pang = apply_on_ssl_node(NH1, fun () -> net_adm:ping(Node2) end),
+
+ [] = apply_on_ssl_node(NH1, fun () -> nodes() end),
+ [] = apply_on_ssl_node(NH2, fun () -> nodes() end),
+
+ stop_ssl_node(NH1),
+ stop_ssl_node(NH2),
+ success(Config).
+
+%% ssl_crl_cache_api callbacks
+lookup(_DistributionPoint, _DbHandle) ->
+ not_available.
+
+select({rdnSequence, NameParts}, {NodeDir, _}) ->
+ %% Extract the CN from the issuer name...
+ [CN] = [CN ||
+ [#'AttributeTypeAndValue'{
+ type = ?'id-at-commonName',
+ value = <<_, _, CN/binary>>}] <- NameParts],
+ %% ...and use that as the directory name to find the CRL.
+ error_logger:info_report([{found_cn, CN}]),
+ CRLFile = filename:join([NodeDir, CN, "crl.pem"]),
+ {ok, PemBin} = file:read_file(CRLFile),
+ PemEntries = public_key:pem_decode(PemBin),
+ CRLs = [ CRL || {'CertificateList', CRL, not_encrypted}
+ <- PemEntries],
+ CRLs.
+
+fresh_crl(_DistributionPoint, CRL) ->
+ CRL.
%%--------------------------------------------------------------------
%%% Internal functions -----------------------------------------------
@@ -528,6 +780,19 @@ start_ssl_node_raw(Name, Args) ->
exit({failed_to_start_node, Name, Error})
end.
+cache_crls_on_ssl_nodes(PrivDir, CANames, NHs) ->
+ [begin
+ File = filename:join([PrivDir, "Certs", CAName, "crl.pem"]),
+ {ok, PemBin} = file:read_file(File),
+ PemEntries = public_key:pem_decode(PemBin),
+ CRLs = [ CRL || {'CertificateList', CRL, not_encrypted}
+ <- PemEntries],
+ ok = apply_on_ssl_node(NH, ssl_manager, insert_crls,
+ ["no_distribution_point", CRLs, dist])
+ end
+ || NH <- NHs, CAName <- CANames],
+ ok.
+
%%
%% command line creation
%%
@@ -563,11 +828,13 @@ mk_node_cmdline(ListenPort, Name, Args) ->
++ NameSw ++ " " ++ Name ++ " "
++ "-pa " ++ Pa ++ " "
++ "-run application start crypto -run application start public_key "
+ ++ "-eval 'net_kernel:verbose(1)' "
++ "-run " ++ atom_to_list(?MODULE) ++ " cnct2tstsrvr "
++ host_name() ++ " "
++ integer_to_list(ListenPort) ++ " "
++ Args ++ " "
++ "-env ERL_CRASH_DUMP " ++ Pwd ++ "/erl_crash_dump." ++ Name ++ " "
+ ++ "-kernel error_logger \"{file,\\\"" ++ Pwd ++ "/error_log." ++ Name ++ "\\\"}\" "
++ "-setcookie " ++ atom_to_list(erlang:get_cookie()).
%%
@@ -815,8 +1082,8 @@ setup_dist_opts(Config) ->
DataDir = proplists:get_value(data_dir, Config),
Dhfile = filename:join([DataDir, "dHParam.pem"]),
NodeDir = filename:join([PrivDir, "Certs"]),
- SDir = filename:join([NodeDir, "server"]),
- CDir = filename:join([NodeDir, "client"]),
+ SDir = filename:join([NodeDir, proplists:get_value(server_cert_dir, Config, "server")]),
+ CDir = filename:join([NodeDir, proplists:get_value(client_cert_dir, Config, "client")]),
SC = filename:join([SDir, "cert.pem"]),
SK = filename:join([SDir, "key.pem"]),
SKC = filename:join([SDir, "keycert.pem"]),
diff --git a/lib/stdlib/test/gen_server_SUITE.erl b/lib/stdlib/test/gen_server_SUITE.erl
index 3242511f4a..338cd3dc0a 100644
--- a/lib/stdlib/test/gen_server_SUITE.erl
+++ b/lib/stdlib/test/gen_server_SUITE.erl
@@ -185,7 +185,7 @@ start(Config) when is_list(Config) ->
gen_server:start({global, my_test_name},
gen_server_SUITE, [], []),
ok = gen_server:call({global, my_test_name}, stop),
- ct:sleep(1),
+ busy_wait_for_process(Pid4,600),
{'EXIT', {noproc,_}} = (catch gen_server:call(Pid4, started_p, 10)),
%% global register linked
@@ -214,7 +214,7 @@ start(Config) when is_list(Config) ->
gen_server:start({via, dummy_via, my_test_name},
gen_server_SUITE, [], []),
ok = gen_server:call({via, dummy_via, my_test_name}, stop),
- ct:sleep(1),
+ busy_wait_for_process(Pid6,600),
{'EXIT', {noproc,_}} = (catch gen_server:call(Pid6, started_p, 10)),
%% via register linked