[PATCH] Refactoring - More preparations for removing lp_posix_pathnames()

Jeremy Allison jra at samba.org
Tue Mar 15 03:44:51 UTC 2016


Next pachset. 11 patches in all, but mostly
cleanups and pushing const struct smb_filename *
replacements into previous const char * calls.

1 & 2). Remove use of lp_posix_pathnames() inside
direct POSIX ACL code in hpuxacl and solarisacl
modules. We know we must always follow the link.

3). Cleanup - remove code that duplicates
vfs_stat_smb_basename().

4). Change fn to const struct smb_filename * from const char *.

5). Refactoring, remove unneeded variable.

6 - 10). Change functions to const struct smb_filename * from const char *.

11). Refactoring, remove unneeded variable.

Passes local make test. Next step is to
add 'flags' field into struct smb_filename.

Please review and push if happy !

Cheers,

	Jeremy.
-------------- next part --------------
>From da247f8a9223e0559cc34beb11b0d0667ba0e8a6 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 14:29:20 -0800
Subject: [PATCH 01/11] s3: vfs: vfs_hpuxacl. refuse_symlink() means we can
 always use STAT here.

For a posix acl call on a symlink, we've already refused it.
For a Windows acl mapped call on a symlink, we want to follow
it.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_hpuxacl.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/source3/modules/vfs_hpuxacl.c b/source3/modules/vfs_hpuxacl.c
index 1894146..55a6894 100644
--- a/source3/modules/vfs_hpuxacl.c
+++ b/source3/modules/vfs_hpuxacl.c
@@ -249,22 +249,24 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
 	}
 
 	/*
-	 * if the file is a directory, there is extra work to do:
-	 * since the hpux acl call stores both the access acl and 
-	 * the default acl as provided, we have to get the acl part 
-	 * that has _not_ been specified in "type" from the file first 
-	 * and concatenate it with the acl provided.
+	 * We can directly use SMB_VFS_STAT here, as if this was a
+	 * POSIX call on a symlink, we've already refused it.
+	 * For a Windows acl mapped call on a symlink, we want to follow
+	 * it.
 	 */
-	if (lp_posix_pathnames()) {
-		ret = SMB_VFS_LSTAT(handle->conn, smb_fname);
-	} else {
-		ret = SMB_VFS_STAT(handle->conn, smb_fname);
-	}
+	ret = SMB_VFS_STAT(handle->conn, smb_fname);
 	if (ret != 0) {
 		DEBUG(10, ("Error in stat call: %s\n", strerror(errno)));
 		goto done;
 	}
 	if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+		/*
+		 * if the file is a directory, there is extra work to do:
+		 * since the hpux acl call stores both the access acl and
+		 * the default acl as provided, we have to get the acl part
+		 * that has _not_ been specified in "type" from the file first
+		 * and concatenate it with the acl provided.
+		 */
 		HPUX_ACL_T other_acl; 
 		int other_count;
 		SMB_ACL_TYPE_T other_type;
-- 
2.5.0


>From 3f7af1105dcadbac54b11b0b783eb0223919cba5 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 16:01:31 -0800
Subject: [PATCH 02/11] s3: vfs: vfs_solarisacl. refuse_symlink() means we can
 always use STAT here.

For a posix acl call on a symlink, we've already refused it.
For a Windows acl mapped call on a symlink, we want to follow
it.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_solarisacl.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c
index cf25abc..b421016 100644
--- a/source3/modules/vfs_solarisacl.c
+++ b/source3/modules/vfs_solarisacl.c
@@ -139,10 +139,12 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
 				SMB_ACL_T theacl)
 {
 	int ret = -1;
-	struct stat_ex s;
 	SOLARIS_ACL_T solaris_acl = NULL;
 	int count;
-	
+	struct smb_filename smb_fname = {
+		.base_name = discard_const_p(char, name)
+	};
+
 	DEBUG(10, ("solarisacl_sys_acl_set_file called for file '%s'\n",
 		   name));
 
@@ -166,12 +168,18 @@ int solarisacl_sys_acl_set_file(vfs_handle_struct *handle,
 	 * the default acl as provided, we have to get the acl part 
 	 * that has not been specified in "type" from the file first 
 	 * and concatenate it with the acl provided.
+	 *
+	 * We can directly use SMB_VFS_STAT here, as if this was a
+	 * POSIX call on a symlink, we've already refused it.
+	 * For a Windows acl mapped call on a symlink, we want to follow
+	 * it.
 	 */
-	if (vfs_stat_smb_basename(handle->conn, name, &s) != 0) {
+	ret = SMB_VFS_STAT(conn, &smb_fname);
+	if (ret != 0) {
 		DEBUG(10, ("Error in stat call: %s\n", strerror(errno)));
 		goto done;
 	}
-	if (S_ISDIR(s.st_ex_mode)) {
+	if (S_ISDIR(smb_fname.st.st_ex_mode)) {
 		SOLARIS_ACL_T other_acl = NULL;
 		int other_count;
 		SMB_ACL_TYPE_T other_type;
-- 
2.5.0


>From 763d5ce19cf2dbf6a3ad544ad7fe4d2f9cd5172c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:08:26 -0800
Subject: [PATCH 03/11] s3:vfs: vfs_streams_xattr.c - Remove duplicate code.
 This is exactly vfs_stat_smb_basename().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_streams_xattr.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 3887d9f..d206db1 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -823,23 +823,10 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
 
 	if ((fsp != NULL) && (fsp->fh->fd != -1)) {
 		ret = SMB_VFS_FSTAT(fsp, &sbuf);
-	}
-	else {
-		struct smb_filename *smb_fname_base = NULL;
-		smb_fname_base = synthetic_smb_fname(talloc_tos(),
-					smb_fname->base_name,
-					NULL,
-					NULL);
-		if (smb_fname_base == NULL) {
-			return NT_STATUS_NO_MEMORY;
-		}
-		if (lp_posix_pathnames()) {
-			ret = SMB_VFS_LSTAT(handle->conn, smb_fname_base);
-		} else {
-			ret = SMB_VFS_STAT(handle->conn, smb_fname_base);
-		}
-		sbuf = smb_fname_base->st;
-		TALLOC_FREE(smb_fname_base);
+	} else {
+		ret = vfs_stat_smb_basename(handle->conn,
+				smb_fname->base_name,
+				&sbuf);
 	}
 
 	if (ret == -1) {
-- 
2.5.0


>From c5b1f6f5568d06999529cdc171156386d683f5f2 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:11:20 -0800
Subject: [PATCH 04/11] s3:vfs: vfs_streams_xattr.c: Change
 walk_xattr_streams() to const struct smb_filename * from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_streams_xattr.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index d206db1..b4bfb01 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -683,11 +683,12 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 	return ret;
 }
 
-static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle, files_struct *fsp,
-				   const char *fname,
-				   bool (*fn)(struct ea_struct *ea,
-					      void *private_data),
-				   void *private_data)
+static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle,
+				files_struct *fsp,
+				const struct smb_filename *smb_fname,
+				bool (*fn)(struct ea_struct *ea,
+					void *private_data),
+				void *private_data)
 {
 	NTSTATUS status;
 	char **names;
@@ -697,8 +698,12 @@ static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle, files_struct *fsp,
 	SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
 				return NT_STATUS_UNSUCCESSFUL);
 
-	status = get_ea_names_from_file(talloc_tos(), handle->conn, fsp, fname,
-					&names, &num_names);
+	status = get_ea_names_from_file(talloc_tos(),
+				handle->conn,
+				fsp,
+				smb_fname->base_name,
+				&names,
+				&num_names);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -729,11 +734,17 @@ static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle, files_struct *fsp,
 			continue;
 		}
 
-		status = get_ea_value(names, handle->conn, fsp, fname,
-				      names[i], &ea);
+		status = get_ea_value(names,
+					handle->conn,
+					fsp,
+					smb_fname->base_name,
+					names[i],
+					&ea);
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(10, ("Could not get ea %s for file %s: %s\n",
-				   names[i], fname, nt_errstr(status)));
+				names[i],
+				smb_fname->base_name,
+				nt_errstr(status)));
 			continue;
 		}
 
@@ -849,7 +860,7 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
 		 */
 		status = NT_STATUS_OK;
 	} else {
-		status = walk_xattr_streams(handle, fsp, smb_fname->base_name,
+		status = walk_xattr_streams(handle, fsp, smb_fname,
 				    collect_one_stream, &state);
 	}
 
-- 
2.5.0


>From 977a4da77b95b89cc11dbf1d10af6a23b8635b79 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:23:23 -0800
Subject: [PATCH 05/11] s3: smbd: Reformatting - remove unneeded const char
 *fname variable.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/smbd/trans2.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index fd363b9..a189856 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -658,7 +658,6 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		const struct smb_filename *smb_fname, struct ea_list *ea_list)
 {
 	NTSTATUS status;
-	char *fname = NULL;
 
 	if (!lp_ea_support(SNUM(conn))) {
 		return NT_STATUS_EAS_NOT_SUPPORTED;
@@ -688,8 +687,6 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		return STATUS_INVALID_EA_NAME;
 	}
 
-	fname = smb_fname->base_name;
-
 	for (;ea_list; ea_list = ea_list->next) {
 		int ret;
 		fstring unix_ea_name;
@@ -697,7 +694,10 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		fstrcpy(unix_ea_name, "user."); /* All EA's must start with user. */
 		fstrcat(unix_ea_name, ea_list->ea.name);
 
-		canonicalize_ea_name(conn, fsp, fname, unix_ea_name);
+		canonicalize_ea_name(conn,
+				fsp,
+				smb_fname->base_name,
+				unix_ea_name);
 
 		DEBUG(10,("set_ea: ea_name %s ealen = %u\n", unix_ea_name, (unsigned int)ea_list->ea.value.length));
 
@@ -715,8 +715,10 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 				ret = SMB_VFS_FREMOVEXATTR(fsp, unix_ea_name);
 			} else {
 				DEBUG(10,("set_ea: deleting ea name %s on file %s.\n",
-					unix_ea_name, fname));
-				ret = SMB_VFS_REMOVEXATTR(conn, fname, unix_ea_name);
+					unix_ea_name, smb_fname->base_name));
+				ret = SMB_VFS_REMOVEXATTR(conn,
+						smb_fname->base_name,
+						unix_ea_name);
 			}
 #ifdef ENOATTR
 			/* Removing a non existent attribute always succeeds. */
@@ -735,9 +737,13 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 							ea_list->ea.value.data, ea_list->ea.value.length, 0);
 			} else {
 				DEBUG(10,("set_ea: setting ea name %s on file %s.\n",
-					unix_ea_name, fname));
-				ret = SMB_VFS_SETXATTR(conn, fname, unix_ea_name,
-							ea_list->ea.value.data, ea_list->ea.value.length, 0);
+					unix_ea_name, smb_fname->base_name));
+				ret = SMB_VFS_SETXATTR(conn,
+						smb_fname->base_name,
+						unix_ea_name,
+						ea_list->ea.value.data,
+						ea_list->ea.value.length,
+						0);
 			}
 		}
 
-- 
2.5.0


>From 69030ba21f4828452fabc59e7d6487ca3d3c1326 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:25:54 -0800
Subject: [PATCH 06/11] s3: smbd: Change canonicalize_ea_name() to take a const
 smb_filename * parameter from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/smbd/trans2.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index a189856..2e10bbe 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -630,12 +630,20 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
  Ensure the EA name is case insensitive by matching any existing EA name.
 ****************************************************************************/
 
-static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, const char *fname, fstring unix_ea_name)
+static void canonicalize_ea_name(connection_struct *conn,
+			files_struct *fsp,
+			const struct smb_filename *smb_fname,
+			fstring unix_ea_name)
 {
 	size_t total_ea_len;
 	TALLOC_CTX *mem_ctx = talloc_tos();
 	struct ea_list *ea_list;
-	NTSTATUS status = get_ea_list_from_file_path(mem_ctx, conn, fsp, fname, &total_ea_len, &ea_list);
+	NTSTATUS status = get_ea_list_from_file_path(mem_ctx,
+					conn,
+					fsp,
+					smb_fname->base_name,
+					&total_ea_len,
+					&ea_list);
 	if (!NT_STATUS_IS_OK(status)) {
 		return;
 	}
@@ -696,7 +704,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 
 		canonicalize_ea_name(conn,
 				fsp,
-				smb_fname->base_name,
+				smb_fname,
 				unix_ea_name);
 
 		DEBUG(10,("set_ea: ea_name %s ealen = %u\n", unix_ea_name, (unsigned int)ea_list->ea.value.length));
-- 
2.5.0


>From 742e7de9ff86010e1a336a57e09bd560e4db3410 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:30:00 -0800
Subject: [PATCH 07/11] s3:smbd: Change get_ea_list_from_file_path() to take a
 const smb_filename * parameter from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/smbd/trans2.c | 41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 2e10bbe..eb99660 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -355,8 +355,12 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
  Return a linked list of the total EA's. Plus the total size
 ****************************************************************************/
 
-static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp,
-				      const char *fname, size_t *pea_total_len, struct ea_list **ea_list)
+static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				files_struct *fsp,
+				const struct smb_filename *smb_fname,
+				size_t *pea_total_len,
+				struct ea_list **ea_list)
 {
 	/* Get a list of all xattrs. Max namesize is 64k. */
 	size_t i, num_names;
@@ -367,8 +371,12 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, connection_struc
 	*pea_total_len = 0;
 	*ea_list = NULL;
 
-	status = get_ea_names_from_file(talloc_tos(), conn, fsp, fname,
-					&names, &num_names);
+	status = get_ea_names_from_file(talloc_tos(),
+				conn,
+				fsp,
+				smb_fname->base_name,
+				&names,
+				&num_names);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
@@ -401,9 +409,12 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, connection_struc
 			return NT_STATUS_NO_MEMORY;
 		}
 
-		status = get_ea_value(listp, conn, fsp,
-				      fname, names[i],
-				      &listp->ea);
+		status = get_ea_value(listp,
+					conn,
+					fsp,
+					smb_fname->base_name,
+					names[i],
+					&listp->ea);
 
 		if (!NT_STATUS_IS_OK(status)) {
 			TALLOC_FREE(listp);
@@ -458,7 +469,12 @@ static NTSTATUS get_ea_list_from_file(TALLOC_CTX *mem_ctx, connection_struct *co
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
-	return get_ea_list_from_file_path(mem_ctx, conn, fsp, smb_fname->base_name, pea_total_len, ea_list);
+	return get_ea_list_from_file_path(mem_ctx,
+				conn,
+				fsp,
+				smb_fname,
+				pea_total_len,
+				ea_list);
 }
 
 /****************************************************************************
@@ -601,7 +617,12 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
 	if (is_ntfs_stream_smb_fname(smb_fname)) {
 		fsp = NULL;
 	}
-	(void)get_ea_list_from_file_path(mem_ctx, conn, fsp, smb_fname->base_name, &total_ea_len, &ea_list);
+	(void)get_ea_list_from_file_path(mem_ctx,
+				conn,
+				fsp,
+				smb_fname,
+				&total_ea_len,
+				&ea_list);
 	if(conn->sconn->using_smb2) {
 		NTSTATUS status;
 		unsigned int ret_data_size;
@@ -641,7 +662,7 @@ static void canonicalize_ea_name(connection_struct *conn,
 	NTSTATUS status = get_ea_list_from_file_path(mem_ctx,
 					conn,
 					fsp,
-					smb_fname->base_name,
+					smb_fname,
 					&total_ea_len,
 					&ea_list);
 	if (!NT_STATUS_IS_OK(status)) {
-- 
2.5.0


>From 73a360cb24b82249f0fe7e59fc55d881f5928933 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:34:58 -0800
Subject: [PATCH 08/11] s3:smbd: Change get_ea_names_from_file() to take a
 const smb_filename * parameter from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_streams_xattr.c |  2 +-
 source3/smbd/nttrans.c              |  4 ++--
 source3/smbd/proto.h                |  9 ++++++---
 source3/smbd/trans2.c               | 19 ++++++++++++-------
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index b4bfb01..0d54734 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -701,7 +701,7 @@ static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle,
 	status = get_ea_names_from_file(talloc_tos(),
 				handle->conn,
 				fsp,
-				smb_fname->base_name,
+				smb_fname,
 				&names,
 				&num_names);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index b1917fe..0951280 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -694,7 +694,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
 
 		/* Do we have any EA's ? */
 		status = get_ea_names_from_file(ctx, conn, fsp,
-				smb_fname->base_name, NULL, &num_names);
+				smb_fname, NULL, &num_names);
 		if (NT_STATUS_IS_OK(status) && num_names) {
 			file_status &= ~NO_EAS;
 		}
@@ -1339,7 +1339,7 @@ static void call_nt_transact_create(connection_struct *conn,
 
 		/* Do we have any EA's ? */
 		status = get_ea_names_from_file(ctx, conn, fsp,
-				smb_fname->base_name, NULL, &num_names);
+				smb_fname, NULL, &num_names);
 		if (NT_STATUS_IS_OK(status) && num_names) {
 			file_status &= ~NO_EAS;
 		}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index f9ae4a3..776e91d 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1119,9 +1119,12 @@ bool samba_private_attr_name(const char *unix_ea_name);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
 		      files_struct *fsp, const char *fname,
 		      const char *ea_name, struct ea_struct *pea);
-NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
-				files_struct *fsp, const char *fname,
-				char ***pnames, size_t *pnum_names);
+NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
+			connection_struct *conn,
+			files_struct *fsp,
+			const struct smb_filename *smb_fname,
+			char ***pnames,
+			size_t *pnum_names);
 NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		const struct smb_filename *smb_fname, struct ea_list *ea_list);
 struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index eb99660..b03094d 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -230,9 +230,12 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
 	return NT_STATUS_OK;
 }
 
-NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
-				files_struct *fsp, const char *fname,
-				char ***pnames, size_t *pnum_names)
+NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				files_struct *fsp,
+				const struct smb_filename *smb_fname,
+				char ***pnames,
+				size_t *pnum_names)
 {
 	/* Get a list of all xattrs. Max namesize is 64k. */
 	size_t ea_namelist_size = 1024;
@@ -253,7 +256,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
 		return NT_STATUS_OK;
 	}
 
-	status = refuse_symlink(conn, fsp, fname);
+	status = refuse_symlink(conn, fsp, smb_fname->base_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		/*
 		 * Just return no EA's on a symlink.
@@ -285,8 +288,10 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
 			sizeret = SMB_VFS_FLISTXATTR(fsp, ea_namelist,
 						     ea_namelist_size);
 		} else {
-			sizeret = SMB_VFS_LISTXATTR(conn, fname, ea_namelist,
-						    ea_namelist_size);
+			sizeret = SMB_VFS_LISTXATTR(conn,
+					smb_fname->base_name,
+					ea_namelist,
+					ea_namelist_size);
 		}
 
 		if ((sizeret == -1) && (errno == ERANGE)) {
@@ -374,7 +379,7 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx,
 	status = get_ea_names_from_file(talloc_tos(),
 				conn,
 				fsp,
-				smb_fname->base_name,
+				smb_fname,
 				&names,
 				&num_names);
 
-- 
2.5.0


>From 6d9562ca6e77246fe6e367869cf2a51d6364d77e Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:38:28 -0800
Subject: [PATCH 09/11] s3:smbd: Change refuse_symlink() to take a const
 smb_filename * parameter from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/smbd/trans2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index b03094d..9c77a67 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -60,7 +60,7 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
 
 static NTSTATUS refuse_symlink(connection_struct *conn,
 			const files_struct *fsp,
-			const char *name)
+			const struct smb_filename *smb_fname)
 {
 	SMB_STRUCT_STAT sbuf;
 	const SMB_STRUCT_STAT *pst = NULL;
@@ -69,7 +69,7 @@ static NTSTATUS refuse_symlink(connection_struct *conn,
 		pst = &fsp->fsp_name->st;
 	} else {
 		int ret = vfs_stat_smb_basename(conn,
-				name,
+				smb_fname->base_name,
 				&sbuf);
 		if (ret == -1) {
 			return map_nt_error_from_unix(errno);
@@ -256,7 +256,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
 		return NT_STATUS_OK;
 	}
 
-	status = refuse_symlink(conn, fsp, smb_fname->base_name);
+	status = refuse_symlink(conn, fsp, smb_fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		/*
 		 * Just return no EA's on a symlink.
@@ -697,7 +697,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		return NT_STATUS_EAS_NOT_SUPPORTED;
 	}
 
-	status = refuse_symlink(conn, fsp, smb_fname->base_name);
+	status = refuse_symlink(conn, fsp, smb_fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
@@ -5399,7 +5399,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
 
 				status = refuse_symlink(conn,
 						fsp,
-						smb_fname->base_name);
+						smb_fname);
 				if (!NT_STATUS_IS_OK(status)) {
 					return status;
 				}
@@ -7018,7 +7018,7 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
-	status = refuse_symlink(conn, fsp, smb_fname->base_name);
+	status = refuse_symlink(conn, fsp, smb_fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
-- 
2.5.0


>From bf95c5adfc7fb6f45934e3aed90287c202f3d973 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 15:50:57 -0800
Subject: [PATCH 10/11] s3:vfs: Change get_acl_blob() to take a const
 smb_filename * parameter from const char *.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_acl_common.c | 48 ++++++++++++++++++++--------------------
 source3/modules/vfs_acl_tdb.c    |  8 ++++---
 source3/modules/vfs_acl_xattr.c  |  4 ++--
 3 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index ba93e7b..c8c0650 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -33,7 +33,7 @@ static NTSTATUS create_acl_blob(const struct security_descriptor *psd,
 static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 			vfs_handle_struct *handle,
 			files_struct *fsp,
-			const char *name,
+			const struct smb_filename *smb_fname,
 			DATA_BLOB *pblob);
 
 static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
@@ -366,7 +366,7 @@ static NTSTATUS add_directory_inheritable_components(vfs_handle_struct *handle,
 
 static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 				    files_struct *fsp,
-				    const struct smb_filename *smb_fname,
+				    const struct smb_filename *smb_fname_in,
 				    uint32_t security_info,
 				    TALLOC_CTX *mem_ctx,
 				    struct security_descriptor **ppdesc)
@@ -381,22 +381,22 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 	uint8_t sys_acl_hash_tmp[XATTR_SD_HASH_SIZE];
 	struct security_descriptor *psd = NULL;
 	struct security_descriptor *pdesc_next = NULL;
-	const char *name = NULL;
+	const struct smb_filename *smb_fname = NULL;
 	bool ignore_file_system_acl = lp_parm_bool(SNUM(handle->conn),
 						ACL_MODULE_NAME,
 						"ignore system acls",
 						false);
 	TALLOC_CTX *frame = talloc_stackframe();
 
-	if (fsp && smb_fname == NULL) {
-		name = fsp->fsp_name->base_name;
+	if (fsp && smb_fname_in == NULL) {
+		smb_fname = fsp->fsp_name;
 	} else {
-		name = smb_fname->base_name;
+		smb_fname = smb_fname_in;
 	}
 
-	DEBUG(10, ("get_nt_acl_internal: name=%s\n", name));
+	DEBUG(10, ("get_nt_acl_internal: name=%s\n", smb_fname->base_name));
 
-	status = get_acl_blob(frame, handle, fsp, name, &blob);
+	status = get_acl_blob(frame, handle, fsp, smb_fname, &blob);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(10, ("get_nt_acl_internal: get_acl_blob returned %s\n",
 			nt_errstr(status)));
@@ -440,7 +440,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		DEBUG(10, ("get_nt_acl_internal: ACL blob revision "
 			   "mismatch (%u) for file %s\n",
 			   (unsigned int)hash_type,
-			   name));
+			   smb_fname->base_name));
 		TALLOC_FREE(psd);
 		psd = NULL;
 		goto out;
@@ -451,7 +451,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		DEBUG(10, ("get_nt_acl_internal: ACL blob hash type "
 			   "(%u) unexpected for file %s\n",
 			   (unsigned int)hash_type,
-			   name));
+			   smb_fname->base_name));
 		TALLOC_FREE(psd);
 		psd = NULL;
 		goto out;
@@ -474,10 +474,10 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		} else {
 			/* Get the full underlying sd, then hash. */
 			ret = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle,
-								 name,
-								 frame,
-								 &sys_acl_blob_description,
-								 &sys_acl_blob);
+						 smb_fname->base_name,
+						 frame,
+						 &sys_acl_blob_description,
+						 &sys_acl_blob);
 		}
 
 		/* If we fail to get the ACL blob (for some reason) then this
@@ -494,7 +494,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 				/* Hash matches, return blob sd. */
 				DEBUG(10, ("get_nt_acl_internal: blob hash "
 					   "matches for file %s\n",
-					   name ));
+					   smb_fname->base_name ));
 				goto out;
 			}
 		}
@@ -521,7 +521,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(10, ("get_nt_acl_internal: get_next_acl for file %s "
 				   "returned %s\n",
-				   name,
+				   smb_fname->base_name,
 				   nt_errstr(status)));
 			TALLOC_FREE(frame);
 			return status;
@@ -545,7 +545,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 			/* Hash matches, return blob sd. */
 			DEBUG(10, ("get_nt_acl_internal: blob hash "
 				   "matches for file %s\n",
-				   name ));
+				   smb_fname->base_name ));
 			goto out;
 		}
 
@@ -553,11 +553,11 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		DEBUG(10, ("get_nt_acl_internal: blob hash "
 			   "does not match for file %s - returning "
 			   "file system SD mapping.\n",
-			   name ));
+			   smb_fname->base_name ));
 
 		if (DEBUGLEVEL >= 10) {
 			DEBUG(10,("get_nt_acl_internal: acl for blob hash for %s is:\n",
-				  name ));
+				  smb_fname->base_name ));
 			NDR_PRINT_DEBUG(security_descriptor, pdesc_next);
 		}
 
@@ -587,7 +587,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(10, ("get_nt_acl_internal: get_next_acl for file %s "
 				   "returned %s\n",
-				   name,
+				   smb_fname->base_name,
 				   nt_errstr(status)));
 			TALLOC_FREE(frame);
 			return status;
@@ -641,7 +641,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 			 * is fully plumbed through the VFS.
 			 */
 			int ret = vfs_stat_smb_basename(handle->conn,
-						name,
+						smb_fname->base_name,
 						&sbuf);
 			if (ret == -1) {
 				TALLOC_FREE(frame);
@@ -653,7 +653,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 		if (ignore_file_system_acl) {
 			TALLOC_FREE(pdesc_next);
 			status = make_default_filesystem_acl(mem_ctx,
-						name,
+						smb_fname->base_name,
 						psbuf,
 						&psd);
 			if (!NT_STATUS_IS_OK(status)) {
@@ -666,7 +666,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 							true)) {
 				status = add_directory_inheritable_components(
 							handle,
-							name,
+							smb_fname->base_name,
 							psbuf,
 							psd);
 				if (!NT_STATUS_IS_OK(status)) {
@@ -701,7 +701,7 @@ static NTSTATUS get_nt_acl_internal(vfs_handle_struct *handle,
 
 	if (DEBUGLEVEL >= 10) {
 		DEBUG(10,("get_nt_acl_internal: returning acl for %s is:\n",
-			name ));
+			smb_fname->base_name ));
 		NDR_PRINT_DEBUG(security_descriptor, psd);
 	}
 
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index 54edb87..1bc5973 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -143,7 +143,7 @@ static NTSTATUS acl_tdb_delete(vfs_handle_struct *handle,
 static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 			vfs_handle_struct *handle,
 			files_struct *fsp,
-			const char *name,
+			const struct smb_filename *smb_fname,
 			DATA_BLOB *pblob)
 {
 	uint8_t id_buf[16];
@@ -159,7 +159,9 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 		status = vfs_stat_fsp(fsp);
 		sbuf = fsp->fsp_name->st;
 	} else {
-		int ret = vfs_stat_smb_basename(handle->conn, name, &sbuf);
+		int ret = vfs_stat_smb_basename(handle->conn,
+				smb_fname->base_name,
+				&sbuf);
 		if (ret == -1) {
 			status = map_nt_error_from_unix(errno);
 		}
@@ -186,7 +188,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 	pblob->length = data.dsize;
 
 	DEBUG(10,("get_acl_blob: returned %u bytes from file %s\n",
-		(unsigned int)data.dsize, name ));
+		(unsigned int)data.dsize, smb_fname->base_name ));
 
 	if (pblob->length == 0 || pblob->data == NULL) {
 		return NT_STATUS_NOT_FOUND;
diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c
index 2338798..d311c57 100644
--- a/source3/modules/vfs_acl_xattr.c
+++ b/source3/modules/vfs_acl_xattr.c
@@ -40,7 +40,7 @@
 static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 			vfs_handle_struct *handle,
 			files_struct *fsp,
-			const char *name,
+			const struct smb_filename *smb_fname,
 			DATA_BLOB *pblob)
 {
 	size_t size = 1024;
@@ -64,7 +64,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 	if (fsp && fsp->fh->fd != -1) {
 		sizeret = SMB_VFS_FGETXATTR(fsp, XATTR_NTACL_NAME, val, size);
 	} else {
-		sizeret = SMB_VFS_GETXATTR(handle->conn, name,
+		sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
 					XATTR_NTACL_NAME, val, size);
 	}
 	if (sizeret == -1) {
-- 
2.5.0


>From e58f68dc48b45b5ad1ff1afa67daa883030049f2 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Fri, 11 Mar 2016 16:07:20 -0800
Subject: [PATCH 11/11] s3: vfs: vfs_xattr_tdb - cleanup. Remove unneeded
 variable "path".

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source3/modules/vfs_xattr_tdb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 9bb4dc8..a22192b 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -407,7 +407,6 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle,
 	struct file_id id;
 	struct db_context *db;
 	int ret;
-	const char *path = smb_fname->base_name;
 	TALLOC_CTX *frame = talloc_stackframe();
 
 	SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
@@ -416,7 +415,9 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle,
 					TALLOC_FREE(frame); return -1;
 				});
 
-	if (vfs_stat_smb_basename(handle->conn, path, &sbuf) == -1) {
+	if (vfs_stat_smb_basename(handle->conn,
+				smb_fname->base_name,
+				&sbuf) == -1) {
 		TALLOC_FREE(frame);
 		return -1;
 	}
-- 
2.5.0



More information about the samba-technical mailing list