From 9971f38968b19ba90e0267b8c7a549fc568d5611 Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Tue, 27 Nov 2012 15:33:47 +0100
Subject: Basic functionality for sftp ver6 and testcase
---
lib/ssh/src/ssh.erl | 4 +++
lib/ssh/src/ssh_sftpd.erl | 75 +++++++++++++++++++++-------------------
lib/ssh/src/ssh_xfer.hrl | 12 ++++++-
lib/ssh/test/ssh_sftpd_SUITE.erl | 18 ++++++++--
4 files changed, 70 insertions(+), 39 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 719c97e940..22c55f8bf0 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -364,6 +364,8 @@ handle_option([{quiet_mode, _} = Opt|Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([{idle_time, _} = Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
+handle_option([{sftp_vsn, _} = Opt | Rest], SocketOptions, SshOptions) ->
+ handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, [handle_inet_option(Opt) | SocketOptions], SshOptions).
@@ -440,6 +442,8 @@ handle_ssh_option({quiet_mode, Value} = Opt) when Value == true;
Opt;
handle_ssh_option({idle_time, Value} = Opt) when is_integer(Value), Value > 0 ->
Opt;
+handle_ssh_option({sftp_vsn, Value} = Opt) when is_integer(Value), Value > 0, Value < 7 ->
+ Opt;
handle_ssh_option(Opt) ->
throw({error, {eoptions, Opt}}).
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index ec7b76b0b3..d6a7ee3859 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -119,9 +119,7 @@ init(Options) ->
{Root0, State0}
end,
MaxLength = proplists:get_value(max_files, Options, 0),
-
- Vsn = proplists:get_value(vsn, Options, 5),
-
+ Vsn = proplists:get_value(sftp_vsn, Options, 5),
{ok, State#state{cwd = CWD, root = Root, max_files = MaxLength,
handles = [], pending = <<>>,
xf = #ssh_xfer{vsn = Vsn, ext = []}}}.
@@ -369,17 +367,20 @@ handle_op(?SSH_FXP_FSETSTAT, ReqId, <>,
- State0 = #state{file_handler = FileMod, file_state = FS0}) ->
+ State0 = #state{file_handler = FileMod, file_state = FS0, xf = #ssh_xfer{vsn = Vsn}}) ->
Path = relate_file_name(BPath, State0),
- %% case FileMod:is_dir(Path) of %% This version 6 we still have ver 5
- %% true ->
- %% ssh_xfer:xf_send_status(State#state.xf, ReqId,
- %% ?SSH_FX_FILE_IS_A_DIRECTORY);
- %% false ->
- {Status, FS1} = FileMod:delete(Path, FS0),
- State1 = State0#state{file_state = FS1},
- send_status(Status, ReqId, State1);
- %%end;
+ case FileMod:is_dir(Path) of %% This version 6 we still have ver 5
+ true when Vsn > 5 ->
+ ssh_xfer:xf_send_status(State0#state.xf, ReqId,
+ ?SSH_FX_FILE_IS_A_DIRECTORY, "File is a directory");
+ true ->
+ ssh_xfer:xf_send_status(State0#state.xf, ReqId,
+ ?SSH_FX_FAILURE, "File is a directory");
+ false ->
+ {Status, FS1} = FileMod:delete(Path, FS0),
+ State1 = State0#state{file_state = FS1},
+ send_status(Status, ReqId, State1)
+ end;
handle_op(?SSH_FXP_RMDIR, ReqId, <>,
State0 = #state{file_handler = FileMod, file_state = FS0}) ->
Path = relate_file_name(BPath, State0),
@@ -637,31 +638,33 @@ open(Vsn, ReqId, Data, State) when Vsn >= 4 ->
do_open(ReqId, State, Path, Flags).
do_open(ReqId, State0, Path, Flags) ->
- #state{file_handler = FileMod, file_state = FS0, root = Root} = State0,
+ #state{file_handler = FileMod, file_state = FS0, root = Root, xf = #ssh_xfer{vsn = Vsn}} = State0,
XF = State0#state.xf,
F = [binary | Flags],
- %% case FileMod:is_dir(Path) of %% This is version 6 we still have 5
- %% true ->
- %% ssh_xfer:xf_send_status(State#state.xf, ReqId,
- %% ?SSH_FX_FILE_IS_A_DIRECTORY);
- %% false ->
-
- AbsPath = case Root of
- "" ->
- Path;
- _ ->
- relate_file_name(Path, State0)
- end,
-
- {Res, FS1} = FileMod:open(AbsPath, F, FS0),
- State1 = State0#state{file_state = FS1},
- case Res of
- {ok, IoDevice} ->
- add_handle(State1, XF, ReqId, file, {Path,IoDevice});
- {error, Error} ->
- ssh_xfer:xf_send_status(State1#state.xf, ReqId,
- ssh_xfer:encode_erlang_status(Error)),
- State1
+ case FileMod:is_dir(Path) of
+ true when Vsn > 5 ->
+ ssh_xfer:xf_send_status(State0#state.xf, ReqId,
+ ?SSH_FX_FILE_IS_A_DIRECTORY, "File is a directory");
+ true ->
+ ssh_xfer:xf_send_status(State0#state.xf, ReqId,
+ ?SSH_FX_FAILURE, "File is a directory");
+ false ->
+ AbsPath = case Root of
+ "" ->
+ Path;
+ _ ->
+ relate_file_name(Path, State0)
+ end,
+ {Res, FS1} = FileMod:open(AbsPath, F, FS0),
+ State1 = State0#state{file_state = FS1},
+ case Res of
+ {ok, IoDevice} ->
+ add_handle(State1, XF, ReqId, file, {Path,IoDevice});
+ {error, Error} ->
+ ssh_xfer:xf_send_status(State1#state.xf, ReqId,
+ ssh_xfer:encode_erlang_status(Error)),
+ State1
+ end
end.
%% resolve all symlinks in a path
diff --git a/lib/ssh/src/ssh_xfer.hrl b/lib/ssh/src/ssh_xfer.hrl
index c13950eb6e..0d85cf2094 100644
--- a/lib/ssh/src/ssh_xfer.hrl
+++ b/lib/ssh/src/ssh_xfer.hrl
@@ -58,7 +58,6 @@
%%% # SSH_FX_xxx
%%% Description: Response packet types for file transfer protocol.
%%%----------------------------------------------------------------------
-
-define(SSH_FX_OK, 0).
-define(SSH_FX_EOF, 1).
-define(SSH_FX_NO_SUCH_FILE, 2).
@@ -79,7 +78,18 @@
-define(SSH_FX_LOCK_CONFlICT, 17).
-define(SSH_FX_DIR_NOT_EMPTY, 18).
-define(SSH_FX_NOT_A_DIRECTORY, 19).
+-define(SSH_FX_INVALID_FILENAME, 20).
+-define(SSH_FX_LINK_LOOP, 21).
+-define(SSH_FX_CANNOT_DELETE, 22).
+-define(SSH_FX_INVALID_PARAMETER, 23).
-define(SSH_FX_FILE_IS_A_DIRECTORY, 24).
+-define(SSH_FX_BYTE_RANGE_LOCK_CONFLICT,25).
+-define(SSH_FX_BYTE_RANGE_LOCK_REFUSED, 26).
+-define(SSH_FX_DELETE_PENDING, 27).
+-define(SSH_FX_FILE_CORRUPT, 28).
+-define(SSH_FX_OWNER_INVALID, 29).
+-define(SSH_FX_GROUP_INVALID, 30).
+-define(SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK,31).
%%%----------------------------------------------------------------------
%%% # SSH_FILEXFER_xxx
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index b995eb9f0e..ad4652521f 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -58,7 +58,8 @@ all() ->
links,
ver3_rename,
relpath,
- sshd_read_file].
+ sshd_read_file,
+ ver6_basic].
groups() ->
[].
@@ -128,6 +129,8 @@ init_per_testcase(TestCase, Config) ->
ProtocolVer = case atom_to_list(TestCase) of
"ver3_" ++ _ ->
3;
+ "ver6_" ++ _ ->
+ 6;
_ ->
?SSH_SFTP_PROTOCOL_VERSION
end,
@@ -591,7 +594,18 @@ sshd_read_file(Config) when is_list(Config) ->
read_file(Handle, 100, 0, Cm, Channel, NewReqId),
{ok, Data} = file:read_file(FileName).
-
+ver6_basic(doc) ->
+ ["Test SFTP Version 6"];
+ver6_basic(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ %FileName = filename:join(PrivDir, "test.txt"),
+ {Cm, Channel} = ?config(sftp, Config),
+ ReqId = 0,
+ {ok, <>, _} =
+ open_file(PrivDir, Cm, Channel, ReqId,
+ ?ACE4_READ_DATA bor ?ACE4_READ_ATTRIBUTES,
+ ?SSH_FXF_OPEN_EXISTING).
%%--------------------------------------------------------------------
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
--
cgit v1.2.3
From 6c82d9eb6476216458a5762edb41cecd3d4d595e Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Tue, 27 Nov 2012 16:50:15 +0100
Subject: Added a file_is_a_directory to a proper status return
---
lib/ssh/src/ssh_xfer.erl | 2 ++
1 file changed, 2 insertions(+)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh_xfer.erl b/lib/ssh/src/ssh_xfer.erl
index d5b6dd03d1..e72e2e982f 100644
--- a/lib/ssh/src/ssh_xfer.erl
+++ b/lib/ssh/src/ssh_xfer.erl
@@ -383,6 +383,7 @@ decode_status(Status) ->
?SSH_FX_UNKNOWN_PRINCIPLE -> unknown_principle;
?SSH_FX_LOCK_CONFlICT -> lock_conflict;
?SSH_FX_NOT_A_DIRECTORY -> not_a_directory;
+ ?SSH_FX_FILE_IS_A_DIRECTORY -> file_is_a_directory;
_ -> {error,Status}
end.
@@ -392,6 +393,7 @@ encode_erlang_status(Status) ->
eof -> ?SSH_FX_EOF;
enoent -> ?SSH_FX_NO_SUCH_FILE;
eacces -> ?SSH_FX_PERMISSION_DENIED;
+ eisdir -> ?SSH_FX_FILE_IS_A_DIRECTORY;
_ -> ?SSH_FX_FAILURE
end.
--
cgit v1.2.3
From 6801fa8751fe1d495099230f5d49867fd8a91cfc Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 10:04:25 +0100
Subject: Changes to sftpd test suite
---
lib/ssh/test/ssh_sftpd_SUITE.erl | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index ad4652521f..ab6ff4cac2 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -108,11 +108,19 @@ init_per_testcase(TestCase, Config) ->
Port = ssh_test_lib:inet_port(node()),
- {ok, Sftpd} =
- ssh_sftpd:listen(Port, [{system_dir, SystemDir},
- {user_dir, PrivDir},
- {user_passwords,[{?USER, ?PASSWD}]},
- {pwdfun, fun(_,_) -> true end}]),
+ {ok, Sftpd} = case TestCase of
+ ver6_basic ->
+ ssh_sftpd:listen(Port, [{system_dir, SystemDir},
+ {user_dir, PrivDir},
+ {user_passwords,[{?USER, ?PASSWD}]},
+ {pwdfun, fun(_,_) -> true end},
+ {sftp_vsn, 6}]);
+ _ ->
+ ssh_sftpd:listen(Port, [{system_dir, SystemDir},
+ {user_dir, PrivDir},
+ {user_passwords,[{?USER, ?PASSWD}]},
+ {pwdfun, fun(_,_) -> true end}])
+ end,
Cm = ssh_test_lib:connect(Port,
[{user_dir, ClientUserDir},
@@ -129,8 +137,6 @@ init_per_testcase(TestCase, Config) ->
ProtocolVer = case atom_to_list(TestCase) of
"ver3_" ++ _ ->
3;
- "ver6_" ++ _ ->
- 6;
_ ->
?SSH_SFTP_PROTOCOL_VERSION
end,
--
cgit v1.2.3
From 3051d7a5833eb8cd4903a5fec749549de27a3c8d Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 10:52:45 +0100
Subject: corrected is_dir call in sftpd
---
lib/ssh/src/ssh_sftpd.erl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index d6a7ee3859..21ba98a3e1 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -369,7 +369,8 @@ handle_op(?SSH_FXP_FSETSTAT, ReqId, <>,
State0 = #state{file_handler = FileMod, file_state = FS0, xf = #ssh_xfer{vsn = Vsn}}) ->
Path = relate_file_name(BPath, State0),
- case FileMod:is_dir(Path) of %% This version 6 we still have ver 5
+ {IsDir, _FS1} = FileMod:is_dir(Path, FS0),
+ case IsDir of %% This version 6 we still have ver 5
true when Vsn > 5 ->
ssh_xfer:xf_send_status(State0#state.xf, ReqId,
?SSH_FX_FILE_IS_A_DIRECTORY, "File is a directory");
@@ -641,7 +642,8 @@ do_open(ReqId, State0, Path, Flags) ->
#state{file_handler = FileMod, file_state = FS0, root = Root, xf = #ssh_xfer{vsn = Vsn}} = State0,
XF = State0#state.xf,
F = [binary | Flags],
- case FileMod:is_dir(Path) of
+ {IsDir, _FS1} = FileMod:is_dir(Path, FS0),
+ case IsDir of
true when Vsn > 5 ->
ssh_xfer:xf_send_status(State0#state.xf, ReqId,
?SSH_FX_FILE_IS_A_DIRECTORY, "File is a directory");
--
cgit v1.2.3
From 3b697a2e0de3dc02461d811b8714ad91470b9e2c Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 11:48:11 +0100
Subject: changed option to sftpd_vsn
---
lib/ssh/src/ssh.erl | 4 ++--
lib/ssh/src/ssh_sftpd.erl | 2 +-
lib/ssh/test/ssh_sftpd_SUITE.erl | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 22c55f8bf0..e089dd20bd 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -364,7 +364,7 @@ handle_option([{quiet_mode, _} = Opt|Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([{idle_time, _} = Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
-handle_option([{sftp_vsn, _} = Opt | Rest], SocketOptions, SshOptions) ->
+handle_option([{sftpd_vsn, _} = Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, [handle_inet_option(Opt) | SocketOptions], SshOptions).
@@ -442,7 +442,7 @@ handle_ssh_option({quiet_mode, Value} = Opt) when Value == true;
Opt;
handle_ssh_option({idle_time, Value} = Opt) when is_integer(Value), Value > 0 ->
Opt;
-handle_ssh_option({sftp_vsn, Value} = Opt) when is_integer(Value), Value > 0, Value < 7 ->
+handle_ssh_option({sftpd_vsn, Value} = Opt) when is_integer(Value), Value =:= 6 ->
Opt;
handle_ssh_option(Opt) ->
throw({error, {eoptions, Opt}}).
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index 21ba98a3e1..d4d6e4a9a7 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -119,7 +119,7 @@ init(Options) ->
{Root0, State0}
end,
MaxLength = proplists:get_value(max_files, Options, 0),
- Vsn = proplists:get_value(sftp_vsn, Options, 5),
+ Vsn = proplists:get_value(sftpd_vsn, Options, 5),
{ok, State#state{cwd = CWD, root = Root, max_files = MaxLength,
handles = [], pending = <<>>,
xf = #ssh_xfer{vsn = Vsn, ext = []}}}.
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index ab6ff4cac2..9877d39ec4 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -114,7 +114,7 @@ init_per_testcase(TestCase, Config) ->
{user_dir, PrivDir},
{user_passwords,[{?USER, ?PASSWD}]},
{pwdfun, fun(_,_) -> true end},
- {sftp_vsn, 6}]);
+ {sftpd_vsn, 6}]);
_ ->
ssh_sftpd:listen(Port, [{system_dir, SystemDir},
{user_dir, PrivDir},
--
cgit v1.2.3
From 0935ad3069a1372e40cf20631ede94181ef01353 Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 15:23:18 +0100
Subject: Changed testcases to proper sftpd listening
---
lib/ssh/test/ssh_sftpd_SUITE.erl | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index 9877d39ec4..2f81e89433 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -107,19 +107,17 @@ init_per_testcase(TestCase, Config) ->
SystemDir = filename:join(?config(priv_dir, Config), system),
Port = ssh_test_lib:inet_port(node()),
-
+ Options = [{system_dir, SystemDir},
+ {user_dir, PrivDir},
+ {user_passwords,[{?USER, ?PASSWD}]},
+ {pwdfun, fun(_,_) -> true end}],
{ok, Sftpd} = case TestCase of
ver6_basic ->
- ssh_sftpd:listen(Port, [{system_dir, SystemDir},
- {user_dir, PrivDir},
- {user_passwords,[{?USER, ?PASSWD}]},
- {pwdfun, fun(_,_) -> true end},
- {sftpd_vsn, 6}]);
+ SubSystems = [ssh_sftpd:subsystem_spec([{sftpd_vsn, 6}])],
+ ssh:daemon(Port, [{subsystems, SubSystems}|Options]);
_ ->
- ssh_sftpd:listen(Port, [{system_dir, SystemDir},
- {user_dir, PrivDir},
- {user_passwords,[{?USER, ?PASSWD}]},
- {pwdfun, fun(_,_) -> true end}])
+ SubSystems = [ssh_sftpd:subsystem_spec([])],
+ ssh:daemon(Port, [{subsystems, SubSystems}|Options])
end,
Cm = ssh_test_lib:connect(Port,
--
cgit v1.2.3
From 5a1f7a4d4d705e302e748c45db9a8fd9fc28eca1 Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 15:34:49 +0100
Subject: Updated doc for sftpd_vsn
---
lib/ssh/doc/src/ssh_sftpd.xml | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'lib/ssh')
diff --git a/lib/ssh/doc/src/ssh_sftpd.xml b/lib/ssh/doc/src/ssh_sftpd.xml
index b3d64e72b4..3b814ec9dd 100644
--- a/lib/ssh/doc/src/ssh_sftpd.xml
+++ b/lib/ssh/doc/src/ssh_sftpd.xml
@@ -86,6 +86,11 @@
the user will end up in /tmp/etc.
+
+ -
+
Sets the sftp version to use, defaults to 5. Version 6 is under
+ development and limited.
+
--
cgit v1.2.3
From b5f755bab947c220c6ec434b121ccbc1d0a2476e Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Wed, 28 Nov 2012 16:26:21 +0100
Subject: sftp ver6 mods, SSH_FX_CANNOT_DELETE added as parameter
---
lib/ssh/src/ssh_xfer.erl | 2 ++
1 file changed, 2 insertions(+)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh_xfer.erl b/lib/ssh/src/ssh_xfer.erl
index e72e2e982f..91607ce69c 100644
--- a/lib/ssh/src/ssh_xfer.erl
+++ b/lib/ssh/src/ssh_xfer.erl
@@ -384,6 +384,7 @@ decode_status(Status) ->
?SSH_FX_LOCK_CONFlICT -> lock_conflict;
?SSH_FX_NOT_A_DIRECTORY -> not_a_directory;
?SSH_FX_FILE_IS_A_DIRECTORY -> file_is_a_directory;
+ ?SSH_FX_CANNOT_DELETE -> cannot_delete;
_ -> {error,Status}
end.
@@ -394,6 +395,7 @@ encode_erlang_status(Status) ->
enoent -> ?SSH_FX_NO_SUCH_FILE;
eacces -> ?SSH_FX_PERMISSION_DENIED;
eisdir -> ?SSH_FX_FILE_IS_A_DIRECTORY;
+ eperm -> ?SSH_FX_CANNOT_DELETE;
_ -> ?SSH_FX_FAILURE
end.
--
cgit v1.2.3
From 179e47446a5940acfdde5dea38d1b318520ad464 Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Thu, 29 Nov 2012 11:36:13 +0100
Subject: Changed erlclient testcases for sftp
---
lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl | 21 ++++++++++++++++++---
.../ssh_sftpd_file_alt.erl | 2 +-
2 files changed, 19 insertions(+), 4 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
index 7fc2312661..c2cea76953 100644
--- a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
@@ -42,7 +42,8 @@ all() ->
quit,
file_cb,
root_dir,
- list_dir_limited].
+ list_dir_limited,
+ ver6_basic].
groups() ->
[].
@@ -112,7 +113,12 @@ init_per_testcase(TestCase, Config) ->
[{system_dir, SystemDir},
{user_dir, PrivDir},
{subsystems, [Spec]}];
-
+ "ver6_basic" ->
+ Spec =
+ ssh_sftpd:subsystem_spec([{sftpd_vsn, 6}]),
+ [{system_dir, SystemDir},
+ {user_dir, PrivDir},
+ {subsystems, [Spec]}];
_ ->
[{user_dir, PrivDir},
{system_dir, SystemDir}]
@@ -232,7 +238,7 @@ file_cb(Config) when is_list(Config) ->
NewDir = filename:join(PrivDir, "testdir"),
ok = ssh_sftp:make_dir(Sftp, NewDir),
alt_file_handler_check(alt_make_dir),
-
+
ok = ssh_sftp:del_dir(Sftp, NewDir),
alt_file_handler_check(alt_read_link_info),
alt_file_handler_check(alt_write_file_info),
@@ -260,6 +266,15 @@ list_dir_limited(Config) when is_list(Config) ->
ssh_sftp:list_dir(Sftp, "."),
ct:pal("Listing: ~p~n", [Listing]).
+ver6_basic(doc) ->
+ ["Test some version 6 features"];
+ver6_basic(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ NewDir = filename:join(PrivDir, "testdir"),
+ {Sftp, _} = ?config(sftp, Config),
+ %ok = ssh_sftp:make_dir(Sftp, NewDir),
+ %%Test file_is_a_directory
+ {error, file_is_a_directory} = ssh_sftp:delete(Sftp, NewDir).
%%--------------------------------------------------------------------
%% Internal functions ------------------------------------------------
%%--------------------------------------------------------------------
diff --git a/lib/ssh/test/ssh_sftpd_erlclient_SUITE_data/ssh_sftpd_file_alt.erl b/lib/ssh/test/ssh_sftpd_erlclient_SUITE_data/ssh_sftpd_file_alt.erl
index 9e119c4929..9f8a7c496c 100644
--- a/lib/ssh/test/ssh_sftpd_erlclient_SUITE_data/ssh_sftpd_file_alt.erl
+++ b/lib/ssh/test/ssh_sftpd_erlclient_SUITE_data/ssh_sftpd_file_alt.erl
@@ -48,7 +48,7 @@ get_cwd(State) ->
{file:get_cwd(), State}.
is_dir(AbsPath, State) ->
- sftpd_file_alt_tester ! alt_is_dir,
+ %sftpd_file_alt_tester ! alt_is_dir,
{filelib:is_dir(AbsPath), State}.
list_dir(AbsPath, State) ->
--
cgit v1.2.3
From b66486468476734419ec4e3aa9cbac766aa012fe Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Thu, 29 Nov 2012 14:12:15 +0100
Subject: Added eexist to return proper sftp parameter
---
lib/ssh/src/ssh_xfer.erl | 1 +
1 file changed, 1 insertion(+)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh_xfer.erl b/lib/ssh/src/ssh_xfer.erl
index 91607ce69c..4dfd9ed8b0 100644
--- a/lib/ssh/src/ssh_xfer.erl
+++ b/lib/ssh/src/ssh_xfer.erl
@@ -396,6 +396,7 @@ encode_erlang_status(Status) ->
eacces -> ?SSH_FX_PERMISSION_DENIED;
eisdir -> ?SSH_FX_FILE_IS_A_DIRECTORY;
eperm -> ?SSH_FX_CANNOT_DELETE;
+ eexist -> ?SSH_FX_FILE_ALREADY_EXISTS;
_ -> ?SSH_FX_FAILURE
end.
--
cgit v1.2.3
From 19c560d98202b87e5b158f673fd48ba347e623ee Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson
Date: Thu, 29 Nov 2012 14:59:13 +0100
Subject: Removed unused code ssh.erl and changed tests
---
lib/ssh/src/ssh.erl | 4 ----
lib/ssh/test/ssh_sftpd_SUITE.erl | 2 +-
lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl | 4 ++--
3 files changed, 3 insertions(+), 7 deletions(-)
(limited to 'lib/ssh')
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index e089dd20bd..719c97e940 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -364,8 +364,6 @@ handle_option([{quiet_mode, _} = Opt|Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([{idle_time, _} = Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
-handle_option([{sftpd_vsn, _} = Opt | Rest], SocketOptions, SshOptions) ->
- handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, [handle_inet_option(Opt) | SocketOptions], SshOptions).
@@ -442,8 +440,6 @@ handle_ssh_option({quiet_mode, Value} = Opt) when Value == true;
Opt;
handle_ssh_option({idle_time, Value} = Opt) when is_integer(Value), Value > 0 ->
Opt;
-handle_ssh_option({sftpd_vsn, Value} = Opt) when is_integer(Value), Value =:= 6 ->
- Opt;
handle_ssh_option(Opt) ->
throw({error, {eoptions, Opt}}).
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index 2f81e89433..5aa46872ee 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -348,7 +348,7 @@ mk_rm_dir(Config) when is_list(Config) ->
_/binary>>, _} = mkdir(DirName, Cm, Channel, ReqId),
NewReqId = 1,
- {ok, <>, _} = mkdir(DirName, Cm, Channel, NewReqId),
NewReqId1 = 2,
diff --git a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
index c2cea76953..8f722941d4 100644
--- a/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_erlclient_SUITE.erl
@@ -270,9 +270,9 @@ ver6_basic(doc) ->
["Test some version 6 features"];
ver6_basic(Config) when is_list(Config) ->
PrivDir = ?config(priv_dir, Config),
- NewDir = filename:join(PrivDir, "testdir"),
+ NewDir = filename:join(PrivDir, "testdir2"),
{Sftp, _} = ?config(sftp, Config),
- %ok = ssh_sftp:make_dir(Sftp, NewDir),
+ ok = ssh_sftp:make_dir(Sftp, NewDir),
%%Test file_is_a_directory
{error, file_is_a_directory} = ssh_sftp:delete(Sftp, NewDir).
%%--------------------------------------------------------------------
--
cgit v1.2.3