nfs4_acls: Use fsp stat buffer in smb_fget_nt_acl_nfs4
authorChristof Schmitt <cs@samba.org>
Thu, 18 Jul 2019 18:16:33 +0000 (11:16 -0700)
committerChristof Schmitt <cs@samba.org>
Tue, 23 Jul 2019 19:45:05 +0000 (19:45 +0000)
Instead of having a local buffer for the stat data, update the one kept
in the fsp. With this change the local stat buffer and the helper
function smbacl4_fGetFileOwner are no longer needed and can be removed.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Tue Jul 23 19:45:05 UTC 2019 on sn-devel-184

source3/modules/nfs4_acls.c

index 663dc150fa7b79dc03395f2519b066399aca50b8..4d50223c79517f42e97c018c00ae38bb5aeefb76 100644 (file)
@@ -289,24 +289,6 @@ static int smbacl4_GetFileOwner(struct connection_struct *conn,
        return 0;
 }
 
-static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf)
-{
-       ZERO_STRUCTP(psbuf);
-
-       if (fsp->fh->fd == -1) {
-               return smbacl4_GetFileOwner(fsp->conn,
-                                           fsp->fsp_name, psbuf);
-       }
-       if (SMB_VFS_FSTAT(fsp, psbuf) != 0)
-       {
-               DEBUG(8, ("SMB_VFS_FSTAT failed with error %s\n",
-                       strerror(errno)));
-               return -1;
-       }
-
-       return 0;
-}
-
 static void check_for_duplicate_sec_ace(struct security_ace *nt_ace_list,
                                        int *good_aces)
 {
@@ -565,21 +547,17 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
                              struct security_descriptor **ppdesc,
                              struct SMB4ACL_T *theacl)
 {
-       SMB_STRUCT_STAT sbuf;
        struct smbacl4_vfs_params params;
-       SMB_STRUCT_STAT *psbuf = NULL;
 
        DEBUG(10, ("smb_fget_nt_acl_nfs4 invoked for %s\n", fsp_str_dbg(fsp)));
 
-       if (VALID_STAT(fsp->fsp_name->st)) {
-               psbuf = &fsp->fsp_name->st;
-       }
+       if (!VALID_STAT(fsp->fsp_name->st)) {
+               NTSTATUS status;
 
-       if (psbuf == NULL) {
-               if (smbacl4_fGetFileOwner(fsp, &sbuf)) {
-                       return map_nt_error_from_unix(errno);
+               status = vfs_stat_fsp(fsp);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
                }
-               psbuf = &sbuf;
        }
 
        if (pparams == NULL) {
@@ -590,7 +568,8 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
                pparams = &params;
        }
 
-       return smb_get_nt_acl_nfs4_common(psbuf, pparams, security_info,
+       return smb_get_nt_acl_nfs4_common(&fsp->fsp_name->st, pparams,
+                                         security_info,
                                          mem_ctx, ppdesc, theacl);
 }