]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_zfsacl: ensure zfs_get_nt_acl_common() has access to stat info
authorRalph Boehme <slow@samba.org>
Wed, 6 Sep 2017 14:53:23 +0000 (16:53 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 25 Oct 2017 06:42:59 +0000 (08:42 +0200)
We'll need this in the next commit.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=6133

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit bdc7fc62011cb1744f0246aea358b93e98caef38)

source3/modules/vfs_zfsacl.c

index 0c75b9f32319ede957692c7388e75db2c8914219..e59b0bbfb4a13f8b9e4488e64c65769e3d515149 100644 (file)
  * read the local file's acls and return it in NT form
  * using the NFSv4 format conversion
  */
-static NTSTATUS zfs_get_nt_acl_common(TALLOC_CTX *mem_ctx,
+static NTSTATUS zfs_get_nt_acl_common(struct connection_struct *conn,
+                                     TALLOC_CTX *mem_ctx,
                                      const struct smb_filename *smb_fname,
                                      struct SMB4ACL_T **ppacl)
 {
        int naces, i;
        ace_t *acebuf;
        struct SMB4ACL_T *pacl;
+       SMB_STRUCT_STAT sbuf;
+       const SMB_STRUCT_STAT *psbuf = NULL;
+       int ret;
+
+       if (VALID_STAT(smb_fname->st)) {
+               psbuf = &smb_fname->st;
+       }
+
+       if (psbuf == NULL) {
+               ret = vfs_stat_smb_basename(conn, smb_fname, &sbuf);
+               if (ret != 0) {
+                       DBG_INFO("stat [%s]failed: %s\n",
+                                smb_fname_str_dbg(smb_fname), strerror(errno));
+                       return map_nt_error_from_unix(errno);
+               }
+               psbuf = &sbuf;
+       }
 
        /* read the number of file aces */
        if((naces = acl(smb_fname->base_name, ACE_GETACLCNT, 0, NULL)) == -1) {
@@ -201,7 +219,8 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle,
        NTSTATUS status;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       status = zfs_get_nt_acl_common(frame, fsp->fsp_name, &pacl);
+       status = zfs_get_nt_acl_common(handle->conn, frame,
+                                      fsp->fsp_name, &pacl);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
                return status;
@@ -223,7 +242,7 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle,
        NTSTATUS status;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       status = zfs_get_nt_acl_common(frame, smb_fname, &pacl);
+       status = zfs_get_nt_acl_common(handle->conn, frame, smb_fname, &pacl);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
                return status;