VFS: Modify chown to take a const struct smb_filename * instead of const char *
authorJeremy Allison <jra@samba.org>
Thu, 3 Mar 2016 19:54:23 +0000 (11:54 -0800)
committerRalph Boehme <slow@samba.org>
Sat, 5 Mar 2016 08:39:18 +0000 (09:39 +0100)
Preparing to reduce use of lp_posix_pathnames().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
21 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_cap.c
source3/modules/vfs_catia.c
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_fake_acls.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_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/smbd/pysmbd.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index e7bb645f1654f3d2284c8c5cdadd5f19de6f605d..57f5b0921f02f82d3b00cd1242e95da783735327 100644 (file)
@@ -382,8 +382,10 @@ static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
        return -1;
 }
 
-static int skel_chown(vfs_handle_struct *handle, const char *path,
-                     uid_t uid, gid_t gid)
+static int skel_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        errno = ENOSYS;
        return -1;
index fe2356a6e69b4ac797e29f68d47fcf0ec5134943..d320da951180e2031b41afb20129c87cdfd013fc 100644 (file)
@@ -488,10 +488,12 @@ static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp,
        return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
 }
 
-static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid,
-                     gid_t gid)
+static int skel_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
-       return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
 }
 
 static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp,
index c8e049487dce530361374a71e1f379013e7c4b78..4b3ac0372ad324fd077211f637c7353c7baff226 100644 (file)
                const struct smb_filename * */
 /* Version 35 - Change chmod_acl from const char *, to
                const struct smb_filename * */
+/* Version 35 - Change chown from const char *, to
+               const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 35
 
@@ -646,7 +648,10 @@ struct vfs_fn_pointers {
                        const struct smb_filename *smb_fname,
                        mode_t mode);
        int (*fchmod_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
-       int (*chown_fn)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
+       int (*chown_fn)(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid);
        int (*fchown_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
        int (*lchown_fn)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
        int (*chdir_fn)(struct vfs_handle_struct *handle, const char *path);
@@ -1095,8 +1100,10 @@ int smb_vfs_call_chmod(struct vfs_handle_struct *handle,
                        mode_t mode);
 int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
                        struct files_struct *fsp, mode_t mode);
-int smb_vfs_call_chown(struct vfs_handle_struct *handle, const char *path,
-                      uid_t uid, gid_t gid);
+int smb_vfs_call_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid);
 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
                        struct files_struct *fsp, uid_t uid, gid_t gid);
 int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
index e5e3c99866d5a6bb0d7418767a8cec72dd5e68b2..5fbd779c0a53fad196ac606be55ea5d1239ebb21 100644 (file)
 #define SMB_VFS_NEXT_FCHMOD(handle, fsp, mode) \
        smb_vfs_call_fchmod((handle)->next, (fsp), (mode))
 
-#define SMB_VFS_CHOWN(conn, path, uid, gid) \
-       smb_vfs_call_chown((conn)->vfs_handles, (path), (uid), (gid))
-#define SMB_VFS_NEXT_CHOWN(handle, path, uid, gid) \
-       smb_vfs_call_chown((handle)->next, (path), (uid), (gid))
+#define SMB_VFS_CHOWN(conn, smb_fname, uid, gid) \
+       smb_vfs_call_chown((conn)->vfs_handles, (smb_fname), (uid), (gid))
+#define SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid) \
+       smb_vfs_call_chown((handle)->next, (smb_fname), (uid), (gid))
 
 #define SMB_VFS_FCHOWN(fsp, uid, gid) \
        smb_vfs_call_fchown((fsp)->conn->vfs_handles, (fsp), (uid), (gid))
index 0bb943da9a2982363cda213dd3ea56e283cd9061..f58977b5aa94ce1fb2f5a8bee00a2d977aa4093b 100644 (file)
@@ -336,15 +336,37 @@ static int cap_chmod(vfs_handle_struct *handle,
        return ret;
 }
 
-static int cap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int cap_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       struct smb_filename *cap_smb_fname = NULL;
+       char *cappath = capencode(talloc_tos(), smb_fname->base_name);
+       int ret;
+       int saved_errno;
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_CHOWN(handle, cappath, uid, gid);
+
+       cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       cappath,
+                                       NULL,
+                                       NULL);
+       if (cap_smb_fname == NULL) {
+               TALLOC_FREE(cappath);
+               errno = ENOMEM;
+               return -1;
+       }
+
+       ret = SMB_VFS_NEXT_CHOWN(handle, cap_smb_fname, uid, gid);
+       saved_errno = errno;
+       TALLOC_FREE(cappath);
+       TALLOC_FREE(cap_smb_fname);
+       errno = saved_errno;
+       return ret;
 }
 
 static int cap_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
index e142ccef8ef09218e56f3a5b93757babc96c3c4c..814f474c079834774494da7af9048ba63db27b0f 100644 (file)
@@ -522,24 +522,39 @@ static int catia_unlink(vfs_handle_struct *handle,
 }
 
 static int catia_chown(vfs_handle_struct *handle,
-                      const char *path,
+                      const struct smb_filename *smb_fname,
                       uid_t uid,
                       gid_t gid)
 {
        char *name = NULL;
        NTSTATUS status;
        int ret;
+       int saved_errno;
+       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_CHOWN(handle, name, uid, gid);
+       ret = SMB_VFS_NEXT_CHOWN(handle, catia_smb_fname, uid, gid);
+       saved_errno = errno;
        TALLOC_FREE(name);
-
+       TALLOC_FREE(catia_smb_fname);
+       errno = saved_errno;
        return ret;
 }
 
index 82e15c8dfccca7eb1f4e905127ad1fb60a32e747..d185bd0c0b591a955942ee6fdb6033f54ec00529 100644 (file)
@@ -697,11 +697,18 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp,
        return -1;
 }
 
-static int cephwrap_chown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int cephwrap_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
-       DEBUG(10, ("[CEPH] chown(%p, %s, %d, %d)\n", handle, path, uid, gid));
-       result = ceph_chown(handle->data, path, uid, gid);
+       DEBUG(10, ("[CEPH] chown(%p, %s, %d, %d)\n",
+               handle,
+               smb_fname->base_name,
+               uid,
+               gid));
+       result = ceph_chown(handle->data, smb_fname->base_name, uid, gid);
        DEBUG(10, ("[CEPH] chown(...) = %d\n", result));
        WRAP_RETURN(result);
 }
index bb55facbb08a08e71255907ff78183d1dd343c12..604ee4519b71bead7e9552b8bbfb3276f1288586 100644 (file)
@@ -1744,12 +1744,15 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m
        return result;
 }
 
-static int vfswrap_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int vfswrap_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
 
        START_PROFILE(syscall_chown);
-       result = chown(path, uid, gid);
+       result = chown(smb_fname->base_name, uid, gid);
        END_PROFILE(syscall_chown);
        return result;
 }
index 3887e86746e252742ff3dc538fa477f16f3e0f88..cb907d0ca9875fabbb8c450c4622e2a4159b0385 100644 (file)
@@ -393,20 +393,33 @@ static int fake_acls_sys_acl_delete_def_file(vfs_handle_struct *handle, const ch
        return ret;
 }
 
-static int fake_acls_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int fake_acls_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int ret;
        uint8_t id_buf[4];
        if (uid != -1) {
                SIVAL(id_buf, 0, uid);
-               ret = SMB_VFS_NEXT_SETXATTR(handle, path, FAKE_UID, id_buf, sizeof(id_buf), 0);
+               ret = SMB_VFS_NEXT_SETXATTR(handle,
+                               smb_fname->base_name,
+                               FAKE_UID,
+                               id_buf,
+                               sizeof(id_buf),
+                               0);
                if (ret != 0) {
                        return ret;
                }
        }
        if (gid != -1) {
                SIVAL(id_buf, 0, gid);
-               ret = SMB_VFS_NEXT_SETXATTR(handle, path, FAKE_GID, id_buf, sizeof(id_buf), 0);
+               ret = SMB_VFS_NEXT_SETXATTR(handle,
+                               smb_fname->base_name,
+                               FAKE_GID,
+                               id_buf,
+                               sizeof(id_buf),
+                               0);
                if (ret != 0) {
                        return ret;
                }
index 49cfa0c3c078c4cbd892c70635f9834c244bb142..73b5f3a53b8971c679597c5e63519fd5ec13b583 100644 (file)
@@ -2545,16 +2545,17 @@ static int fruit_chmod(vfs_handle_struct *handle,
 }
 
 static int fruit_chown(vfs_handle_struct *handle,
-                      const char *path,
+                      const struct smb_filename *smb_fname,
                       uid_t uid,
                       gid_t gid)
 {
        int rc = -1;
        char *adp = NULL;
        struct fruit_config_data *config = NULL;
+       struct smb_filename *adp_smb_fname = NULL;
        SMB_STRUCT_STAT sb;
 
-       rc = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       rc = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        if (rc != 0) {
                return rc;
        }
@@ -2566,26 +2567,37 @@ static int fruit_chown(vfs_handle_struct *handle,
                return rc;
        }
 
-       /* FIXME: direct sys_lstat(), missing smb_fname */
-       rc = sys_lstat(path, &sb, false);
+       /* FIXME: direct sys_lstat(), need non-const smb_fname */
+       rc = sys_lstat(smb_fname->base_name, &sb, false);
        if (rc != 0 || !S_ISREG(sb.st_ex_mode)) {
                return rc;
        }
 
-       rc = adouble_path(talloc_tos(), path, &adp);
+       rc = adouble_path(talloc_tos(), smb_fname->base_name, &adp);
        if (rc != 0) {
                goto done;
        }
 
        DEBUG(10, ("fruit_chown: %s\n", adp));
 
-       rc = SMB_VFS_NEXT_CHOWN(handle, adp, uid, gid);
+       adp_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       adp,
+                                       NULL,
+                                       NULL);
+       if (adp_smb_fname == NULL) {
+               errno = ENOMEM;
+               rc = -1;
+               goto done;
+       }
+
+       rc = SMB_VFS_NEXT_CHOWN(handle, adp_smb_fname, uid, gid);
        if (errno == ENOENT) {
                rc = 0;
        }
 
  done:
        TALLOC_FREE(adp);
+       TALLOC_FREE(adp_smb_fname);
        return rc;
 }
 
index 4a7b358894197a8b3369758dc47dff335d8cb1b6..309158a41c2769d3ee2b35b936ae547873578fde 100644 (file)
@@ -1422,14 +1422,16 @@ static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static int smb_full_audit_chown(vfs_handle_struct *handle,
-                      const char *path, uid_t uid, gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
 
-       result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
 
        do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
-              path, (long int)uid, (long int)gid);
+              smb_fname->base_name, (long int)uid, (long int)gid);
 
        return result;
 }
index 2008342229d74592fa1efae5f73e1467be4fecb4..b61bb14ffa4fdc2649d244a9909bacb68a036e79 100644 (file)
@@ -942,9 +942,11 @@ static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
-                            const char *path, uid_t uid, gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
-       return glfs_chown(handle->data, path, uid, gid);
+       return glfs_chown(handle->data, smb_fname->base_name, uid, gid);
 }
 
 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
index e1f05ccdbeec0f15a87da1afe837eaea36c32764..73b418ef1815bbd0b78ff0f5208dbc38d4b7c24a 100644 (file)
@@ -1580,34 +1580,31 @@ out:
  * Failure: set errno, return -1
  */
 static int mh_chown(vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                uid_t uid,
                gid_t gid)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
+       struct smb_filename *clientFname = NULL;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_chown\n"));
-       if (!is_in_media_files(path))
+       if (!is_in_media_files(smb_fname->base_name))
        {
-               status = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+               status = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
                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_CHOWN(handle, clientPath, uid, gid);
+       status = SMB_VFS_NEXT_CHOWN(handle, clientFname, uid, gid);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return status;
 }
index 4bb26d09dce1d087e87ad7f1c2849fd16528d3e6..13ad402f89b574676555c0092f78c517017da13a 100644 (file)
@@ -397,7 +397,10 @@ exit_chmod:
        return ret;
 }
 
-static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int atalk_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int ret = 0;
        char *adbl_path = 0;
@@ -406,14 +409,12 @@ static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t
        SMB_STRUCT_STAT orig_info;
        TALLOC_CTX *ctx;
 
-       ret = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
-
-       if (!path) return ret;
+       ret = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
 
        if (!(ctx = talloc_init("chown_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->cwd, path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_chown;
index c83ce1e529f7b895838b99e0b49d147322948fa9..c63d67603d3495ad46cd65eab91f487611cde16b 100644 (file)
@@ -1013,29 +1013,45 @@ static int shadow_copy2_chmod(vfs_handle_struct *handle,
        return ret;
 }
 
-static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
-                             uid_t uid, gid_t gid)
+static int shadow_copy2_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        time_t timestamp;
        char *stripped;
        int ret, saved_errno;
-       char *conv;
+       char *conv = NULL;
+       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_CHOWN(handle, fname, uid, gid);
+               return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL);
+       if (conv_smb_fname == NULL) {
+               TALLOC_FREE(conv);
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_CHOWN(handle, conv_smb_fname, uid, gid);
        saved_errno = errno;
        TALLOC_FREE(conv);
+       TALLOC_FREE(conv_smb_fname);
        errno = saved_errno;
        return ret;
 }
index fb9936931c0399ad93c9937f5cfd6f4006f2b63f..11a99d97b796c1dc030b18f1ffd798036a1dad9d 100644 (file)
@@ -2259,29 +2259,46 @@ static int snapper_gmt_chmod(vfs_handle_struct *handle,
        return ret;
 }
 
-static int snapper_gmt_chown(vfs_handle_struct *handle, const char *fname,
-                            uid_t uid, gid_t gid)
+static int snapper_gmt_chown(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        time_t timestamp;
-       char *stripped;
+       char *stripped = NULL;
        int ret, saved_errno;
-       char *conv;
+       char *conv = NULL;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
-                                       &timestamp, &stripped)) {
+       if (!snapper_gmt_strip_snapshot(talloc_tos(),
+                               handle,
+                               smb_fname->base_name,
+                               &timestamp,
+                               &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
+               TALLOC_FREE(stripped);
+               return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        }
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL);
+       if (conv_smb_fname == NULL) {
+               TALLOC_FREE(conv);
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_CHOWN(handle, conv_smb_fname, uid, gid);
        saved_errno = errno;
        TALLOC_FREE(conv);
+       TALLOC_FREE(conv_smb_fname);
        errno = saved_errno;
        return ret;
 }
index 944251d934dbeabab607152a78d1304f52f504e0..68bc84b58d94ef09253326e6c0445b29d29b5a4d 100644 (file)
@@ -1143,19 +1143,23 @@ static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static int smb_time_audit_chown(vfs_handle_struct *handle,
-                               const char *path, uid_t uid, gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("chown", timediff, path);
+               smb_time_audit_log_fname("chown",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;
index dd6dc335dd8fc9875c1a415cb3353bc15cad8a56..84191cc571fb0928f65c1791909cd6299f0419c0 100644 (file)
@@ -1207,29 +1207,31 @@ err:
 }
 
 static int um_chown(vfs_handle_struct *handle,
-                   const char *path,
-                   uid_t uid,
-                   gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_chown\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_CHOWN(handle, client_path, uid, gid);
+       status = SMB_VFS_NEXT_CHOWN(handle, client_fname, uid, gid);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
index cd6a1e2e72463fa58489ced1df00be80e1646243..68bc3e758490d8a3e35efe78f87136fbf99e0afc 100644 (file)
@@ -375,6 +375,7 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
        int uid, gid;
        TALLOC_CTX *frame;
        mode_t saved_umask;
+       struct smb_filename *smb_fname = NULL;
 
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sii|z",
                                         discard_const_p(char *, kwnames),
@@ -392,7 +393,18 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
           so set our umask to 0 */
        saved_umask = umask(0);
 
-       ret = SMB_VFS_CHOWN( conn, fname, uid, gid);
+       smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       fname,
+                                       NULL,
+                                       NULL);
+       if (smb_fname == NULL) {
+               umask(saved_umask);
+               TALLOC_FREE(frame);
+               errno = ENOMEM;
+               return PyErr_SetFromErrno(PyExc_OSError);
+       }
+
+       ret = SMB_VFS_CHOWN(conn, smb_fname, uid, gid);
        if (ret != 0) {
                umask(saved_umask);
                TALLOC_FREE(frame);
index 02a94e86f532a8848ed62e6e303de05894670b39..8b87b32f4b1249df0ef2e9d68ef8d759e5b580e1 100644 (file)
@@ -1882,11 +1882,13 @@ int smb_vfs_call_fchmod(struct vfs_handle_struct *handle,
        return handle->fns->fchmod_fn(handle, fsp, mode);
 }
 
-int smb_vfs_call_chown(struct vfs_handle_struct *handle, const char *path,
-                      uid_t uid, gid_t gid)
+int smb_vfs_call_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        VFS_FIND(chown);
-       return handle->fns->chown_fn(handle, path, uid, gid);
+       return handle->fns->chown_fn(handle, smb_fname, uid, gid);
 }
 
 int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
@@ -1983,7 +1985,7 @@ NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid)
                        uid, gid);
        } else {
                ret = SMB_VFS_CHOWN(fsp->conn,
-                       path,
+                       fsp->fsp_name,
                        uid, gid);
        }
 
index a7e70b3c3a139c7f688cddb50d0cfdcaa2cbe387..4bd5417fb8ae00d25d02df7bd86003315729319b 100644 (file)
@@ -955,6 +955,7 @@ static NTSTATUS cmd_fchmod_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
 
 static NTSTATUS cmd_chown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
+       struct smb_filename *smb_fname = NULL;
        uid_t uid;
        gid_t gid;
        if (argc != 4) {
@@ -964,7 +965,16 @@ static NTSTATUS cmd_chown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
 
        uid = atoi(argv[2]);
        gid = atoi(argv[3]);
-       if (SMB_VFS_CHOWN(vfs->conn, argv[1], uid, gid) == -1) {
+
+       smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       argv[1],
+                                       NULL,
+                                       NULL);
+       if (smb_fname == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       if (SMB_VFS_CHOWN(vfs->conn, smb_fname, uid, gid) == -1) {
                printf("chown: error=%d (%s)\n", errno, strerror(errno));
                return NT_STATUS_UNSUCCESSFUL;
        }