aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_sftpd_SUITE.erl
diff options
context:
space:
mode:
authorKarolis Petrauskas <karolis.petrauskas@erisata.lt>2017-02-12 15:00:36 +0200
committerKarolis Petrauskas <karolis.petrauskas@erisata.lt>2017-02-12 15:00:36 +0200
commit002e507bab9209aeb5487ee3a1dbe52a73f80f84 (patch)
treefc431befdaa3498ba128fb9fd13cdb3bec0d7381 /lib/ssh/test/ssh_sftpd_SUITE.erl
parenta34576111652d2d7972147160f93cfbbc9f13251 (diff)
downloadotp-002e507bab9209aeb5487ee3a1dbe52a73f80f84.tar.gz
otp-002e507bab9209aeb5487ee3a1dbe52a73f80f84.tar.bz2
otp-002e507bab9209aeb5487ee3a1dbe52a73f80f84.zip
Check for directory with correct path
When opening file in the ssh_sftpd, directory check should be performed on the server's file tree.
Diffstat (limited to 'lib/ssh/test/ssh_sftpd_SUITE.erl')
-rw-r--r--lib/ssh/test/ssh_sftpd_SUITE.erl45
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index 6d71b33c9b..380b01d32d 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -66,7 +66,9 @@ all() ->
relpath,
sshd_read_file,
ver6_basic,
- relative_path].
+ relative_path,
+ open_file_dir_v5,
+ open_file_dir_v6].
groups() ->
[].
@@ -121,6 +123,13 @@ init_per_testcase(TestCase, Config) ->
relative_path ->
SubSystems = [ssh_sftpd:subsystem_spec([{cwd, PrivDir}])],
ssh:daemon(0, [{subsystems, SubSystems}|Options]);
+ open_file_dir_v5 ->
+ SubSystems = [ssh_sftpd:subsystem_spec([{cwd, PrivDir}])],
+ ssh:daemon(0, [{subsystems, SubSystems}|Options]);
+ open_file_dir_v6 ->
+ SubSystems = [ssh_sftpd:subsystem_spec([{cwd, PrivDir},
+ {sftpd_vsn, 6}])],
+ ssh:daemon(0, [{subsystems, SubSystems}|Options]);
_ ->
SubSystems = [ssh_sftpd:subsystem_spec([])],
ssh:daemon(0, [{subsystems, SubSystems}|Options])
@@ -668,6 +677,40 @@ relative_path(Config) when is_list(Config) ->
?SSH_FXF_OPEN_EXISTING).
%%--------------------------------------------------------------------
+open_file_dir_v5() ->
+ [{doc, "Test if open_file fails when opening existing directory."}].
+open_file_dir_v5(Config) when is_list(Config) ->
+ PrivDir = proplists:get_value(priv_dir, Config),
+ FileName = "open_file_dir_v5",
+ FilePath = filename:join(PrivDir, FileName),
+ ok = filelib:ensure_dir(FilePath),
+ ok = file:make_dir(FilePath),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
+ ReqId = 0,
+ {ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId),
+ ?UINT32(?SSH_FX_FAILURE), _/binary>>, _} =
+ open_file(FileName, Cm, Channel, ReqId,
+ ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES,
+ ?SSH_FXF_OPEN_EXISTING).
+
+%%--------------------------------------------------------------------
+open_file_dir_v6() ->
+ [{doc, "Test if open_file fails when opening existing directory."}].
+open_file_dir_v6(Config) when is_list(Config) ->
+ PrivDir = proplists:get_value(priv_dir, Config),
+ FileName = "open_file_dir_v6",
+ FilePath = filename:join(PrivDir, FileName),
+ ok = filelib:ensure_dir(FilePath),
+ ok = file:make_dir(FilePath),
+ {Cm, Channel} = proplists:get_value(sftp, Config),
+ ReqId = 0,
+ {ok, <<?SSH_FXP_STATUS, ?UINT32(ReqId),
+ ?UINT32(?SSH_FX_FILE_IS_A_DIRECTORY), _/binary>>, _} =
+ open_file(FileName, Cm, Channel, ReqId,
+ ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES,
+ ?SSH_FXF_OPEN_EXISTING).
+
+%%--------------------------------------------------------------------
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
prep(Config) ->