[PATCH] libcli: Overwrite destination in cli_smb2_rename

Jeremy Allison jra at samba.org
Tue Aug 5 15:27:44 MDT 2014


On Tue, Aug 05, 2014 at 11:12:53PM +0200, Stefan (metze) Metzmacher wrote:
> Am 05.08.2014 um 20:47 schrieb Jeremy Allison:
> > On Tue, Aug 05, 2014 at 06:42:16PM +0100, Ross Lagerwall wrote:
> >> Overwrite the destination in cli_smb2_rename by setting the
> >> ReplaceIfExists byte to TRUE.
> >>
> >> Signed-off-by: Ross Lagerwall <rosslagerwall at gmail.com>
> >> ---
> >>  source3/libsmb/cli_smb2_fnum.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
> >> index 3a04ea1..1c08f7f 100644
> >> --- a/source3/libsmb/cli_smb2_fnum.c
> >> +++ b/source3/libsmb/cli_smb2_fnum.c
> >> @@ -1910,6 +1910,7 @@ NTSTATUS cli_smb2_rename(struct cli_state *cli,
> >>  		goto fail;
> >>  	}
> >>  
> >> +	SCVAL(inbuf.data, 0, 0xFF);
> >>  	SIVAL(inbuf.data, 16, converted_size_bytes);
> >>  	memcpy(inbuf.data + 20, converted_str, converted_size_bytes);
> >>  
> >> -- 
> >> 2.0.3
> > 
> > I'd prefer SCVAL(inbuf.data, 0, 0x1), but other
> > than that LGTM. Reviewed-by: Jeremy Allison <jra at samba.org>
> > 
> > Can I get a second Team reviewer ?
> 
> I'm not sure this is correct.
> 
> [MS-CIFS] 3.3.5.10 Receiving an SMB_COM_RENAME Request
> http://msdn.microsoft.com/en-us/library/ee441650.aspx
> 
> says If there is an existing file with the new name, the rename MUST
> fail with STATUS_OBJECT_NAME_COLLISION.
> 
> I think cli_rename() should be consistent between SMB1 and SMB2.

Oh that's a pain, as POSIX rename overwrites by default,
which is what we want for libsmbclient really :-(.

SMB1 has several methods of renaming, the NTTrans
rename overwrites the destination by default.

Maybe we could also change cli_rename() to call the NTTrans
varient for SMB1 and then the rename semantics would
be the same between SMB1 and SMB2 for cli_rename()
(although different from what they are now) ?

But yeah, that patch would have to be combined
with this one to keep both protocol behaviours
consistent.

Jeremy.


More information about the samba-technical mailing list