s3:smbd:vfs: Change posix_get_nt_acl() from const char * to const struct smb_filename *.
authorJeremy Allison <jra@samba.org>
Fri, 11 Mar 2016 00:05:48 +0000 (16:05 -0800)
committerJeremy Allison <jra@samba.org>
Mon, 14 Mar 2016 22:02:11 +0000 (23:02 +0100)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <rb@sernet.de>
source3/modules/vfs_aixacl2.c
source3/modules/vfs_default.c
source3/modules/vfs_gpfs.c
source3/smbd/posix_acls.c
source3/smbd/proto.h

index 0efcc001f99ab80b736f4af4b20d5c63fad9c6f8..1c9f84bf2a877cac778d5d79d9b3037422fd7c52 100644 (file)
@@ -204,7 +204,7 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
        {
                DEBUG(10, ("retrying with posix acl...\n"));
                return posix_get_nt_acl(handle->conn,
-                               smb_fname->base_name,
+                               smb_fname,
                                security_info,
                                mem_ctx,
                                ppdesc);
index ee9ddb20e5fe24b88dfa0be1d9cb1a609ac6ee8f..ea7dc2caf99fc59c899e05e6069e3ba29fcdff86 100644 (file)
@@ -2344,7 +2344,7 @@ static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
 
        START_PROFILE(get_nt_acl);
        result = posix_get_nt_acl(handle->conn,
-                               smb_fname->base_name,
+                               smb_fname,
                                security_info,
                                mem_ctx,
                                ppdesc);
index c9cc88d10dbfea4f9a63c4db7b3f20cd6a65f77a..09e37fa7f5374f5327857b89a55509d63a6d074c 100644 (file)
@@ -622,7 +622,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
 
        if (result > 0) {
                DEBUG(10, ("retrying with posix acl...\n"));
-               status = posix_get_nt_acl(handle->conn, smb_fname->base_name,
+               status = posix_get_nt_acl(handle->conn, smb_fname,
                                          security_info, mem_ctx, ppdesc);
                TALLOC_FREE(frame);
                return status;
index ac296e24ea0e987cffa59a11e9e5341299cf614b..c4eeb9c4bd921aae442b6b8225a2b720e1e582ba 100644 (file)
@@ -3516,7 +3516,7 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
 
        /* can it happen that fsp_name == NULL ? */
        if (fsp->is_directory ||  fsp->fh->fd == -1) {
-               status = posix_get_nt_acl(fsp->conn, fsp->fsp_name->base_name,
+               status = posix_get_nt_acl(fsp->conn, fsp->fsp_name,
                                          security_info, mem_ctx, ppdesc);
                TALLOC_FREE(frame);
                return status;
@@ -3540,31 +3540,36 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
        return status;
 }
 
-NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
-                         uint32_t security_info,
-                         TALLOC_CTX *mem_ctx,
-                         struct security_descriptor **ppdesc)
+NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
+                       const struct smb_filename *smb_fname_in,
+                       uint32_t security_info,
+                       TALLOC_CTX *mem_ctx,
+                       struct security_descriptor **ppdesc)
 {
        SMB_ACL_T posix_acl = NULL;
        SMB_ACL_T def_acl = NULL;
        struct pai_val *pal;
-       struct smb_filename smb_fname;
+       struct smb_filename *smb_fname = NULL;
        int ret;
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
 
        *ppdesc = NULL;
 
-       DEBUG(10,("posix_get_nt_acl: called for file %s\n", name ));
+       DEBUG(10,("posix_get_nt_acl: called for file %s\n",
+               smb_fname_in->base_name ));
 
-       ZERO_STRUCT(smb_fname);
-       smb_fname.base_name = discard_const_p(char, name);
+       smb_fname = cp_smb_filename(talloc_tos(), smb_fname_in);
+       if (smb_fname == NULL) {
+               TALLOC_FREE(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        /* Get the stat struct for the owner info. */
        if (lp_posix_pathnames()) {
-               ret = SMB_VFS_LSTAT(conn, &smb_fname);
+               ret = SMB_VFS_LSTAT(conn, smb_fname);
        } else {
-               ret = SMB_VFS_STAT(conn, &smb_fname);
+               ret = SMB_VFS_STAT(conn, smb_fname);
        }
 
        if (ret == -1) {
@@ -3573,22 +3578,27 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
        }
 
        /* Get the ACL from the path. */
-       posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name,
+       posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, smb_fname->base_name,
                                             SMB_ACL_TYPE_ACCESS, frame);
 
        /* If it's a directory get the default POSIX ACL. */
-       if(S_ISDIR(smb_fname.st.st_ex_mode)) {
-               def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name,
+       if(S_ISDIR(smb_fname->st.st_ex_mode)) {
+               def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, smb_fname->base_name,
                                                   SMB_ACL_TYPE_DEFAULT, frame);
                def_acl = free_empty_sys_acl(conn, def_acl);
        }
 
-       pal = load_inherited_info(conn, name);
+       pal = load_inherited_info(conn, smb_fname->base_name);
 
-       status = posix_get_nt_acl_common(conn, name, &smb_fname.st, pal,
-                                        posix_acl, def_acl, security_info,
-                                        mem_ctx,
-                                        ppdesc);
+       status = posix_get_nt_acl_common(conn,
+                                       smb_fname->base_name,
+                                       &smb_fname->st,
+                                       pal,
+                                       posix_acl,
+                                       def_acl,
+                                       security_info,
+                                       mem_ctx,
+                                       ppdesc);
        TALLOC_FREE(frame);
        return status;
 }
index e1ec063226f1ca7592aa29b0e2f355d53115f5c8..f9ae4a3047b01f9b0913f661e7d277dfd171bb77 100644 (file)
@@ -751,10 +751,11 @@ SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
 NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
                           TALLOC_CTX *mem_ctx,
                           struct security_descriptor **ppdesc);
-NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
-                         uint32_t security_info,
-                         TALLOC_CTX *mem_ctx,
-                         struct security_descriptor **ppdesc);
+NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
+                       const struct smb_filename *smb_fname_in,
+                       uint32_t security_info,
+                       TALLOC_CTX *mem_ctx,
+                       struct security_descriptor **ppdesc);
 NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid);
 NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct security_descriptor *psd);
 int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode );