]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: ACLs. Remove smb_fname argument to get_nt_acl_common().
authorJeremy Allison <jra@samba.org>
Mon, 13 Apr 2020 19:53:58 +0000 (12:53 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 7 May 2020 19:27:34 +0000 (19:27 +0000)
As a bonus stat_fsp_or_smb_fname() is no longer used.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_acl_common.c
source3/modules/vfs_acl_common.h
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_acl_xattr.c

index 67c3f9f9f282aace99bc90ded4743fa9315be7ff..5c6105701bc8bc7eedb52a9f3b65eb287ca16733 100644 (file)
@@ -593,6 +593,7 @@ fail:
        return status;
 }
 
+#if 0
 static NTSTATUS stat_fsp_or_smb_fname(vfs_handle_struct *handle,
                                      files_struct *fsp,
                                      const struct smb_filename *smb_fname,
@@ -634,6 +635,7 @@ static NTSTATUS stat_fsp_or_smb_fname(vfs_handle_struct *handle,
 
        return NT_STATUS_OK;
 }
+#endif
 
 /*******************************************************************
  Pull a DATA_BLOB from an xattr given an fsp.
@@ -792,11 +794,9 @@ fail:
 NTSTATUS get_nt_acl_common(
        NTSTATUS (*get_acl_blob_fn)(TALLOC_CTX *ctx,
                                    vfs_handle_struct *handle,
-                                   files_struct *fsp,
                                    const struct smb_filename *smb_fname,
                                    DATA_BLOB *pblob),
        vfs_handle_struct *handle,
-       files_struct *fsp,
        const struct smb_filename *smb_fname_in,
        uint32_t security_info,
        TALLOC_CTX *mem_ctx,
@@ -805,7 +805,6 @@ NTSTATUS get_nt_acl_common(
        DATA_BLOB blob = data_blob_null;
        NTSTATUS status;
        struct security_descriptor *psd = NULL;
-       const struct smb_filename *smb_fname = NULL;
        bool psd_is_from_fs = false;
        struct acl_common_config *config = NULL;
 
@@ -813,27 +812,21 @@ NTSTATUS get_nt_acl_common(
                                struct acl_common_config,
                                return NT_STATUS_UNSUCCESSFUL);
 
-       if (fsp && smb_fname_in == NULL) {
-               smb_fname = fsp->fsp_name;
-       } else {
-               smb_fname = smb_fname_in;
-       }
-
-       DBG_DEBUG("name=%s\n", smb_fname->base_name);
+       DBG_DEBUG("name=%s\n", smb_fname_in->base_name);
 
-       status = get_acl_blob_fn(mem_ctx, handle, fsp, smb_fname, &blob);
+       status = get_acl_blob_fn(mem_ctx, handle, smb_fname_in, &blob);
        if (NT_STATUS_IS_OK(status)) {
                status = validate_nt_acl_blob(mem_ctx,
                                              handle,
-                                             fsp,
-                                             smb_fname,
+                                             NULL,
+                                             smb_fname_in,
                                              &blob,
                                              &psd,
                                              &psd_is_from_fs);
                TALLOC_FREE(blob.data);
                if (!NT_STATUS_IS_OK(status)) {
                        DBG_DEBUG("ACL validation for [%s] failed\n",
-                                 smb_fname->base_name);
+                                 smb_fname_in->base_name);
                        goto fail;
                }
        }
@@ -845,42 +838,36 @@ NTSTATUS get_nt_acl_common(
 
                if (config->ignore_system_acls) {
                        SMB_STRUCT_STAT sbuf;
-                       SMB_STRUCT_STAT *psbuf = &sbuf;
+                       int ret;
 
-                       status = stat_fsp_or_smb_fname(handle, fsp, smb_fname,
-                                                      &sbuf, &psbuf);
-                       if (!NT_STATUS_IS_OK(status)) {
+                       ret = vfs_stat_smb_basename(handle->conn,
+                                       smb_fname_in,
+                                       &sbuf);
+                       if (ret == -1) {
+                               status = map_nt_error_from_unix(errno);
                                goto fail;
                        }
 
                        status = make_default_filesystem_acl(
                                mem_ctx,
                                config->default_acl_style,
-                               smb_fname->base_name,
-                               psbuf,
+                               smb_fname_in->base_name,
+                               &sbuf,
                                &psd);
                        if (!NT_STATUS_IS_OK(status)) {
                                goto fail;
                        }
                } else {
-                       if (fsp) {
-                               status = SMB_VFS_NEXT_FGET_NT_ACL(handle,
-                                                                 fsp,
-                                                                 security_info,
-                                                                 mem_ctx,
-                                                                 &psd);
-                       } else {
-                               status = SMB_VFS_NEXT_GET_NT_ACL(handle,
-                                                                smb_fname,
-                                                                security_info,
-                                                                mem_ctx,
-                                                                &psd);
-                       }
+                       status = SMB_VFS_NEXT_GET_NT_ACL(handle,
+                                                        smb_fname_in,
+                                                        security_info,
+                                                        mem_ctx,
+                                                        &psd);
 
                        if (!NT_STATUS_IS_OK(status)) {
                                DBG_DEBUG("get_next_acl for file %s "
                                          "returned %s\n",
-                                         smb_fname->base_name,
+                                         smb_fname_in->base_name,
                                          nt_errstr(status));
                                goto fail;
                        }
@@ -891,8 +878,8 @@ NTSTATUS get_nt_acl_common(
 
        if (psd_is_from_fs) {
                SMB_STRUCT_STAT sbuf;
-               SMB_STRUCT_STAT *psbuf = &sbuf;
                bool is_directory = false;
+               int ret;
 
                /*
                 * We're returning the underlying ACL from the
@@ -900,19 +887,21 @@ NTSTATUS get_nt_acl_common(
                 * inheritable ACE entries we have to fake them.
                 */
 
-               status = stat_fsp_or_smb_fname(handle, fsp, smb_fname,
-                                              &sbuf, &psbuf);
-               if (!NT_STATUS_IS_OK(status)) {
+               ret = vfs_stat_smb_basename(handle->conn,
+                               smb_fname_in,
+                               &sbuf);
+               if (ret == -1) {
+                       status = map_nt_error_from_unix(errno);
                        goto fail;
                }
 
-               is_directory = S_ISDIR(psbuf->st_ex_mode);
+               is_directory = S_ISDIR(sbuf.st_ex_mode);
 
                if (is_directory && !sd_has_inheritable_components(psd, true)) {
                        status = add_directory_inheritable_components(
                                handle,
-                               smb_fname->base_name,
-                               psbuf,
+                               smb_fname_in->base_name,
+                               &sbuf,
                                psd);
                        if (!NT_STATUS_IS_OK(status)) {
                                goto fail;
@@ -944,7 +933,7 @@ NTSTATUS get_nt_acl_common(
 
        if (DEBUGLEVEL >= 10) {
                DBG_DEBUG("returning acl for %s is:\n",
-                         smb_fname->base_name);
+                         smb_fname_in->base_name);
                NDR_PRINT_DEBUG(security_descriptor, psd);
        }
 
index fb3dfef304ed59a38a01469e6a3d5c04c4a7d9a3..89450bfc730a8278a730842ad7e3339784ba9622 100644 (file)
@@ -50,11 +50,9 @@ int chmod_acl_acl_module_common(struct vfs_handle_struct *handle,
 NTSTATUS get_nt_acl_common(
        NTSTATUS (*get_acl_blob_fn)(TALLOC_CTX *ctx,
                                    vfs_handle_struct *handle,
-                                   files_struct *fsp,
                                    const struct smb_filename *smb_fname,
                                    DATA_BLOB *pblob),
        vfs_handle_struct *handle,
-       files_struct *fsp,
        const struct smb_filename *smb_fname_in,
        uint32_t security_info,
        TALLOC_CTX *mem_ctx,
index 0587f86fbdc4d39e9789a745444b8d7102cd24c5..977bd693c0626f924704876386475cdf539de3cf 100644 (file)
@@ -160,7 +160,6 @@ static NTSTATUS fget_acl_blob(TALLOC_CTX *ctx,
 
 static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
                        vfs_handle_struct *handle,
-                       files_struct *fsp,
                        const struct smb_filename *smb_fname,
                        DATA_BLOB *pblob)
 {
@@ -170,19 +169,15 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
        struct db_context *db = acl_db;
        NTSTATUS status = NT_STATUS_OK;
        SMB_STRUCT_STAT sbuf;
+       int ret;
 
        ZERO_STRUCT(sbuf);
 
-       if (fsp) {
-               status = vfs_stat_fsp(fsp);
-               sbuf = fsp->fsp_name->st;
-       } else {
-               int ret = vfs_stat_smb_basename(handle->conn,
+       ret = vfs_stat_smb_basename(handle->conn,
                                smb_fname,
                                &sbuf);
-               if (ret == -1) {
-                       status = map_nt_error_from_unix(errno);
-               }
+       if (ret == -1) {
+               status = map_nt_error_from_unix(errno);
        }
 
        if (!NT_STATUS_IS_OK(status)) {
@@ -205,8 +200,8 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
        pblob->data = data.dptr;
        pblob->length = data.dsize;
 
-       DEBUG(10,("get_acl_blob: returned %u bytes from file %s\n",
-               (unsigned int)data.dsize, smb_fname->base_name ));
+       DBG_DEBUG("returned %u bytes from file %s\n",
+               (unsigned int)data.dsize, smb_fname->base_name );
 
        if (pblob->length == 0 || pblob->data == NULL) {
                return NT_STATUS_NOT_FOUND;
@@ -466,7 +461,7 @@ static NTSTATUS acl_tdb_get_nt_acl(vfs_handle_struct *handle,
                                   struct security_descriptor **ppdesc)
 {
        NTSTATUS status;
-       status = get_nt_acl_common(get_acl_blob, handle, NULL, smb_fname,
+       status = get_nt_acl_common(get_acl_blob, handle, smb_fname,
                                   security_info, mem_ctx, ppdesc);
        return status;
 }
index 6f5302aaea526a68bdc874f4b1c2626e6a4bafc9..bd8a164f0fe4dd000b3e79b2038684bef6810e16 100644 (file)
@@ -124,7 +124,6 @@ static NTSTATUS fget_acl_blob(TALLOC_CTX *ctx,
 
 static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
                        vfs_handle_struct *handle,
-                       files_struct *fsp,
                        const struct smb_filename *smb_fname,
                        DATA_BLOB *pblob)
 {
@@ -145,7 +144,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
        val = tmp;
 
        sizeret =
-           getxattr_do(handle, fsp, smb_fname, XATTR_NTACL_NAME, val, size);
+           getxattr_do(handle, NULL, smb_fname, XATTR_NTACL_NAME, val, size);
 
        if (sizeret >= 0) {
                pblob->data = val;
@@ -159,7 +158,7 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
 
        /* Too small, try again. */
        sizeret =
-           getxattr_do(handle, fsp, smb_fname, XATTR_NTACL_NAME, NULL, 0);
+           getxattr_do(handle, NULL, smb_fname, XATTR_NTACL_NAME, NULL, 0);
        if (sizeret < 0) {
                goto err;
        }
@@ -375,7 +374,7 @@ static NTSTATUS acl_xattr_get_nt_acl(vfs_handle_struct *handle,
                                     struct security_descriptor **ppdesc)
 {
        NTSTATUS status;
-       status = get_nt_acl_common(get_acl_blob, handle, NULL, smb_fname,
+       status = get_nt_acl_common(get_acl_blob, handle, smb_fname,
                                   security_info, mem_ctx, ppdesc);
        return status;
 }