s3: VFS: vfs_acl_xattr. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Wed, 11 Sep 2019 23:49:38 +0000 (16:49 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:44 +0000 (17:20 +0000)
Note this isn't identical to unlink() as
this must cope with (flags & AT_REMOVEDIR),
which is identical to rmdir(). It calls
either unlink or rmdir depending on the
flags parameter.

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

index b8190fd4b1cbf8c1fc51c90c5420e105531cf599..80779cd9577ee74368c23180bf7a3a93f1324bee 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "smbd/smbd.h"
+#include "system/filesys.h"
 #include "librpc/gen_ndr/xattr.h"
 #include "auth.h"
 #include "vfs_acl_common.h"
@@ -277,6 +278,21 @@ static int connect_acl_xattr(struct vfs_handle_struct *handle,
        return 0;
 }
 
+static int acl_xattr_unlinkat(vfs_handle_struct *handle,
+                        struct files_struct *dirfsp,
+                        const struct smb_filename *smb_fname,
+                        int flags)
+{
+       int ret;
+
+       if (flags & AT_REMOVEDIR) {
+               ret = rmdir_acl_common(handle, smb_fname);
+       } else {
+               ret = unlink_acl_common(handle, smb_fname);
+       }
+       return ret;
+}
+
 static NTSTATUS acl_xattr_fget_nt_acl(vfs_handle_struct *handle,
                                      files_struct *fsp,
                                      uint32_t security_info,
@@ -317,6 +333,7 @@ static struct vfs_fn_pointers vfs_acl_xattr_fns = {
        .connect_fn = connect_acl_xattr,
        .rmdir_fn = rmdir_acl_common,
        .unlink_fn = unlink_acl_common,
+       .unlinkat_fn = acl_xattr_unlinkat,
        .chmod_fn = chmod_acl_module_common,
        .fchmod_fn = fchmod_acl_module_common,
        .fget_nt_acl_fn = acl_xattr_fget_nt_acl,