diff options
author | Hans Nilsson <[email protected]> | 2017-02-17 11:40:36 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-02-17 11:40:36 +0100 |
commit | af4855549d2a7b1cf414b0e6c0568c0e151e1319 (patch) | |
tree | 8f97c2687e4c1a568ab2efca5d35186ea1ec333e /lib/ssh/test | |
parent | adbcc111926afe5dc43ceaf322bfa007d9f5d00a (diff) | |
parent | 859ac82433da2dcd11685b8c8beb972336cf70cf (diff) | |
download | otp-af4855549d2a7b1cf414b0e6c0568c0e151e1319.tar.gz otp-af4855549d2a7b1cf414b0e6c0568c0e151e1319.tar.bz2 otp-af4855549d2a7b1cf414b0e6c0568c0e151e1319.zip |
Merge branch 'ssh_sftpd_cwd_with_root' into hans/ssh/sftpd_fixes/OTP-14225
Conflicts:
lib/ssh/test/ssh_sftpd_SUITE.erl
Diffstat (limited to 'lib/ssh/test')
-rw-r--r-- | lib/ssh/test/ssh_sftpd_SUITE.erl | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl index 5616736f6e..851da6b479 100644 --- a/lib/ssh/test/ssh_sftpd_SUITE.erl +++ b/lib/ssh/test/ssh_sftpd_SUITE.erl @@ -66,7 +66,8 @@ all() -> relpath, sshd_read_file, ver6_basic, - access_outside_root]. + access_outside_root, + root_with_cwd]. groups() -> []. @@ -128,6 +129,11 @@ init_per_testcase(TestCase, Config) -> SubSystems = [ssh_sftpd:subsystem_spec([{root, RootDir}, {cwd, CWD}])], ssh:daemon(0, [{subsystems, SubSystems}|Options]); + root_with_cwd -> + RootDir = filename:join(PrivDir, root_with_cwd), + CWD = filename:join(RootDir, home), + SubSystems = [ssh_sftpd:subsystem_spec([{root, RootDir}, {cwd, CWD}])], + ssh:daemon(0, [{subsystems, SubSystems}|Options]); _ -> SubSystems = [ssh_sftpd:subsystem_spec([])], ssh:daemon(0, [{subsystems, SubSystems}|Options]) @@ -659,6 +665,8 @@ ver6_basic(Config) when is_list(Config) -> ?SSH_FXF_OPEN_EXISTING). %%-------------------------------------------------------------------- +access_outside_root() -> + [{doc, "Try access files outside the tree below RootDir"}]. access_outside_root(Config) when is_list(Config) -> PrivDir = proplists:get_value(priv_dir, Config), BaseDir = filename:join(PrivDir, access_outside_root), @@ -703,6 +711,36 @@ try_access(Path, Cm, Channel, ReqId) -> end. %%-------------------------------------------------------------------- +root_with_cwd() -> + [{doc, "Check if files are found, if the CWD and Root are specified"}]. +root_with_cwd(Config) when is_list(Config) -> + PrivDir = proplists:get_value(priv_dir, Config), + RootDir = filename:join(PrivDir, root_with_cwd), + CWD = filename:join(RootDir, home), + FileName = "root_with_cwd.txt", + FilePath = filename:join(CWD, FileName), + ok = filelib:ensure_dir(FilePath), + ok = file:write_file(FilePath ++ "0", <<>>), + ok = file:write_file(FilePath ++ "1", <<>>), + ok = file:write_file(FilePath ++ "2", <<>>), + {Cm, Channel} = proplists:get_value(sftp, Config), + ReqId0 = 0, + {ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId0), _Handle0/binary>>, _} = + open_file(FileName ++ "0", Cm, Channel, ReqId0, + ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES, + ?SSH_FXF_OPEN_EXISTING), + ReqId1 = 1, + {ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId1), _Handle1/binary>>, _} = + open_file("./" ++ FileName ++ "1", Cm, Channel, ReqId1, + ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES, + ?SSH_FXF_OPEN_EXISTING), + ReqId2 = 2, + {ok, <<?SSH_FXP_HANDLE, ?UINT32(ReqId2), _Handle2/binary>>, _} = + open_file("/home/" ++ FileName ++ "2", Cm, Channel, ReqId2, + ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES, + ?SSH_FXF_OPEN_EXISTING). + +%%-------------------------------------------------------------------- %% Internal functions ------------------------------------------------ %%-------------------------------------------------------------------- prep(Config) -> |