[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Fri Mar 31 21:22:02 UTC 2023


The branch, master has been updated
       via  47f401095ea smbd: squash check_path_syntax() variants
       via  1d220e3170b s3: smbd: Correctly process SMB3 POSIX paths in create.
       via  09221cea5a1 s3: smbd: Correctly set smb2req->smb1req->posix_pathnames from the calling fsp on SMB2 calls.
       via  3f33ea95eb6 smbd: Ensure share root POSIX attrs are cleared after mode_fn
       via  adfa3a428bd s3: smbd: Add check_path_syntax_smb2_posix().
       via  a8329d2536a s3: smbd: Flatten the check_path_syntax_smb2() wrapper.
      from  874e10ef79a s4:kdc: Add support for AD device claims

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 47f401095ea723cbca6a8fc1a841465a32852cdc
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Mar 31 11:44:00 2023 +0200

    smbd: squash check_path_syntax() variants
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Fri Mar 31 21:21:57 UTC 2023 on atb-devel-224

commit 1d220e3170b1eb2afbff48d0148e30f8cec9fba0
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 28 13:55:49 2023 -0700

    s3: smbd: Correctly process SMB3 POSIX paths in create.
    
    Remove knownfail for  posix path handling of case/reserved char
    
    Signed-off-by: David Mulder <dmulder at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 09221cea5a19034fd19394134cd2d9c3181966ca
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 28 13:53:20 2023 -0700

    s3: smbd: Correctly set smb2req->smb1req->posix_pathnames from the calling fsp on SMB2 calls.
    
    We must always do SMB3+POSIX operations on fsp's opened with a posix create context.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3f33ea95eb654ab41636f2216002d7916fc56521
Author: David Mulder <dmulder at samba.org>
Date:   Thu Dec 1 10:53:44 2022 -0700

    smbd: Ensure share root POSIX attrs are cleared after mode_fn
    
    The call to mode_fn (smbd_dirptr_lanman2_mode_fn)
    was filling the cleared attributes back in to the
    stat. Ensure the clear happens after this call.
    
    Signed-off-by: David Mulder <dmulder at samba.org>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit adfa3a428bda14a19ef506203d82d055ee98f1be
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 28 11:06:36 2023 -0700

    s3: smbd: Add check_path_syntax_smb2_posix().
    
    Not yet used. Simple wrapper, identical to check_path_syntax_posix().
    I want to keep SMB1/SMB2 code as separate as possible so
    we can remove any SMB1 code path later.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a8329d2536a9333d63a7b2fd5106377364fde42a
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 28 11:03:59 2023 -0700

    s3: smbd: Flatten the check_path_syntax_smb2() wrapper.
    
    Keep it, rather and move all SMB2 code to check_path_syntax()
    as I want to keep SMB1/SMB2 code as separate as possible so
    we can remove any SMB1 code path later.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 selftest/knownfail.d/smb3unix       |  2 --
 source3/smbd/dir.c                  | 21 ++++++++++++-------
 source3/smbd/globals.h              |  3 ++-
 source3/smbd/msdfs.c                |  6 +++---
 source3/smbd/proto.h                |  4 +---
 source3/smbd/smb1_reply.c           |  2 +-
 source3/smbd/smb2_break.c           |  2 +-
 source3/smbd/smb2_close.c           |  2 +-
 source3/smbd/smb2_create.c          | 40 ++++++++++++++++++++++-------------
 source3/smbd/smb2_flush.c           |  2 +-
 source3/smbd/smb2_getinfo.c         |  2 +-
 source3/smbd/smb2_glue.c            |  7 ++++++-
 source3/smbd/smb2_ioctl.c           |  2 +-
 source3/smbd/smb2_lock.c            |  2 +-
 source3/smbd/smb2_notify.c          |  2 +-
 source3/smbd/smb2_query_directory.c |  2 +-
 source3/smbd/smb2_read.c            |  2 +-
 source3/smbd/smb2_reply.c           | 42 +++----------------------------------
 source3/smbd/smb2_setinfo.c         |  2 +-
 source3/smbd/smb2_trans2.c          |  6 ++++--
 source3/smbd/smb2_write.c           |  2 +-
 21 files changed, 71 insertions(+), 84 deletions(-)
 delete mode 100644 selftest/knownfail.d/smb3unix


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail.d/smb3unix b/selftest/knownfail.d/smb3unix
deleted file mode 100644
index 2ab886ae75e..00000000000
--- a/selftest/knownfail.d/smb3unix
+++ /dev/null
@@ -1,2 +0,0 @@
-^samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_posix_reserved_char\(fileserver\)
-^samba.tests.smb3unix.samba.tests.smb3unix.Smb3UnixTests.test_posix_case_sensitive\(fileserver\)
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 859c8f0dc83..09029ee0c23 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -979,13 +979,6 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
 			smb_fname = tmp_smb_fname;
 			mode = FILE_ATTRIBUTE_DIRECTORY;
 			get_dosmode = false;
-
-			/* Ensure posix fileid and sids are hidden
-			 */
-			smb_fname->st.st_ex_ino = 0;
-			smb_fname->st.st_ex_dev = 0;
-			smb_fname->st.st_ex_uid = -1;
-			smb_fname->st.st_ex_gid = -1;
 		}
 
 		ok = mode_fn(ctx,
@@ -1005,6 +998,20 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
 
 		TALLOC_FREE(atname);
 
+		/*
+		 * Don't leak INO/DEV/User SID/Group SID about the containing
+		 * directory of the share. This MUST happen AFTER the call to
+		 * mode_fn().
+		 */
+		if (dirptr_path_is_dot && ISDOTDOT(dname)) {
+			/* Ensure posix fileid and sids are hidden
+			 */
+			smb_fname->st.st_ex_ino = 0;
+			smb_fname->st.st_ex_dev = 0;
+			smb_fname->st.st_ex_uid = -1;
+			smb_fname->st.st_ex_gid = -1;
+		}
+
 		/*
 		 * The only valid cases where we return the directory entry if
 		 * it's a symlink are:
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 5fb9f2e647c..ff69d95ddfb 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -277,7 +277,8 @@ NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req,
 					 struct tevent_req *subreq,
 					 uint32_t defer_time);
 
-struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req);
+struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req,
+					       struct files_struct *fsp);
 size_t smbd_smb2_unread_bytes(struct smbd_smb2_request *req);
 void remove_smb2_chained_fsp(files_struct *fsp);
 
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index a0b59da1fcf..dfb801a3f55 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -55,7 +55,7 @@
      \pathname.
 
  If returned, remainingpath is untouched. Caller must call
- check_path_syntaxXXX() on it.
+ check_path_syntax() on it.
 
  Called by all non-fileserver processing (DFS RPC, FSCTL_DFS_GET_REFERRALS)
  etc. Errors out on any inconsistency in the path.
@@ -947,7 +947,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 	}
 
 	/* Path referrals are always non-POSIX. */
-	status = check_path_syntax(reqpath);
+	status = check_path_syntax(reqpath, false);
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(frame);
 		return status;
@@ -1194,7 +1194,7 @@ bool create_junction(TALLOC_CTX *ctx,
 	}
 
 	/* Junction create paths are always non-POSIX. */
-	status = check_path_syntax(reqpath);
+	status = check_path_syntax(reqpath, false);
 	if (!NT_STATUS_IS_OK(status)) {
 		return false;
 	}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index e8b3034970e..c5c0c161867 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -928,9 +928,7 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
 
 /* The following definitions come from smbd/smb2_reply.c  */
 
-NTSTATUS check_path_syntax(char *path);
-NTSTATUS check_path_syntax_posix(char *path);
-NTSTATUS check_path_syntax_smb2(char *path);
+NTSTATUS check_path_syntax(char *path, bool posix);
 NTSTATUS smb1_strip_dfs_path(TALLOC_CTX *mem_ctx,
 			     uint32_t *ucf_flags,
 			     char **in_path);
diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c
index 3fc2cc8e793..7921d6b261b 100644
--- a/source3/smbd/smb1_reply.c
+++ b/source3/smbd/smb1_reply.c
@@ -73,7 +73,7 @@ bool check_fsp_open(connection_struct *conn, struct smb_request *req,
 /****************************************************************************
  SMB1 version of smb2_strip_dfs_path()
  Differs from SMB2 in that all Windows path separator '\' characters
- have already been converted to '/' by check_path_syntax_internal().
+ have already been converted to '/' by check_path_syntax().
 ****************************************************************************/
 
 NTSTATUS smb1_strip_dfs_path(TALLOC_CTX *mem_ctx,
diff --git a/source3/smbd/smb2_break.c b/source3/smbd/smb2_break.c
index e8f6b996101..f837b8eccc1 100644
--- a/source3/smbd/smb2_break.c
+++ b/source3/smbd/smb2_break.c
@@ -185,7 +185,7 @@ static struct tevent_req *smbd_smb2_oplock_break_send(TALLOC_CTX *mem_ctx,
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp),
 		  oplocklevel));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c
index ed2b21dc5bc..236d5b79f91 100644
--- a/source3/smbd/smb2_close.c
+++ b/source3/smbd/smb2_close.c
@@ -211,7 +211,7 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req,
 	DEBUG(10,("smbd_smb2_close: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(req);
+	smbreq = smbd_smb2_fake_smb_request(req, fsp);
 	if (smbreq == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index c17562e93e1..93c345f5809 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -452,6 +452,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req
 	NTTIME twrp = fsp->fsp_name->twrp;
 	NTSTATUS status;
 	bool is_dfs = (smb1req->flags2 & FLAGS2_DFS_PATHNAMES);
+	bool is_posix = (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
 
 	if (lease_ptr == NULL) {
 		if (fsp->oplock_type != LEASE_OPLOCK) {
@@ -511,7 +512,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req
 	}
 
 	/* This also converts '\' to '/' */
-	status = check_path_syntax_smb2(filename);
+	status = check_path_syntax(filename, is_posix);
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(filename);
 		return status;
@@ -741,6 +742,12 @@ static NTSTATUS smbd_smb2_create_fetch_create_ctx(
 
 		state->posx = smb2_create_blob_find(
 			in_context_blobs, SMB2_CREATE_TAG_POSIX);
+		/*
+		 * Setting the bool below will cause
+		 * ucf_flags_from_smb_request() to
+		 * return UCF_POSIX_PATHNAMES in ucf_flags.
+		 */
+		state->smb1req->posix_pathnames = true;
 	}
 
 	return NT_STATUS_OK;
@@ -771,6 +778,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 	struct smb_filename *smb_fname = NULL;
 	uint32_t ucf_flags;
 	bool is_dfs = false;
+	bool is_posix = false;
 
 	req = tevent_req_create(mem_ctx, &state,
 				struct smbd_smb2_create_state);
@@ -784,7 +792,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 		.in_create_disposition = in_create_disposition,
 	};
 
-	smb1req = smbd_smb2_fake_smb_request(smb2req);
+	smb1req = smbd_smb2_fake_smb_request(smb2req, NULL);
 	if (tevent_req_nomem(smb1req, req)) {
 		return tevent_req_post(req, state->ev);
 	}
@@ -1040,8 +1048,10 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 		state->lease_ptr = NULL;
 	}
 
+	is_posix = (state->posx != NULL);
+
 	/* convert '\\' into '/' */
-	status = check_path_syntax_smb2(state->fname);
+	status = check_path_syntax(state->fname, is_posix);
 	if (tevent_req_nterror(req, status)) {
 		return tevent_req_post(req, state->ev);
 	}
@@ -1089,10 +1099,17 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 	 * server MUST fail the request with
 	 * STATUS_INVALID_PARAMETER.
 	 */
-	if (in_name[0] == '\\' || in_name[0] == '/') {
-		tevent_req_nterror(req,
-				   NT_STATUS_INVALID_PARAMETER);
-		return tevent_req_post(req, state->ev);
+	if (in_name[0] == '/') {
+		/* Names starting with '/' are never allowed. */
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
+	}
+	if (!is_posix && (in_name[0] == '\\')) {
+		/*
+		 * Windows names starting with '\' are not allowed.
+		 */
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
 	}
 
 	status = SMB_VFS_CREATE_FILE(smb1req->conn,
@@ -1182,13 +1199,8 @@ static void smbd_smb2_create_before_exec(struct tevent_req *req)
 			return;
 		}
 
-		/*
-		 * NB. When SMB2+ unix extensions are added,
-		 * we need to relax this check in invalid
-		 * names - we used to not do this if
-		 * lp_posix_pathnames() was false.
-		 */
-		if (ea_list_has_invalid_name(state->ea_list)) {
+		if ((state->posx == NULL) &&
+		    ea_list_has_invalid_name(state->ea_list)) {
 			tevent_req_nterror(req, STATUS_INVALID_EA_NAME);
 			return;
 		}
diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c
index 5c8c171e418..2d3e6319697 100644
--- a/source3/smbd/smb2_flush.c
+++ b/source3/smbd/smb2_flush.c
@@ -140,7 +140,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_flush: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c
index 468010696fe..51283eb174e 100644
--- a/source3/smbd/smb2_getinfo.c
+++ b/source3/smbd/smb2_getinfo.c
@@ -277,7 +277,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_getinfo_send: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_glue.c b/source3/smbd/smb2_glue.c
index 543c0a0b9e6..563aaf88873 100644
--- a/source3/smbd/smb2_glue.c
+++ b/source3/smbd/smb2_glue.c
@@ -26,7 +26,8 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_SMB2
 
-struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
+struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req,
+					       struct files_struct *fsp)
 {
 	struct smb_request *smbreq;
 	const uint8_t *inhdr = SMBD_SMB2_IN_HDR_PTR(req);
@@ -67,6 +68,10 @@ struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
 	}
 	smbreq->mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID);
 	smbreq->chain_fsp = req->compat_chain_fsp;
+	if (fsp != NULL) {
+		smbreq->posix_pathnames =
+			(fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
+	}
 	smbreq->smb2req = req;
 	req->smb1req = smbreq;
 
diff --git a/source3/smbd/smb2_ioctl.c b/source3/smbd/smb2_ioctl.c
index e4f8c10e3af..2ca53e33788 100644
--- a/source3/smbd/smb2_ioctl.c
+++ b/source3/smbd/smb2_ioctl.c
@@ -445,7 +445,7 @@ static struct tevent_req *smbd_smb2_ioctl_send(TALLOC_CTX *mem_ctx,
 		   fsp ? fsp_str_dbg(fsp) : "<no handle>",
 		   fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 48593af4790..642e9c74151 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -237,7 +237,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 
 	tevent_req_set_cleanup_fn(req, smbd_smb2_lock_cleanup);
 
-	state->smb1req = smbd_smb2_fake_smb_request(smb2req);
+	state->smb1req = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(state->smb1req, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_notify.c b/source3/smbd/smb2_notify.c
index 133c990f0df..8cccd90b3fb 100644
--- a/source3/smbd/smb2_notify.c
+++ b/source3/smbd/smb2_notify.c
@@ -232,7 +232,7 @@ static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_notify_send: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index 250b56633bb..0cecd720602 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -290,7 +290,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_query_directory_send: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	state->smbreq = smbd_smb2_fake_smb_request(smb2req);
+	state->smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(state->smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index 4c6822f2c74..eb12dbd7269 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -480,7 +480,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_read: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c
index 0cb640ecdde..ba0b38c7d6f 100644
--- a/source3/smbd/smb2_reply.c
+++ b/source3/smbd/smb2_reply.c
@@ -63,8 +63,7 @@
 /* Custom version for processing POSIX paths. */
 #define IS_PATH_SEP(c,posix_only) ((c) == '/' || (!(posix_only) && (c) == '\\'))
 
-static NTSTATUS check_path_syntax_internal(char *path,
-					   bool posix_path)
+NTSTATUS check_path_syntax(char *path, bool posix_path)
 {
 	char *d = path;
 	const char *s = path;
@@ -209,7 +208,7 @@ static NTSTATUS check_path_syntax_internal(char *path,
 					*d++ = *s++;
 					break;
 				default:
-					DEBUG(0,("check_path_syntax_internal: character length assumptions invalid !\n"));
+					DBG_ERR("character length assumptions invalid !\n");
 					*d = '\0';
 					return NT_STATUS_INVALID_PARAMETER;
 			}
@@ -222,37 +221,6 @@ static NTSTATUS check_path_syntax_internal(char *path,
 	return ret;
 }
 
-/****************************************************************************
- Ensure we check the path in *exactly* the same way as W2K for regular pathnames.
- No wildcards allowed.
-****************************************************************************/
-
-NTSTATUS check_path_syntax(char *path)
-{
-	return check_path_syntax_internal(path, false);
-}
-
-/****************************************************************************
- Check the path for a POSIX client.
- We're assuming here that '/' is not the second byte in any multibyte char
- set (a safe assumption).
-****************************************************************************/
-
-NTSTATUS check_path_syntax_posix(char *path)
-{
-	return check_path_syntax_internal(path, true);
-}
-
-NTSTATUS check_path_syntax_smb2(char *path)
-{
-	/*
-	 * Now a simple wrapper around check_path_syntax().
-	 * Leave it alone for now to keep things separate
-	 * when we add SMB3+POSIX parsing.
-	 */
-	return check_path_syntax(path);
-}
-
 /****************************************************************************
  SMB2-only code to strip an MSDFS prefix from an incoming pathname.
 ****************************************************************************/
@@ -434,11 +402,7 @@ static size_t srvstr_get_path_internal(TALLOC_CTX *ctx,
 
   local_path:
 
-	if (posix_pathnames) {
-		*err = check_path_syntax_posix(dst);
-	} else {
-		*err = check_path_syntax(dst);
-	}
+	*err = check_path_syntax(dst, posix_pathnames);
 
 	return ret;
 }
diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c
index 04fd9490fe9..f26fce77a23 100644
--- a/source3/smbd/smb2_setinfo.c
+++ b/source3/smbd/smb2_setinfo.c
@@ -392,7 +392,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_setinfo_send: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}
diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c
index 789b4d5a276..c32e0e52e02 100644
--- a/source3/smbd/smb2_trans2.c
+++ b/source3/smbd/smb2_trans2.c
@@ -4445,7 +4445,8 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
 	req->flags2 &= ~FLAGS2_DFS_PATHNAMES;
 	ucf_flags &= ~UCF_DFS_PATHNAME;
 
-	status = check_path_syntax_smb2(newname);
+	status = check_path_syntax(newname,
+			fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -4556,7 +4557,8 @@ static NTSTATUS smb2_file_link_information(connection_struct *conn,
 	req->flags2 &= ~FLAGS2_DFS_PATHNAMES;
 	ucf_flags &= ~UCF_DFS_PATHNAME;
 
-	status = check_path_syntax_smb2(newname);
+	status = check_path_syntax(newname,
+			fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c
index ff99127b067..269c489642e 100644
--- a/source3/smbd/smb2_write.c
+++ b/source3/smbd/smb2_write.c
@@ -297,7 +297,7 @@ static struct tevent_req *smbd_smb2_write_send(TALLOC_CTX *mem_ctx,
 	DEBUG(10,("smbd_smb2_write: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
 
-	smbreq = smbd_smb2_fake_smb_request(smb2req);
+	smbreq = smbd_smb2_fake_smb_request(smb2req, fsp);
 	if (tevent_req_nomem(smbreq, req)) {
 		return tevent_req_post(req, ev);
 	}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list