From 96b9842e31f975500f37373af1543214f078188e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Sep 2020 12:30:53 -0700 Subject: [PATCH] s3: smbd: unlink_internals() can figure out if the mask has a wildcard on its own. Doesn't need a parameter for that. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/printing/nt_printing.c | 2 +- source3/smbd/proto.h | 3 +-- source3/smbd/reply.c | 18 ++++++++++++++---- source3/smbd/trans2.c | 3 +-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 355953fa222..e57ff3404de 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -2040,7 +2040,7 @@ static NTSTATUS driver_unlink_internals(connection_struct *conn, goto err_out; } - status = unlink_internals(conn, NULL, 0, smb_fname, false); + status = unlink_internals(conn, NULL, 0, smb_fname); err_out: talloc_free(tmp_ctx); return status; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 5fa101c3622..b2dfdb21b1b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1000,8 +1000,7 @@ void reply_ulogoffX(struct smb_request *req); void reply_mknew(struct smb_request *req); void reply_ctemp(struct smb_request *req); NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, - uint32_t dirtype, struct smb_filename *smb_fname, - bool has_wild); + uint32_t dirtype, struct smb_filename *smb_fname); void reply_unlink(struct smb_request *req); ssize_t fake_sendfile(struct smbXsrv_connection *xconn, files_struct *fsp, off_t startpos, size_t nread); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index f46f0c5a644..7a8d7c766eb 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3369,14 +3369,14 @@ static NTSTATUS do_unlink(connection_struct *conn, ****************************************************************************/ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, - uint32_t dirtype, struct smb_filename *smb_fname, - bool has_wild) + uint32_t dirtype, struct smb_filename *smb_fname) { char *fname_dir = NULL; char *fname_mask = NULL; int count=0; NTSTATUS status = NT_STATUS_OK; struct smb_filename *smb_fname_dir = NULL; + bool has_wild = false; TALLOC_CTX *ctx = talloc_tos(); /* Split up the directory from the filename/mask. */ @@ -3386,6 +3386,17 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, goto out; } + if (req != NULL && !req->posix_pathnames) { + /* + * Check the wildcard mask *before* + * unmangling. As mangling is done + * for names that can't be returned + * to Windows the unmangled name may + * contain Windows wildcard characters. + */ + has_wild = ms_has_wild(fname_mask); + } + /* * We should only check the mangled cache * here if unix_convert failed. This means @@ -3642,8 +3653,7 @@ void reply_unlink(struct smb_request *req) DEBUG(3,("reply_unlink : %s\n", smb_fname_str_dbg(smb_fname))); - status = unlink_internals(conn, req, dirtype, smb_fname, - path_contains_wcard); + status = unlink_internals(conn, req, dirtype, smb_fname); if (!NT_STATUS_IS_OK(status)) { if (open_was_deferred(req->xconn, req->mid)) { /* We have re-scheduled this call. */ diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 1ab0195d951..c6bdb5803f0 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -6479,8 +6479,7 @@ NTSTATUS hardlink_internals(TALLOC_CTX *ctx, status = unlink_internals(conn, req, FILE_ATTRIBUTE_NORMAL, - smb_fname_new, - false); + smb_fname_new); if (!NT_STATUS_IS_OK(status)) { return status; } -- 2.34.1