From 4ad7238ba71b818fa0e3a1ea24bb002daeb11f3a Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Wed, 29 Feb 2012 12:28:57 +0100 Subject: sftp daemon generates file handles correct Also always run ssh_sftp_SUITE against own daemon as well as openssh if existing. Corrected links test case and found that openssh has a known bug that swaps the create link arguments. Created separate ticket (OTP-9951) to deal with this. --- lib/ssh/src/ssh_sftpd.erl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/ssh/src') diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl index 8cc414f83a..ec7b76b0b3 100644 --- a/lib/ssh/src/ssh_sftpd.erl +++ b/lib/ssh/src/ssh_sftpd.erl @@ -424,18 +424,18 @@ handle_op(?SSH_FXP_RENAME, ReqId, State0 end; handle_op(?SSH_FXP_SYMLINK, ReqId, - <>, + <>, State0 = #state{file_handler = FileMod, file_state = FS0}) -> - Path = relate_file_name(BPath, State0), - Path2 = relate_file_name(BPath2, State0), - {Status, FS1} = FileMod:make_symlink(Path2, Path, FS0), + LinkPath = relate_file_name(Link, State0), + TargetPath = relate_file_name(Target, State0), + {Status, FS1} = FileMod:make_symlink(TargetPath, LinkPath, FS0), State1 = State0#state{file_state = FS1}, send_status(Status, ReqId, State1). new_handle([], H) -> H; -new_handle([{N, _} | Rest], H) when N > H -> +new_handle([{N, _,_} | Rest], H) when N =< H -> new_handle(Rest, N+1); new_handle([_ | Rest], H) -> new_handle(Rest, H). @@ -444,6 +444,8 @@ add_handle(State, XF, ReqId, Type, DirFileTuple) -> Handles = State#state.handles, Handle = new_handle(Handles, 0), ssh_xfer:xf_send_handle(XF, ReqId, integer_to_list(Handle)), + %% OBS: If you change handles-tuple also change new_handle! + %% Is this this the best way to implement new handle? State#state{handles = [{Handle, Type, DirFileTuple} | Handles]}. get_handle(Handles, BinHandle) -> -- cgit v1.2.3