]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: hpuxacl. Add hpuxacl_sys_acl_delete_def_fd().
authorJeremy Allison <jra@samba.org>
Fri, 14 May 2021 22:11:20 +0000 (15:11 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 18 May 2021 17:29:34 +0000 (17:29 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/modules/vfs_hpuxacl.c
source3/modules/vfs_hpuxacl.h

index d584ba45099ede8c275aadb21c58348df5859d51..0095fbe9504583c4e3d64bb8fecdaae5015cc190 100644 (file)
@@ -397,6 +397,60 @@ int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
        return ret;
 }
 
+/*
+ * delete the default ACL of a directory
+ *
+ * This is achieved by fetching the access ACL and rewriting it
+ * directly, via the hpux system call: the ACL_SET call on
+ * directories writes both the access and the default ACL as provided.
+ *
+ * XXX: posix acl_delete_def_file returns an error if
+ * the file referred to by path is not a directory.
+ * this function does not complain but the actions
+ * have no effect on a file other than a directory.
+ * But sys_acl_delete_default_file is only called in
+ * smbd/posixacls.c after having checked that the file
+ * is a directory, anyways. So implementing the extra
+ * check is considered unnecessary. --- Agreed? XXX
+ */
+int hpuxacl_sys_acl_delete_def_fd(vfs_handle_struct *handle,
+                                 files_struct *fsp)
+{
+       SMB_ACL_T smb_acl;
+       int ret = -1;
+       HPUX_ACL_T hpux_acl;
+       int count;
+
+       DBG_DEBUG("entering hpuxacl_sys_acl_delete_def_fd.\n");
+
+       smb_acl = hpuxacl_sys_acl_get_file(handle, fsp->fsp_name->base_name,
+                                          SMB_ACL_TYPE_ACCESS);
+       if (smb_acl == NULL) {
+               DBG_DEBUG("getting file acl failed!\n");
+               goto done;
+       }
+       if (!smb_acl_to_hpux_acl(smb_acl, &hpux_acl, &count,
+                                SMB_ACL_TYPE_ACCESS))
+       {
+               DBG_DEBUG("conversion smb_acl -> hpux_acl failed.\n");
+               goto done;
+       }
+       if (!hpux_acl_sort(hpux_acl, count)) {
+               DBG_DEBUG("resulting acl is not valid!\n");
+               goto done;
+       }
+       ret = acl(discard_const_p(char, fsp->fsp_name->base_name),
+                               ACL_SET, count, hpux_acl);
+       if (ret != 0) {
+               DBG_DEBUG("settinge file acl failed!\n");
+       }
+
+ done:
+       DBG_DEBUG("hpuxacl_sys_acl_delete_def_fd %s.\n",
+                 ((ret != 0) ? "failed" : "succeeded" ));
+       TALLOC_FREE(smb_acl);
+       return ret;
+}
 
 /* 
  * private functions 
@@ -1164,6 +1218,7 @@ static struct vfs_fn_pointers hpuxacl_fns = {
        .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
        .sys_acl_set_fd_fn = hpuxacl_sys_acl_set_fd,
        .sys_acl_delete_def_file_fn = hpuxacl_sys_acl_delete_def_file,
+       .sys_acl_delete_def_fd_fn = hpuxacl_sys_acl_delete_def_fd,
 };
 
 static_decl_vfs;
index 087dc6c3015eca5ee271226ae3d11bd63e76b043..be21afddb0e66bf86ddabe37bbe296e028ec3213 100644 (file)
@@ -52,5 +52,8 @@ int hpuxacl_sys_acl_set_fd(vfs_handle_struct *handle,
 int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname);
 
+int hpuxacl_sys_acl_delete_def_fd(vfs_handle_struct *handle,
+                       files_struct *fsp);
+
 #endif