aboutsummaryrefslogtreecommitdiffstats
path: root/erts/epmd/test/epmd_SUITE.erl
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2011-05-19 16:57:08 +0200
committerPatrik Nyblom <[email protected]>2011-05-19 16:57:08 +0200
commitf85d382cd3f81cde9afedff2b777c08c8b68e07c (patch)
treec94ac136dc432880d43379281ba7ea74d2c1b9c9 /erts/epmd/test/epmd_SUITE.erl
parent734118ea0f0dea726ebde7fa07364ba7270be012 (diff)
parent7069ebf67ea417fa5b5cc13d83aa23db92c751eb (diff)
downloadotp-f85d382cd3f81cde9afedff2b777c08c8b68e07c.tar.gz
otp-f85d382cd3f81cde9afedff2b777c08c8b68e07c.tar.bz2
otp-f85d382cd3f81cde9afedff2b777c08c8b68e07c.zip
Merge branch 'pan/epmd_testcase/OTP-9214' into dev
* pan/epmd_testcase/OTP-9214: Make ssh proxy work with older versions of ssh Mend epmd testcases that test remote access
Diffstat (limited to 'erts/epmd/test/epmd_SUITE.erl')
-rw-r--r--erts/epmd/test/epmd_SUITE.erl139
1 files changed, 76 insertions, 63 deletions
diff --git a/erts/epmd/test/epmd_SUITE.erl b/erts/epmd/test/epmd_SUITE.erl
index 72c890503d..6889ec0b34 100644
--- a/erts/epmd/test/epmd_SUITE.erl
+++ b/erts/epmd/test/epmd_SUITE.erl
@@ -780,42 +780,43 @@ no_nonlocal_register(suite) ->
no_nonlocal_register(doc) ->
["Ensure that we cannot register throug a nonlocal connection"];
no_nonlocal_register(Config) when is_list(Config) ->
+ ?line case {os:find_executable("ssh"),ct:get_config(ssh_proxy_host)} of
+ {SSH,Name} when is_list(Name), is_list(SSH) ->
+ do_no_nonlocal_register(Config,Name);
+ {false,_} ->
+ {skip, "No ssh command found to create proxy"};
+ _ ->
+ {skip, "No ssh_proxy_host configured in ts.config"}
+ end.
+do_no_nonlocal_register(Config,SSHHost) when is_list(Config) ->
?line ok = epmdrun(),
- ?line {ok,Ifs} = inet:getiflist(),
- ?line Addr0 = [ inet:ifget(I, [addr]) || I <- Ifs ],
- ?line Addr1 = [ A || {ok,[{addr,A}]} <- Addr0],
- ?line Addr = lists:filter(fun({127,_,_,_}) ->
- false;
- (_) ->
- true
- end,Addr1),
- %% Now we should have all non loopback interface addresses,
- %% none should accept a alive2 registration.
- ?line Res = lists:map(fun(Ad={A1,A2,A3,A4}) ->
- try
- Name = "gurka_"++
- integer_to_list(A1)++"_"++
- integer_to_list(A2)++"_"++
- integer_to_list(A3)++"_"++
- integer_to_list(A4),
- Bname = list_to_binary(Name),
- NameS = byte_size(Bname),
- ?line Bin= <<$x:8,4747:16,$M:8,0:8,5:16,
- 5:16,NameS:16,Bname/binary,
- 0:16>>,
- ?line S = size(Bin),
- {ok, E} = connect(Ad),
- gen_tcp:send(E,[<<S:16>>,Bin]),
- closed = recv(E,1),
- gen_tcp:close(E),
- true
- catch
- _:_ ->
- false
- end
- end, Addr),
- erlang:display(Res),
- ?line true = alltrue(Res),
+ ?line ProxyPort = proxy_port(),
+ ?line ok = ssh_proxy(SSHHost,ProxyPort),
+ Res = try
+ ?line Name = "gurka_"
+ %++
+ %integer_to_list(A1)++"_"++
+ %integer_to_list(A2)++"_"++
+ %integer_to_list(A3)++"_"++
+ %integer_to_list(A4)
+ ,
+ ?line Bname = list_to_binary(Name),
+ ?line NameS = byte_size(Bname),
+ ?line Bin= <<$x:8,4747:16,$M:8,0:8,5:16,
+ 5:16,NameS:16,Bname/binary,
+ 0:16>>,
+ ?line S = size(Bin),
+ ?line {ok, E} = connect("localhost",ProxyPort,passive),
+ ?line gen_tcp:send(E,[<<S:16>>,Bin]),
+ ?line closed = recv(E,1),
+ ?line gen_tcp:close(E),
+ true
+ catch
+ _:_ ->
+ false
+ end,
+ %erlang:display(Res),
+ true = Res,
ok.
no_nonlocal_kill(suite) ->
@@ -823,35 +824,34 @@ no_nonlocal_kill(suite) ->
no_nonlocal_kill(doc) ->
["Ensure that we cannot kill through nonlocal connection"];
no_nonlocal_kill(Config) when is_list(Config) ->
+ ?line case {os:find_executable("ssh"),ct:get_config(ssh_proxy_host)} of
+ {SSH,Name} when is_list(Name), is_list(SSH) ->
+ do_no_nonlocal_kill(Config,Name);
+ {false,_} ->
+ {skip, "No ssh command found to create proxy"};
+ _ ->
+ {skip, "No ssh_proxy_host configured in ts.config"}
+ end.
+do_no_nonlocal_kill(Config,SSHHost) when is_list(Config) ->
?line ok = epmdrun(),
- ?line {ok,Ifs} = inet:getiflist(),
- ?line Addr0 = [ inet:ifget(I, [addr]) || I <- Ifs ],
- ?line Addr1 = [ A || {ok,[{addr,A}]} <- Addr0],
- ?line Addr = lists:filter(fun({127,_,_,_}) ->
- false;
- (_) ->
- true
- end,Addr1),
- %% Now we should have all non loopback interface addresses,
- %% none should accept a alive2 registration.
- ?line Res = lists:map(fun(Ad) ->
- try
- {ok, E} = connect(Ad),
- M = [?EPMD_KILL_REQ],
- send(E, [size16(M), M]),
- closed = recv(E,2),
- gen_tcp:close(E),
- sleep(?MEDIUM_PAUSE),
- {ok, E2} = connect(Ad),
- gen_tcp:close(E2),
- true
- catch
- _:_ ->
- false
- end
- end, Addr),
- erlang:display(Res),
- ?line true = alltrue(Res),
+ ?line ProxyPort = proxy_port(),
+ ?line ok = ssh_proxy(SSHHost,ProxyPort),
+ Res = try
+ {ok, E} = connect("localhost",ProxyPort,passive),
+ M = [?EPMD_KILL_REQ],
+ send(E, [size16(M), M]),
+ closed = recv(E,2),
+ gen_tcp:close(E),
+ sleep(?MEDIUM_PAUSE),
+ {ok, E2} = connect("localhost",ProxyPort,passive),
+ gen_tcp:close(E2),
+ true
+ catch
+ _:_ ->
+ false
+ end,
+ %erlang:display(Res),
+ true = Res,
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
no_live_killing(doc) ->
@@ -896,6 +896,19 @@ cleanup() ->
true
end.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Start an ssh channel to simulate remote access
+
+proxy_port() ->
+ ?PORT+1.
+
+ssh_proxy(SSHHost,ProxyPort) ->
+ ?line Host = lists:nth(2,string:tokens(atom_to_list(node()),"@")),
+ % Requires proxy to be a unix host with the command 'read' accessible
+ ?line osrun("ssh -L "++integer_to_list(ProxyPort)++":"++Host++":"
+ ++integer_to_list(?PORT)++" "++SSHHost++" read").
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Normal debug start of epmd