s3: VFS: Change SMB_VFS_SYS_ACL_BLOB_GET_FILE to use const struct smb_filename *...
authorJeremy Allison <jra@samba.org>
Wed, 24 May 2017 00:35:59 +0000 (17:35 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 31 May 2017 20:50:22 +0000 (22:50 +0200)
We need to migrate all pathname based VFS calls to use a struct
to finish modernising the VFS with extra timestamp and flags parameters.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
18 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/non_posix_acls.c
source3/modules/non_posix_acls.h
source3/modules/vfs_acl_common.c
source3/modules/vfs_afsacl.c
source3/modules/vfs_aixacl2.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_nfs4acl_xattr.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_zfsacl.c
source3/smbd/posix_acls.c
source3/smbd/proto.h
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index b0be73c..8ecd0be 100644 (file)
@@ -757,8 +757,10 @@ static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                     const char *path_p, TALLOC_CTX *mem_ctx,
-                                     char **blob_description, DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        errno = ENOSYS;
        return -1;
index d103695..82d3c37 100644 (file)
@@ -895,10 +895,12 @@ static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int skel_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                     const char *path_p, TALLOC_CTX *mem_ctx,
-                                     char **blob_description, DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
-       return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx,
+       return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx,
                                                  blob_description, blob);
 }
 
index 330a819..e32952a 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change sys_acl_get_file from const char *
                to const struct smb_filename * */
+/* Version 37 - Change sys_acl_blob_get_file from const char *
+               to const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -867,7 +869,7 @@ struct vfs_fn_pointers {
                                       struct files_struct *fsp,
                                       TALLOC_CTX *mem_ctx);
        int (*sys_acl_blob_get_file_fn)(struct vfs_handle_struct *handle,
-                                       const char *path_p,
+                                       const struct smb_filename *smb_fname,
                                        TALLOC_CTX *mem_ctx,
                                        char **blob_description,
                                        DATA_BLOB *blob);
@@ -1323,7 +1325,7 @@ SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
                                      struct files_struct *fsp,
                                      TALLOC_CTX *mem_ctx);
 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
-                                      const char *path_p,
+                                      const struct smb_filename *smb_fname,
                                       TALLOC_CTX *mem_ctx,
                                       char **blob_description,
                                       DATA_BLOB *blob);
index 6858181..0ca601a 100644 (file)
 #define SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx) \
        smb_vfs_call_sys_acl_get_fd((handle)->next, (fsp), (mem_ctx))
 
-#define SMB_VFS_SYS_ACL_BLOB_GET_FILE(conn, path_p, mem_ctx, blob_description, blob)   \
-       smb_vfs_call_sys_acl_blob_get_file((conn)->vfs_handles, (path_p), (mem_ctx), (blob_description), (blob))
-#define SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx, blob_description, blob) \
-       smb_vfs_call_sys_acl_blob_get_file((handle)->next, (path_p), (mem_ctx), (blob_description), (blob))
+#define SMB_VFS_SYS_ACL_BLOB_GET_FILE(conn, smb_fname, mem_ctx, blob_description, blob)        \
+       smb_vfs_call_sys_acl_blob_get_file((conn)->vfs_handles, (smb_fname), (mem_ctx), (blob_description), (blob))
+#define SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname, mem_ctx, blob_description, blob) \
+       smb_vfs_call_sys_acl_blob_get_file((handle)->next, (smb_fname), (mem_ctx), (blob_description), (blob))
 
 #define SMB_VFS_SYS_ACL_BLOB_GET_FD(fsp, mem_ctx, blob_description, blob)                      \
        smb_vfs_call_sys_acl_blob_get_fd((fsp)->conn->vfs_handles, (fsp), (mem_ctx), (blob_description), (blob))
index 8d3be72..4537879 100644 (file)
 #include "modules/non_posix_acls.h"
 
 int non_posix_sys_acl_blob_get_file_helper(vfs_handle_struct *handle,
-                                          const char *path_p,
-                                          DATA_BLOB acl_as_blob,
-                                          TALLOC_CTX *mem_ctx,
-                                          DATA_BLOB *blob)
+                                  const struct smb_filename *smb_fname_in,
+                                  DATA_BLOB acl_as_blob,
+                                  TALLOC_CTX *mem_ctx,
+                                  DATA_BLOB *blob)
 {
        int ret;
        TALLOC_CTX *frame = talloc_stackframe();
        struct xattr_sys_acl_hash_wrapper acl_wrapper = {};
-       struct smb_filename *smb_fname;
+       struct smb_filename *smb_fname = cp_smb_filename_nostream(frame,
+                                               smb_fname_in);
 
-       smb_fname = synthetic_smb_fname(frame, path_p, NULL, NULL, 0);
        if (smb_fname == NULL) {
                TALLOC_FREE(frame);
-               errno = ENOMEM;
                return -1;
        }
 
index 6567a31..8924810 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 int non_posix_sys_acl_blob_get_file_helper(vfs_handle_struct *handle,
-                                          const char *path_p,
+                                          const struct smb_filename *smb_fname,
                                           DATA_BLOB acl_as_blob,
                                           TALLOC_CTX *mem_ctx,
                                           DATA_BLOB *blob);
index fa65fd1..bd1d755 100644 (file)
@@ -711,7 +711,7 @@ static NTSTATUS validate_nt_acl_blob(TALLOC_CTX *mem_ctx,
                } else {
                        /* Get the full underlying sd, then hash. */
                        ret = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle,
-                                                smb_fname->base_name,
+                                                smb_fname,
                                                 mem_ctx,
                                                 &sys_acl_blob_description,
                                                 &sys_acl_blob);
index f34495b..ce789f0 100644 (file)
@@ -1085,7 +1085,11 @@ static int afsacl_connect(vfs_handle_struct *handle,
 }
 
 /* We don't have a linear form of the AFS ACL yet */
-static int afsacl_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
+static int afsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       TALLOC_CTX *mem_ctx,
+                       char **blob_description,
+                       DATA_BLOB *blob)
 {
        errno = ENOSYS;
        return -1;
index de5b333..8613b59 100644 (file)
@@ -221,16 +221,21 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
                                pacl);
 }
 
-static int aixjfs2_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
+static int aixjfs2_sys_acl_blob_get_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       TALLOC_CTX *mem_ctx,
+                       char **blob_description,
+                       DATA_BLOB *blob)
 {
        struct SMB4ACL_T *pacl = NULL;
+       const char *path_p = smb_fname->base_name;
        bool    result;
        bool    retryPosix = False;
 
        result = aixjfs2_get_nfs4_acl(mem_ctx, path_p, &pacl, &retryPosix);
        if (retryPosix)
        {
-               return posix_sys_acl_blob_get_file(handle, path_p, mem_ctx,
+               return posix_sys_acl_blob_get_file(handle, smb_fname, mem_ctx,
                                                   blob_description, blob);
        }
        /* Now way to linarlise NFS4 ACLs at the moment, but the NT ACL is pretty close in this case */
index 932dbf8..6d281d8 100644 (file)
@@ -2181,17 +2181,18 @@ static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                               const char *path_p,
-                                               TALLOC_CTX *mem_ctx,
-                                               char **blob_description,
-                                               DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx, blob_description, blob);
+       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
+                       mem_ctx, blob_description, blob);
 
        do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, (result >= 0), handle,
-              "%s", path_p);
+              "%s", smb_fname->base_name);
 
        return result;
 }
index 37568ab..87ddf5d 100644 (file)
@@ -1011,7 +1011,7 @@ static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                     const char *path_p,
+                                     const struct smb_filename *smb_fname,
                                      TALLOC_CTX *mem_ctx,
                                      char **blob_description,
                                      DATA_BLOB *blob)
@@ -1020,13 +1020,14 @@ static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
        struct gpfs_opaque_acl *acl = NULL;
        DATA_BLOB aclblob;
        int result;
+       const char *path_p = smb_fname->base_name;
 
        SMB_VFS_HANDLE_GET_DATA(handle, config,
                                struct gpfs_config_data,
                                return -1);
 
        if (!config->acl) {
-               return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p,
+               return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
                                                          mem_ctx,
                                                          blob_description,
                                                          blob);
@@ -1068,7 +1069,7 @@ static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
                        return -1;
                }
 
-               result = non_posix_sys_acl_blob_get_file_helper(handle, path_p,
+               result = non_posix_sys_acl_blob_get_file_helper(handle, smb_fname,
                                                                aclblob,
                                                                mem_ctx, blob);
 
@@ -1077,7 +1078,7 @@ static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
        }
 
        /* fall back to POSIX ACL */
-       return posix_sys_acl_blob_get_file(handle, path_p, mem_ctx,
+       return posix_sys_acl_blob_get_file(handle, smb_fname, mem_ctx,
                                           blob_description, blob);
 }
 
index 3975f80..a0c4af7 100644 (file)
@@ -620,7 +620,11 @@ static int nfs4acl_xattr_fail__sys_acl_delete_def_file(vfs_handle_struct *handle
        return -1;
 }
 
-static int nfs4acl_xattr_fail__sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
+static int nfs4acl_xattr_fail__sys_acl_blob_get_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       TALLOC_CTX *mem_ctx,
+                       char **blob_description,
+                       DATA_BLOB *blob)
 {
        return -1;
 }
index 033dabe..d62df37 100644 (file)
@@ -2213,17 +2213,18 @@ static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
 
 
 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                               const char *path_p,
-                                               TALLOC_CTX *mem_ctx, 
-                                               char **blob_description,
-                                               DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx, blob_description, blob);
+       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
+                               mem_ctx, blob_description, blob);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
index 57e4182..cf341da 100644 (file)
@@ -319,7 +319,11 @@ static int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle,
        return -1;
 }
 
-static int zfsacl_fail__sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
+static int zfsacl_fail__sys_acl_blob_get_file(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       TALLOC_CTX *mem_ctx,
+                       char **blob_description,
+                       DATA_BLOB *blob)
 {
        return -1;
 }
index 4f0540b..07e0584 100644 (file)
@@ -4734,7 +4734,7 @@ NTSTATUS get_nt_acl_no_snum(TALLOC_CTX *ctx, const char *fname,
 }
 
 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                               const char *path_p,
+                               const struct smb_filename *smb_fname_in,
                                TALLOC_CTX *mem_ctx,
                                char **blob_description,
                                DATA_BLOB *blob)
@@ -4745,9 +4745,8 @@ int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
        struct smb_acl_wrapper acl_wrapper = {
                NULL
        };
-       struct smb_filename *smb_fname;
-
-       smb_fname = synthetic_smb_fname(frame, path_p, NULL, NULL, 0);
+       struct smb_filename *smb_fname = cp_smb_filename_nostream(frame,
+                                               smb_fname_in);
        if (smb_fname == NULL) {
                TALLOC_FREE(frame);
                errno = ENOMEM;
@@ -4810,8 +4809,11 @@ int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
 
        /* This ensures that we also consider the default ACL */
        if (fsp->is_directory ||  fsp->fh->fd == -1) {
-               return posix_sys_acl_blob_get_file(handle, fsp->fsp_name->base_name,
-                                                  mem_ctx, blob_description, blob);
+               return posix_sys_acl_blob_get_file(handle,
+                                               fsp->fsp_name,
+                                               mem_ctx,
+                                               blob_description,
+                                               blob);
        }
        frame = talloc_stackframe();
 
index 556fb6b..06d2461 100644 (file)
@@ -800,7 +800,7 @@ NTSTATUS get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname,
                             uint32_t security_info_wanted,
                             struct security_descriptor **sd);
 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                               const char *path_p,
+                               const struct smb_filename *smb_fname,
                                TALLOC_CTX *mem_ctx,
                                char **blob_description,
                                DATA_BLOB *blob);
index 82d0485..8dd84a2 100644 (file)
@@ -2458,13 +2458,14 @@ SMB_ACL_T smb_vfs_call_sys_acl_get_fd(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
-                                      const char *path_p,
-                                      TALLOC_CTX *mem_ctx, 
-                                      char **blob_description,
-                                      DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        VFS_FIND(sys_acl_blob_get_file);
-       return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
+       return handle->fns->sys_acl_blob_get_file_fn(handle, smb_fname,
+                       mem_ctx, blob_description, blob);
 }
 
 int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
index 390cffa..0bb2903 100644 (file)
@@ -1718,13 +1718,20 @@ static NTSTATUS cmd_sys_acl_blob_get_file(struct vfs_state *vfs,
        DATA_BLOB blob;
        int ret;
        size_t i;
+       struct smb_filename *smb_fname = NULL;
 
        if (argc != 2) {
                printf("Usage: sys_acl_get_file <path>\n");
                return NT_STATUS_OK;
        }
 
-       ret = SMB_VFS_SYS_ACL_BLOB_GET_FILE(vfs->conn, argv[1], talloc_tos(),
+       smb_fname = synthetic_smb_fname_split(talloc_tos(),
+                                       argv[1],
+                                       lp_posix_pathnames());
+       if (smb_fname == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       ret = SMB_VFS_SYS_ACL_BLOB_GET_FILE(vfs->conn, smb_fname, talloc_tos(),
                                            &description, &blob);
        if (ret != 0) {
                printf("sys_acl_blob_get_file failed (%s)\n", strerror(errno));