VFS: Modify rmdir to take a const struct smb_filename * instead of const char *
authorJeremy Allison <jra@samba.org>
Wed, 24 Feb 2016 22:02:45 +0000 (14:02 -0800)
committerMichael Adam <obnox@samba.org>
Thu, 25 Feb 2016 19:46:49 +0000 (20:46 +0100)
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@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Feb 25 20:46:49 CET 2016 on sn-devel-144

28 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_acl_common.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_audit.c
source3/modules/vfs_cap.c
source3/modules/vfs_catia.c
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_extd_audit.c
source3/modules/vfs_fruit.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_media_harmony.c
source3/modules/vfs_netatalk.c
source3/modules/vfs_posix_eadb.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_syncops.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/modules/vfs_xattr_tdb.c
source3/smbd/close.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index 9a855bc3a59eaee90ae47461160f4263269453f3..8961627e41f0b72a2398674d0aeb59d8ef7f1b6a 100644 (file)
@@ -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;
index ac8cbc85f301461ad51cb345e8bc7f85313c61f7..ac82432df89853e945563006c0c00833dedfb098 100644 (file)
@@ -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)
index 48bacb03429addb4ec237c7fde86f9650dc8b68d..b291206af1cbaeaa7dff747f410e1f4cca87f1f7 100644 (file)
                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,
index 758938aaba4cfb4d6d0fe629dc7409b2ee0d8800..e50c6a69797927dbcf74ce8be53fff2ef94ee45e 100644 (file)
 #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)
index 30574e0e06fcb9e146039be7287a7350721b00de..0c0cf83bdee495a00d5526e3d20a097c775601bc 100644 (file)
@@ -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;
 }
index 62559a262e871ed8858e1c705126c7e16dcdfba9..54edb873e589bdcf8bc6b732276cb2b9923be51b 100644 (file)
@@ -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;
        }
index 8905d1f62c47ae29a0b2c5ec8d0943108c01440e..e16355ab859de0e26aaea6b9d78967576c930504 100644 (file)
@@ -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) : "");
 
index b09a4437b6a52c64aed0197ebbf32328acd6963e..fb974124fdba528d5e4b567ed79b9fa1a1ee61ac 100644 (file)
@@ -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,
index 524d9872133a0fe680becd62729dfc0c0afcebb3..f65ed4c7e7855bec5347339c18f13e6d2ca9c705 100644 (file)
@@ -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;
 }
index 086244a18115710cc01e458cacaedab1fb2035fa..a56740aa7cd851c85b09bcb2076de72f94d46ae0 100644 (file)
@@ -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);
 }
index 28f0257e18e992f203398cd7a3b295a790b737a3..c3ff1bcc103abc4cda4205099eb5d92b52747528 100644 (file)
@@ -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;
 }
index 7b7c2af8a52bc946ce95f5dcd874e556e2ce2cd7..6429370d71bcbc9d04a38cfd85b916165c6dfc0f 100644 (file)
@@ -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) : ""));
 
index e33521eafff300e1a44d944c3f0c4de308f90a83..3cd8c65942adb06f0f5cc1a427f696e28248cfdb 100644 (file)
@@ -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,
index 6dd614044abf301bfaff142a3f6d811e1d45a2b9..3dd200510cc5208d4e9c3159c208c338d021f1c9 100644 (file)
@@ -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;
 }
index b3ee4208ee562679ff31faf8a2da5c83910d714c..8e5316da20ed0a70e624f5b47eb92b5cd23bf3e4 100644 (file)
@@ -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,
index 594db83f311ac0a37831d3579a046ae8e52be2de..b5173af49890795ee68ea817cfeb3593eeeb2051 100644 (file)
@@ -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;
index 269d1fdfe0c356c531b9889f834ef1c70425151c..487ab50189caebeb98bfc317725fcece48821900 100644 (file)
@@ -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 */
index 20679e16ae02d9021c0fca1c2d538a8c7aa3f41d..1d165298a2e853a74f793abe37db5ef69c1733f0 100644 (file)
@@ -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);
index 6d59339c05ea1b42c99f37e0f443504a5dbaf8f4..7817168a52177e5b1e5571f14c6103b23a3566a2 100644 (file)
@@ -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;
index 7161b808275c83d6b29fc18e9b1c6f495332f27e..80396c4e7f09b1514cca403ab083b377551c1519 100644 (file)
@@ -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;
 }
index 38c76c1abb621dc260fded4a81cbea75a87c284d..f6226e75abaf7ccc973d40daf951038dad7c03a4 100644 (file)
@@ -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);
        }
index e533a55a716a46fed569545898782a468c0e137b..8b5d79c63d0214827476cd52b780af799ce62f7d 100644 (file)
@@ -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 */
index 8516c98390c56055f3ae481ecd0231b73d91c155..11866fa2f666565668788bbaf21fde18b53a3191 100644 (file)
@@ -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;
index 8437e3adedf7c94cd2695f0fad983367a5e7f9af..2e581e3cda49a1175e62b4158b7caf3e7d76beff 100644 (file)
@@ -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;
 }
index 2124d38f0a29743aa21aded6a9a5982506e7fd98..9bb4dc8aca39b13a03a81ff1e1d05aebf9ac8f77 100644 (file)
@@ -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);
index 1cb546055d09d35524757eede01949057dd32c6d..cf11ae5e98032c357523993c2a94a61d05190a67 100644 (file)
@@ -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:
index 268c653e43d0337ce3cb0704dfbd8700a650e00a..dfc22be9179f5b56883e1914077f702e85313190 100644 (file)
@@ -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,
index f9819da1c6b900755bc5e8c31c9023b9896af99f..6dcf80544d5fd0f740c5d9ea2145c8304d4a77f8 100644 (file)
@@ -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 ) {