From: Jeremy Allison Date: Mon, 5 Oct 2020 19:16:32 +0000 (-0700) Subject: s3: smbd: Fix SMB1 reply_mv() to handle wildcards. X-Git-Tag: talloc-2.3.2~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f696d29fcca81ccd6a8ad3296a6ffc1780e560b4;p=thirdparty%2Fsamba.git s3: smbd: Fix SMB1 reply_mv() to handle wildcards. Pass in the original source last component to rename_internals() from reply_mv(). Change the wildcard detection in rename_internals() to look at the correct thing for the source path. This is now correctly set only from the unmangled last component of the source path sent to reply_mv(). We now pass: Samba3.smbtorture_s3.crypt_client.SMB1-WILD-MANGLE-RENAME(nt4_dc_smb1) samba3.smbtorture_s3.plain.SMB1-WILD-MANGLE-RENAME(fileserver_smb1) so remove the knownfail. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Thu Oct 8 16:29:27 UTC 2020 on sn-devel-184 --- diff --git a/selftest/knownfail.d/smb1-wild-mangle-rename b/selftest/knownfail.d/smb1-wild-mangle-rename deleted file mode 100644 index 8f1c036b139..00000000000 --- a/selftest/knownfail.d/smb1-wild-mangle-rename +++ /dev/null @@ -1,3 +0,0 @@ -# Check SMB1 wildcard demangle -^samba3.smbtorture_s3.plain.SMB1-WILD-MANGLE-RENAME.smbtorture\(fileserver_smb1\) -^samba3.smbtorture_s3.crypt_client.SMB1-WILD-MANGLE-RENAME.smbtorture\(nt4_dc_smb1\) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 43bf9bb7994..51f95f565c0 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -7909,7 +7909,9 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, * to Windows the unmangled name may * contain Windows wildcard characters. */ - src_has_wild = ms_has_wild(fname_src_mask); + if (src_original_lcomp != NULL) { + src_has_wild = ms_has_wild(src_original_lcomp); + } dest_has_wild = ms_has_wild(dst_original_lcomp); } @@ -8264,6 +8266,7 @@ void reply_mv(struct smb_request *req) NTSTATUS status; TALLOC_CTX *ctx = talloc_tos(); struct smb_filename *smb_fname_src = NULL; + const char *src_original_lcomp = NULL; struct smb_filename *smb_fname_dst = NULL; const char *dst_original_lcomp = NULL; uint32_t src_ucf_flags = ucf_flags_from_smb_request(req) | @@ -8329,6 +8332,16 @@ void reply_mv(struct smb_request *req) goto out; } + /* Get the last component of the source for rename_internals(). */ + src_original_lcomp = get_original_lcomp(ctx, + conn, + name, + dst_ucf_flags); + if (src_original_lcomp == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + goto out; + } + status = filename_convert(ctx, conn, newname, @@ -8375,7 +8388,7 @@ void reply_mv(struct smb_request *req) conn, req, smb_fname_src, - NULL, + src_original_lcomp, smb_fname_dst, dst_original_lcomp, attrs,