From 71937b16bf167fa1a338cd2563743f87d8688b44 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 11 Sep 2016 13:30:44 +0200 Subject: [PATCH] s3/vfs/nfs4_acls: avoid a stat Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Sep 27 04:03:03 CEST 2016 on sn-devel-144 --- source3/modules/nfs4_acls.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 6fe3b11fc7e..7488b1c9606 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -529,11 +529,19 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, { 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 (smbacl4_fGetFileOwner(fsp, &sbuf)) { - return map_nt_error_from_unix(errno); + if (VALID_STAT(fsp->fsp_name->st)) { + psbuf = &fsp->fsp_name->st; + } + + if (psbuf == NULL) { + if (smbacl4_fGetFileOwner(fsp, &sbuf)) { + return map_nt_error_from_unix(errno); + } + psbuf = &sbuf; } if (pparams == NULL) { @@ -544,7 +552,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp, pparams = ¶ms; } - return smb_get_nt_acl_nfs4_common(&sbuf, pparams, security_info, + return smb_get_nt_acl_nfs4_common(psbuf, pparams, security_info, mem_ctx, ppdesc, theacl); } @@ -558,12 +566,20 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn, { SMB_STRUCT_STAT sbuf; struct smbacl4_vfs_params params; + const SMB_STRUCT_STAT *psbuf = NULL; DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n", smb_fname->base_name)); - if (smbacl4_GetFileOwner(conn, smb_fname, &sbuf)) { - return map_nt_error_from_unix(errno); + if (VALID_STAT(smb_fname->st)) { + psbuf = &smb_fname->st; + } + + if (psbuf == NULL) { + if (smbacl4_GetFileOwner(conn, smb_fname, &sbuf)) { + return map_nt_error_from_unix(errno); + } + psbuf = &sbuf; } if (pparams == NULL) { @@ -574,7 +590,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn, pparams = ¶ms; } - return smb_get_nt_acl_nfs4_common(&sbuf, pparams, security_info, + return smb_get_nt_acl_nfs4_common(psbuf, pparams, security_info, mem_ctx, ppdesc, theacl); } -- 2.11.4.GIT