aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-02-17 11:43:33 +0100
committerHans Nilsson <[email protected]>2017-02-17 11:43:33 +0100
commita4758f2e75d213bac6e66e7749d5e4d049b90deb (patch)
tree7f2b2b632e41c1cebd78a6886caab647d5323764 /lib/ssh/src
parentaf4855549d2a7b1cf414b0e6c0568c0e151e1319 (diff)
parent1ca3a090fb9027aa140fea06f57aa22f8790940a (diff)
downloadotp-a4758f2e75d213bac6e66e7749d5e4d049b90deb.tar.gz
otp-a4758f2e75d213bac6e66e7749d5e4d049b90deb.tar.bz2
otp-a4758f2e75d213bac6e66e7749d5e4d049b90deb.zip
Merge branch 'ssh_sftpd_relative_path' into hans/ssh/sftpd_fixes/OTP-14225
Conflicts: lib/ssh/test/ssh_sftpd_SUITE.erl
Diffstat (limited to 'lib/ssh/src')
-rw-r--r--lib/ssh/src/ssh_sftpd.erl24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index bc30b7fb7d..9352046795 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -664,29 +664,25 @@ 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, xf = #ssh_xfer{vsn = Vsn}} = State0,
- XF = State0#state.xf,
- F = [binary | Flags],
- {IsDir, _FS1} = FileMod:is_dir(Path, FS0),
+ #state{file_handler = FileMod, file_state = FS0, xf = #ssh_xfer{vsn = Vsn}} = State0,
+ AbsPath = relate_file_name(Path, State0),
+ {IsDir, _FS1} = FileMod:is_dir(AbsPath, 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");
+ ?SSH_FX_FILE_IS_A_DIRECTORY, "File is a directory"),
+ State0;
true ->
ssh_xfer:xf_send_status(State0#state.xf, ReqId,
- ?SSH_FX_FAILURE, "File is a directory");
+ ?SSH_FX_FAILURE, "File is a directory"),
+ State0;
false ->
- AbsPath = case Root of
- "" ->
- Path;
- _ ->
- relate_file_name(Path, State0)
- end,
- {Res, FS1} = FileMod:open(AbsPath, F, FS0),
+ OpenFlags = [binary | Flags],
+ {Res, FS1} = FileMod:open(AbsPath, OpenFlags, FS0),
State1 = State0#state{file_state = FS1},
case Res of
{ok, IoDevice} ->
- add_handle(State1, XF, ReqId, file, {Path,IoDevice});
+ add_handle(State1, State0#state.xf, ReqId, file, {Path,IoDevice});
{error, Error} ->
ssh_xfer:xf_send_status(State1#state.xf, ReqId,
ssh_xfer:encode_erlang_status(Error)),