[PATCH] VFS - modify rmdir to use const struct smb_filename *

Jeremy Allison jra at samba.org
Wed Feb 24 22:44:57 UTC 2016


Three patches this time. First two patches fix up mkdir in
vfs_ceph and vfs_glusterfs as I missed them last time
(I don't normally build with them, sorry).

Last patch converts SMB_VFS_RMDIR calls to use
const struct smb_filename * instead of const char *.

Similar to the previous mkdir changes (except I
remembered to fix ceph and gluster this time :-).

Please review and push if happy !

Cheers,

	Jeremy.
-------------- next part --------------
From 911538e6cc998511238117e270fddc7966aefed5 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 24 Feb 2016 13:58:16 -0800
Subject: [PATCH 1/3] smbd: Modules: vfs_glusterfs.c Fix mkdir function to take
 const struct smb_filename * from const char *.

Missed in previous VFS change.

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

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 427b985..c91287c 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -429,10 +429,11 @@ static void vfs_gluster_init_search_op(struct vfs_handle_struct *handle,
 	return;
 }
 
-static int vfs_gluster_mkdir(struct vfs_handle_struct *handle, const char *path,
-			     mode_t mode)
+static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname,
+			mode_t mode)
 {
-	return glfs_mkdir(handle->data, path, mode);
+	return glfs_mkdir(handle->data, smb_fname->base_name, mode);
 }
 
 static int vfs_gluster_rmdir(struct vfs_handle_struct *handle, const char *path)
-- 
2.7.0.rc3.207.g0ac5344


From 3b8ed2d3a8fc6621a20ce95a122d2718a722e97e Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 24 Feb 2016 14:00:27 -0800
Subject: [PATCH 2/3] smbd: Modules: vfs_ceph.c Fix mkdir function to take
 const struct smb_filename * from const char *.

Missed in previous VFS change.

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

diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index d51499d..59cb89a 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -326,11 +326,14 @@ static void cephwrap_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
 	ceph_rewinddir(handle->data, (struct ceph_dir_result *) dirp);
 }
 
-static int cephwrap_mkdir(struct vfs_handle_struct *handle,  const char *path, mode_t mode)
+static int cephwrap_mkdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname,
+			mode_t mode)
 {
 	int result;
 	bool has_dacl = False;
 	char *parent = NULL;
+	const char *path = smb_fname->base_name;
 
 	DEBUG(10, ("[CEPH] mkdir(%p, %s)\n", handle, path));
 
-- 
2.7.0.rc3.207.g0ac5344


From 5a165e3852d2222906f3113343a5d388d8c3272c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Wed, 24 Feb 2016 14:02:45 -0800
Subject: [PATCH 3/3] s3: VFS: Modify rmdir to take a const struct smb_filename
 * instead of const char *

Preparing to reduce use of lp_posix_pathnames().

Uses the same techniques as commit 616d068f0cebb8e50a855b6e30f36fccb7f5a3c8
(synthetic_smb_fname()) to cope with modules that
modify the incoming pathname.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 examples/VFS/skel_opaque.c          |  3 ++-
 examples/VFS/skel_transparent.c     |  5 +++--
 source3/include/vfs.h               |  8 +++++--
 source3/include/vfs_macros.h        |  8 +++----
 source3/modules/vfs_acl_common.c    | 10 ++++-----
 source3/modules/vfs_acl_tdb.c       |  7 +++---
 source3/modules/vfs_audit.c         |  7 +++---
 source3/modules/vfs_cap.c           | 19 +++++++++++++---
 source3/modules/vfs_catia.c         | 21 ++++++++++++++----
 source3/modules/vfs_ceph.c          |  7 +++---
 source3/modules/vfs_default.c       |  5 +++--
 source3/modules/vfs_extd_audit.c    |  9 ++++----
 source3/modules/vfs_fruit.c         |  6 ++++--
 source3/modules/vfs_full_audit.c    |  7 +++---
 source3/modules/vfs_glusterfs.c     |  5 +++--
 source3/modules/vfs_media_harmony.c | 25 ++++++++++-----------
 source3/modules/vfs_netatalk.c      |  6 ++++--
 source3/modules/vfs_posix_eadb.c    |  6 ++++--
 source3/modules/vfs_shadow_copy2.c  | 24 ++++++++++++++++-----
 source3/modules/vfs_snapper.c       | 19 ++++++++++++----
 source3/modules/vfs_streams_depot.c | 43 +++++++++++++++++++++++++++++++------
 source3/modules/vfs_syncops.c       |  5 +++--
 source3/modules/vfs_time_audit.c    |  8 ++++---
 source3/modules/vfs_unityed_media.c | 24 ++++++++++-----------
 source3/modules/vfs_xattr_tdb.c     |  6 ++++--
 source3/smbd/close.c                |  9 ++++----
 source3/smbd/vfs.c                  |  5 +++--
 source3/torture/cmd_vfs.c           | 20 ++++++++++-------
 28 files changed, 215 insertions(+), 112 deletions(-)

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 9a855bc..8961627 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -165,7 +165,8 @@ static int skel_mkdir(vfs_handle_struct *handle,
 	return -1;
 }
 
-static int skel_rmdir(vfs_handle_struct *handle, const char *path)
+static int skel_rmdir(vfs_handle_struct *handle,
+		const struct smb_filename *smb_fname)
 {
 	errno = ENOSYS;
 	return -1;
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index ac8cbc8..ac82432 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -164,9 +164,10 @@ static int skel_mkdir(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
 }
 
-static int skel_rmdir(vfs_handle_struct *handle, const char *path)
+static int skel_rmdir(vfs_handle_struct *handle,
+		const struct smb_filename *smb_fname)
 {
-	return SMB_VFS_NEXT_RMDIR(handle, path);
+	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 }
 
 static int skel_closedir(vfs_handle_struct *handle, DIR *dir)
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 48bacb0..b291206 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -175,6 +175,8 @@
 		const struct smb_filename * */
 /* Version 35 - Change mkdir from const char *, to
 		const struct smb_filename * */
+/* Version 35 - Change rmdir from const char *, to
+		const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 35
 
@@ -559,7 +561,8 @@ struct vfs_fn_pointers {
 	int (*mkdir_fn)(struct vfs_handle_struct *handle,
 			const struct smb_filename *smb_fname,
 			mode_t mode);
-	int (*rmdir_fn)(struct vfs_handle_struct *handle, const char *path);
+	int (*rmdir_fn)(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname);
 	int (*closedir_fn)(struct vfs_handle_struct *handle, DIR *dir);
 	void (*init_search_op_fn)(struct vfs_handle_struct *handle, DIR *dirp);
 
@@ -978,7 +981,8 @@ void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
 int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
 			const struct smb_filename *smb_fname,
 			mode_t mode);
-int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path);
+int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname);
 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
 			  DIR *dir);
 void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 758938a..e50c6a6 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -114,10 +114,10 @@
 #define SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode) \
 	smb_vfs_call_mkdir((handle)->next,(smb_fname), (mode))
 
-#define SMB_VFS_RMDIR(conn, path) \
-	smb_vfs_call_rmdir((conn)->vfs_handles, (path))
-#define SMB_VFS_NEXT_RMDIR(handle, path) \
-	smb_vfs_call_rmdir((handle)->next, (path))
+#define SMB_VFS_RMDIR(conn, smb_fname) \
+	smb_vfs_call_rmdir((conn)->vfs_handles, (smb_fname))
+#define SMB_VFS_NEXT_RMDIR(handle, smb_fname) \
+	smb_vfs_call_rmdir((handle)->next, (smb_fname))
 
 #define SMB_VFS_CLOSEDIR(conn, dir) \
 	smb_vfs_call_closedir((conn)->vfs_handles, dir)
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 30574e0..0c0cf83 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -1007,7 +1007,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
 
 	become_root();
 	if (is_directory) {
-		ret = SMB_VFS_NEXT_RMDIR(handle, final_component);
+		ret = SMB_VFS_NEXT_RMDIR(handle, &local_fname);
 	} else {
 		ret = SMB_VFS_NEXT_UNLINK(handle, &local_fname);
 	}
@@ -1031,12 +1031,12 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
 }
 
 static int rmdir_acl_common(struct vfs_handle_struct *handle,
-				const char *path)
+				const struct smb_filename *smb_fname)
 {
 	int ret;
 
 	/* Try the normal rmdir first. */
-	ret = SMB_VFS_NEXT_RMDIR(handle, path);
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 	if (ret == 0) {
 		return 0;
 	}
@@ -1044,12 +1044,12 @@ static int rmdir_acl_common(struct vfs_handle_struct *handle,
 		/* Failed due to access denied,
 		   see if we need to root override. */
 		return acl_common_remove_object(handle,
-						path,
+						smb_fname->base_name,
 						true);
 	}
 
 	DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
-		path,
+		smb_fname->base_name,
 		strerror(errno) ));
 	return -1;
 }
diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index 62559a2..54edb87 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -275,19 +275,20 @@ static int unlink_acl_tdb(vfs_handle_struct *handle,
  On rmdir we need to delete the tdb record (if using tdb).
 *********************************************************************/
 
-static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
+static int rmdir_acl_tdb(vfs_handle_struct *handle,
+		const struct smb_filename *smb_fname)
 {
 
 	SMB_STRUCT_STAT sbuf;
 	struct db_context *db = acl_db;
 	int ret = -1;
 
-	ret = vfs_stat_smb_basename(handle->conn, path, &sbuf);
+	ret = vfs_stat_smb_basename(handle->conn, smb_fname->base_name, &sbuf);
 	if (ret == -1) {
 		return -1;
 	}
 
-	ret = rmdir_acl_common(handle, path);
+	ret = rmdir_acl_common(handle, smb_fname);
 	if (ret == -1) {
 		return -1;
 	}
diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c
index 8905d1f..e16355a 100644
--- a/source3/modules/vfs_audit.c
+++ b/source3/modules/vfs_audit.c
@@ -136,14 +136,15 @@ static int audit_mkdir(vfs_handle_struct *handle,
 	return result;
 }
 
-static int audit_rmdir(vfs_handle_struct *handle, const char *path)
+static int audit_rmdir(vfs_handle_struct *handle,
+		const struct smb_filename *smb_fname)
 {
 	int result;
 
-	result = SMB_VFS_NEXT_RMDIR(handle, path);
+	result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 
 	syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n", 
-	       path, 
+	       smb_fname->base_name,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : "");
 
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index b09a443..fb97412 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -122,15 +122,28 @@ static int cap_mkdir(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_MKDIR(handle, cap_smb_fname, mode);
 }
 
-static int cap_rmdir(vfs_handle_struct *handle, const char *path)
+static int cap_rmdir(vfs_handle_struct *handle,
+		const struct smb_filename *smb_fname)
 {
-	char *cappath = capencode(talloc_tos(), path);
+	char *cappath = capencode(talloc_tos(), smb_fname->base_name);
+	struct smb_filename *cap_smb_fname = NULL;
 
 	if (!cappath) {
 		errno = ENOMEM;
 		return -1;
 	}
-	return SMB_VFS_NEXT_RMDIR(handle, cappath);
+
+	cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+					cappath,
+					NULL,
+					NULL);
+	if (cap_smb_fname == NULL) {
+		TALLOC_FREE(cappath);
+		errno = ENOMEM;
+		return -1;
+	}
+
+	return SMB_VFS_NEXT_RMDIR(handle, cap_smb_fname);
 }
 
 static int cap_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 524d987..f65ed4c 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -570,21 +570,34 @@ static int catia_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
 }
 
 static int catia_rmdir(vfs_handle_struct *handle,
-		       const char *path)
+		       const struct smb_filename *smb_fname)
 {
 	char *name = NULL;
 	NTSTATUS status;
 	int ret;
+	struct smb_filename *catia_smb_fname = NULL;
 
-	status = catia_string_replace_allocate(handle->conn, path,
-					&name, vfs_translate_to_unix);
+	status = catia_string_replace_allocate(handle->conn,
+				smb_fname->base_name,
+				&name,
+				vfs_translate_to_unix);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
+	catia_smb_fname = synthetic_smb_fname(talloc_tos(),
+					name,
+					NULL,
+					NULL);
+	if (catia_smb_fname == NULL) {
+		TALLOC_FREE(name);
+		errno = ENOMEM;
+		return -1;
+	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, name);
+	ret = SMB_VFS_NEXT_RMDIR(handle, catia_smb_fname);
 	TALLOC_FREE(name);
+	TALLOC_FREE(catia_smb_fname);
 
 	return ret;
 }
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 59cb89a..2e7d67b 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -367,12 +367,13 @@ static int cephwrap_mkdir(struct vfs_handle_struct *handle,
 	return result;
 }
 
-static int cephwrap_rmdir(struct vfs_handle_struct *handle,  const char *path)
+static int cephwrap_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	int result;
 
-	DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, path));
-	result = ceph_rmdir(handle->data, path);
+	DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, smb_fname->base_name));
+	result = ceph_rmdir(handle->data, smb_fname->base_name);
 	DEBUG(10, ("[CEPH] rmdir(...) = %d\n", result));
 	WRAP_RETURN(result);
 }
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 28f0257..c3ff1bc 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -503,12 +503,13 @@ static int vfswrap_mkdir(vfs_handle_struct *handle,
 	return result;
 }
 
-static int vfswrap_rmdir(vfs_handle_struct *handle, const char *path)
+static int vfswrap_rmdir(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	int result;
 
 	START_PROFILE(syscall_rmdir);
-	result = rmdir(path);
+	result = rmdir(smb_fname->base_name);
 	END_PROFILE(syscall_rmdir);
 	return result;
 }
diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c
index 7b7c2af..6429370 100644
--- a/source3/modules/vfs_extd_audit.c
+++ b/source3/modules/vfs_extd_audit.c
@@ -158,20 +158,21 @@ static int audit_mkdir(vfs_handle_struct *handle,
 	return result;
 }
 
-static int audit_rmdir(vfs_handle_struct *handle, const char *path)
+static int audit_rmdir(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	int result;
 
-	result = SMB_VFS_NEXT_RMDIR(handle, path);
+	result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 
 	if (lp_syslog() > 0) {
 		syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n",
-		       path,
+		       smb_fname->base_name,
 		       (result < 0) ? "failed: " : "",
 		       (result < 0) ? strerror(errno) : "");
 	}
 	DEBUG(0, ("vfs_extd_audit: rmdir %s %s %s\n",
-               path,
+               smb_fname->base_name,
 	       (result < 0) ? "failed: " : "",
 	       (result < 0) ? strerror(errno) : ""));
 
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index e33521e..3cd8c65 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -2576,11 +2576,13 @@ static int fruit_chown(vfs_handle_struct *handle,
 	return rc;
 }
 
-static int fruit_rmdir(struct vfs_handle_struct *handle, const char *path)
+static int fruit_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	DIR *dh = NULL;
 	struct dirent *de;
 	struct fruit_config_data *config;
+	const char *path = smb_fname->base_name;
 
 	SMB_VFS_HANDLE_GET_DATA(handle, config,
 				struct fruit_config_data, return -1);
@@ -2618,7 +2620,7 @@ exit_rmdir:
 	if (dh) {
 		closedir(dh);
 	}
-	return SMB_VFS_NEXT_RMDIR(handle, path);
+	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 }
 
 static ssize_t fruit_pread(vfs_handle_struct *handle,
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 6dd6140..3dd2005 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -857,13 +857,14 @@ static int smb_full_audit_mkdir(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
-		       const char *path)
+		       const struct smb_filename *smb_fname)
 {
 	int result;
 	
-	result = SMB_VFS_NEXT_RMDIR(handle, path);
+	result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 
-	do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
+	do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s",
+		smb_fname->base_name);
 
 	return result;
 }
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index c91287c..12a0eae 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -436,9 +436,10 @@ static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
 	return glfs_mkdir(handle->data, smb_fname->base_name, mode);
 }
 
-static int vfs_gluster_rmdir(struct vfs_handle_struct *handle, const char *path)
+static int vfs_gluster_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
-	return glfs_rmdir(handle->data, path);
+	return glfs_rmdir(handle->data, smb_fname->base_name);
 }
 
 static int vfs_gluster_open(struct vfs_handle_struct *handle,
diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c
index 594db83..b5173af 100644
--- a/source3/modules/vfs_media_harmony.c
+++ b/source3/modules/vfs_media_harmony.c
@@ -1069,34 +1069,31 @@ out:
  * Failure: set errno, return -1
  */
 static int mh_rmdir(vfs_handle_struct *handle,
-		const char *path)
+		const struct smb_filename *smb_fname)
 {
 	int status;
-	char *clientPath;
-	TALLOC_CTX *ctx;
-
+	struct smb_filename *clientFname = NULL;
+	const char *path = smb_fname->base_name;
 
 	DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path));
 
 	if (!is_in_media_files(path))
 	{
-		status = SMB_VFS_NEXT_RMDIR(handle, path);
+		status = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 		goto out;
 	}
 
-	clientPath = NULL;
-	ctx = talloc_tos();
-
-	if ((status = alloc_get_client_path(handle, ctx,
-				path,
-				&clientPath)))
-	{
+	status = alloc_get_client_smb_fname(handle,
+				talloc_tos(),
+				smb_fname,
+				&clientFname);
+	if (status != 0) {
 		goto err;
 	}
 
-	status = SMB_VFS_NEXT_RMDIR(handle, clientPath);
+	status = SMB_VFS_NEXT_RMDIR(handle, clientFname);
 err:
-	TALLOC_FREE(clientPath);
+	TALLOC_FREE(clientFname);
 out:
 	DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", path));
 	return status;
diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c
index 269d1fd..487ab50 100644
--- a/source3/modules/vfs_netatalk.c
+++ b/source3/modules/vfs_netatalk.c
@@ -223,10 +223,12 @@ static DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp,
 	return ret;
 }
 
-static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
+static int atalk_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	bool add = False;
 	TALLOC_CTX *ctx = 0;
+	const char *path = smb_fname->base_name;
 	char *dpath;
 
 	if (!handle->conn->cwd || !path) goto exit_rmdir;
@@ -248,7 +250,7 @@ static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
 
 exit_rmdir:
 	talloc_destroy(ctx);
-	return SMB_VFS_NEXT_RMDIR(handle, path);
+	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 }
 
 /* File operations */
diff --git a/source3/modules/vfs_posix_eadb.c b/source3/modules/vfs_posix_eadb.c
index 20679e1..1d16529 100644
--- a/source3/modules/vfs_posix_eadb.c
+++ b/source3/modules/vfs_posix_eadb.c
@@ -343,11 +343,13 @@ out:
 /*
  * On rmdir we need to delete the tdb record
  */
-static int posix_eadb_rmdir(vfs_handle_struct *handle, const char *path)
+static int posix_eadb_rmdir(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	NTSTATUS status;
 	struct tdb_wrap *ea_tdb;
 	int ret;
+	const char *path = smb_fname->base_name;
 
 	SMB_VFS_HANDLE_GET_DATA(handle, ea_tdb, struct tdb_wrap, return -1);
 
@@ -360,7 +362,7 @@ static int posix_eadb_rmdir(vfs_handle_struct *handle, const char *path)
 		tdb_transaction_cancel(ea_tdb->tdb);
 	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, path);
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 
 	if (ret == -1) {
 		tdb_transaction_cancel(ea_tdb->tdb);
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index 6d59339..7817168 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -1583,27 +1583,41 @@ static int shadow_copy2_mkdir(vfs_handle_struct *handle,
 	return ret;
 }
 
-static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
+static int shadow_copy2_rmdir(vfs_handle_struct *handle,
+				const struct smb_filename *smb_fname)
 {
 	time_t timestamp;
 	char *stripped;
 	int ret, saved_errno;
 	char *conv;
+	struct smb_filename *conv_smb_fname = NULL;
 
-	if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
-					 &timestamp, &stripped)) {
+	if (!shadow_copy2_strip_snapshot(talloc_tos(),
+					handle,
+					smb_fname->base_name,
+					&timestamp,
+					&stripped)) {
 		return -1;
 	}
 	if (timestamp == 0) {
-		return SMB_VFS_NEXT_RMDIR(handle, fname);
+		return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 	}
 	conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
 	TALLOC_FREE(stripped);
 	if (conv == NULL) {
 		return -1;
 	}
-	ret = SMB_VFS_NEXT_RMDIR(handle, conv);
+	conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+					conv,
+					NULL,
+					NULL);
+	if (conv_smb_fname == NULL) {
+		TALLOC_FREE(conv);
+		return -1;
+	}
+	ret = SMB_VFS_NEXT_RMDIR(handle, conv_smb_fname);
 	saved_errno = errno;
+	TALLOC_FREE(conv_smb_fname);
 	TALLOC_FREE(conv);
 	errno = saved_errno;
 	return ret;
diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c
index 7161b80..80396c4 100644
--- a/source3/modules/vfs_snapper.c
+++ b/source3/modules/vfs_snapper.c
@@ -2527,14 +2527,16 @@ static int snapper_gmt_mkdir(vfs_handle_struct *handle,
 	return ret;
 }
 
-static int snapper_gmt_rmdir(vfs_handle_struct *handle, const char *fname)
+static int snapper_gmt_rmdir(vfs_handle_struct *handle,
+				const struct smb_filename *fname)
 {
 	time_t timestamp;
 	char *stripped;
 	int ret, saved_errno;
 	char *conv;
+	struct smb_filename *smb_fname = NULL;
 
-	if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
+	if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname->base_name,
 					&timestamp, &stripped)) {
 		return -1;
 	}
@@ -2546,9 +2548,18 @@ static int snapper_gmt_rmdir(vfs_handle_struct *handle, const char *fname)
 	if (conv == NULL) {
 		return -1;
 	}
-	ret = SMB_VFS_NEXT_RMDIR(handle, conv);
-	saved_errno = errno;
+	smb_fname = synthetic_smb_fname(talloc_tos(),
+					conv,
+					NULL,
+					NULL);
 	TALLOC_FREE(conv);
+	if (smb_fname == NULL) {
+		errno = ENOMEM;
+		return -1;
+	}
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
+	saved_errno = errno;
+	TALLOC_FREE(smb_fname);
 	errno = saved_errno;
 	return ret;
 }
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 38c76c1..f6226e7 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -233,7 +233,7 @@ static char *stream_dir(vfs_handle_struct *handle,
 			      smb_fname_hash->base_name));
 			recursive_rmdir(talloc_tos(), handle->conn,
 					smb_fname_hash);
-			SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash->base_name);
+			SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
 		} else {
 			newname = talloc_asprintf(talloc_tos(), "lost-%lu",
 						  random());
@@ -682,7 +682,19 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 					   &smb_fname_base->st, false);
 
 		if (dirname != NULL) {
-			SMB_VFS_NEXT_RMDIR(handle, dirname);
+			struct smb_filename *smb_fname_dir =
+				synthetic_smb_fname(talloc_tos(),
+						dirname,
+						NULL,
+						NULL);
+			if (smb_fname_dir == NULL) {
+				TALLOC_FREE(smb_fname_base);
+				TALLOC_FREE(dirname);
+				errno = ENOMEM;
+				return -1;
+			}
+			SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
+			TALLOC_FREE(smb_fname_dir);
 		}
 		TALLOC_FREE(dirname);
 	}
@@ -691,18 +703,23 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 	return ret;
 }
 
-static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
+static int streams_depot_rmdir(vfs_handle_struct *handle,
+				const struct smb_filename *smb_fname)
 {
 	struct smb_filename *smb_fname_base = NULL;
 	int ret = -1;
 
-	DEBUG(10, ("streams_depot_rmdir called for %s\n", path));
+	DEBUG(10, ("streams_depot_rmdir called for %s\n",
+		smb_fname->base_name));
 
 	/*
 	 * We potentially need to delete the per-inode streams directory
 	 */
 
-	smb_fname_base = synthetic_smb_fname(talloc_tos(), path, NULL, NULL);
+	smb_fname_base = synthetic_smb_fname(talloc_tos(),
+				smb_fname->base_name,
+				NULL,
+				NULL);
 	if (smb_fname_base == NULL) {
 		errno = ENOMEM;
 		return -1;
@@ -719,13 +736,25 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, path);
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
 	if (ret == 0) {
 		char *dirname = stream_dir(handle, smb_fname_base,
 					   &smb_fname_base->st, false);
 
 		if (dirname != NULL) {
-			SMB_VFS_NEXT_RMDIR(handle, dirname);
+			struct smb_filename *smb_fname_dir =
+				synthetic_smb_fname(talloc_tos(),
+						dirname,
+						NULL,
+						NULL);
+			if (smb_fname_dir == NULL) {
+				TALLOC_FREE(smb_fname_base);
+				TALLOC_FREE(dirname);
+				errno = ENOMEM;
+				return -1;
+			}
+			SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
+			TALLOC_FREE(smb_fname_dir);
 		}
 		TALLOC_FREE(dirname);
 	}
diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c
index e533a55..8b5d79c 100644
--- a/source3/modules/vfs_syncops.c
+++ b/source3/modules/vfs_syncops.c
@@ -224,9 +224,10 @@ static int syncops_mkdir(vfs_handle_struct *handle,
         SYNCOPS_NEXT_SMB_FNAME(MKDIR, smb_fname, (handle, smb_fname, mode));
 }
 
-static int syncops_rmdir(vfs_handle_struct *handle,  const char *fname)
+static int syncops_rmdir(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
-        SYNCOPS_NEXT(RMDIR, fname, (handle, fname));
+        SYNCOPS_NEXT_SMB_FNAME(RMDIR, smb_fname, (handle, smb_fname));
 }
 
 /* close needs to be handled specially */
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 8516c98..11866fa 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -482,19 +482,21 @@ static int smb_time_audit_mkdir(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
-				const char *path)
+				const struct smb_filename *smb_fname)
 {
 	int result;
 	struct timespec ts1,ts2;
 	double timediff;
 
 	clock_gettime_mono(&ts1);
-	result = SMB_VFS_NEXT_RMDIR(handle, path);
+	result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 	clock_gettime_mono(&ts2);
 	timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
 	if (timediff > audit_timeout) {
-		smb_time_audit_log_fname("rmdir", timediff, path);
+		smb_time_audit_log_smb_fname("rmdir",
+			timediff,
+			smb_fname);
 	}
 
 	return result;
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
index 8437e3a..2e581e3 100644
--- a/source3/modules/vfs_unityed_media.c
+++ b/source3/modules/vfs_unityed_media.c
@@ -795,31 +795,29 @@ err:
 }
 
 static int um_rmdir(vfs_handle_struct *handle,
-		    const char *path)
+		    const struct smb_filename *smb_fname)
 {
 	int status;
-	char *clientPath;
-	TALLOC_CTX *ctx;
-
+	const char *path = smb_fname->base_name;
+	struct smb_filename *client_fname = NULL;
 
 	DEBUG(10, ("Entering with path '%s'\n", path));
 
 	if (!is_in_media_files(path)) {
-		return SMB_VFS_NEXT_RMDIR(handle, path);
+		return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 	}
 
-	clientPath = NULL;
-	ctx = talloc_tos();
-
-	if ((status = alloc_get_client_path(handle, ctx,
-					    path,
-					    &clientPath))) {
+	status = alloc_get_client_smb_fname(handle,
+				talloc_tos(),
+				smb_fname,
+				&client_fname);
+	if (status != 0) {
 		goto err;
 	}
 
-	status = SMB_VFS_NEXT_RMDIR(handle, clientPath);
+	status = SMB_VFS_NEXT_RMDIR(handle, client_fname);
 err:
-	TALLOC_FREE(clientPath);
+	TALLOC_FREE(client_fname);
 	DEBUG(10, ("Leaving with path '%s'\n", path));
 	return status;
 }
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 2124d38..9bb4dc8 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -400,12 +400,14 @@ static int xattr_tdb_unlink(vfs_handle_struct *handle,
 /*
  * On rmdir we need to delete the tdb record
  */
-static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
+static int xattr_tdb_rmdir(vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	SMB_STRUCT_STAT sbuf;
 	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,
@@ -419,7 +421,7 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
 		return -1;
 	}
 
-	ret = SMB_VFS_NEXT_RMDIR(handle, path);
+	ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 
 	if (ret == -1) {
 		TALLOC_FREE(frame);
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 1cb5460..cf11ae5 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -845,8 +845,7 @@ bool recursive_rmdir(TALLOC_CTX *ctx,
 			if(!recursive_rmdir(ctx, conn, smb_dname_full)) {
 				goto err_break;
 			}
-			if(SMB_VFS_RMDIR(conn,
-					 smb_dname_full->base_name) != 0) {
+			if(SMB_VFS_RMDIR(conn, smb_dname_full) != 0) {
 				goto err_break;
 			}
 		} else if(SMB_VFS_UNLINK(conn, smb_dname_full) != 0) {
@@ -896,7 +895,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
 		}
 		ret = SMB_VFS_UNLINK(conn, smb_dname);
 	} else {
-		ret = SMB_VFS_RMDIR(conn, smb_dname->base_name);
+		ret = SMB_VFS_RMDIR(conn, smb_dname);
 	}
 	if (ret == 0) {
 		notify_fname(conn, NOTIFY_ACTION_REMOVED,
@@ -998,7 +997,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
 					goto err_break;
 				}
 				if(SMB_VFS_RMDIR(conn,
-					smb_dname_full->base_name) != 0) {
+					smb_dname_full) != 0) {
 					goto err_break;
 				}
 			} else if(SMB_VFS_UNLINK(conn, smb_dname_full) != 0) {
@@ -1017,7 +1016,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
 		}
 		TALLOC_FREE(dir_hnd);
 		/* Retry the rmdir */
-		ret = SMB_VFS_RMDIR(conn, smb_dname->base_name);
+		ret = SMB_VFS_RMDIR(conn, smb_dname);
 	}
 
   err:
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 268c653..dfc22be 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1505,10 +1505,11 @@ int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
 	return handle->fns->mkdir_fn(handle, smb_fname, mode);
 }
 
-int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path)
+int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
+			const struct smb_filename *smb_fname)
 {
 	VFS_FIND(rmdir);
-	return handle->fns->rmdir_fn(handle, path);
+	return handle->fns->rmdir_fn(handle, smb_fname);
 }
 
 int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index f9819da..6dcf805 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -399,6 +399,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 
 static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
+	struct smb_filename *smb_fname = NULL;
 	int ret = -1;
 
 	if (argc != 2) {
@@ -406,16 +407,19 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
 		return NT_STATUS_OK;
 	}
 
-	if (strcmp("rmdir", argv[0]) == 0 ) {
-		ret = SMB_VFS_RMDIR(vfs->conn, argv[1]);
-	} else if (strcmp("unlink", argv[0]) == 0 ) {
-		struct smb_filename *smb_fname;
+	smb_fname = synthetic_smb_fname(talloc_tos(),
+					argv[1],
+					NULL,
+					NULL);
 
-		smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1], NULL);
-		if (smb_fname == NULL) {
-			return NT_STATUS_NO_MEMORY;
-		}
+	if (smb_fname == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
 
+	if (strcmp("rmdir", argv[0]) == 0 ) {
+		ret = SMB_VFS_RMDIR(vfs->conn, smb_fname);
+		TALLOC_FREE(smb_fname);
+	} else if (strcmp("unlink", argv[0]) == 0 ) {
 		ret = SMB_VFS_UNLINK(vfs->conn, smb_fname);
 		TALLOC_FREE(smb_fname);
 	} else if (strcmp("chdir", argv[0]) == 0 ) {
-- 
2.7.0.rc3.207.g0ac5344



More information about the samba-technical mailing list