]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_cap. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 16:36:34 +0000 (09:36 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:45 +0000 (17:20 +0000)
This is identical to unlink(), as there
are no special cases needed for rmdir().

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

index 683e4fbc6d4ebed27bf49e716617bc0fbc8c5d4c..ba7a7aa35986a4edeac797a3fa5a4ac206a84887 100644 (file)
@@ -345,6 +345,39 @@ static int cap_unlink(vfs_handle_struct *handle,
        return ret;
 }
 
+static int cap_unlinkat(vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       int flags)
+{
+       struct smb_filename *smb_fname_tmp = NULL;
+       char *cappath = NULL;
+       int ret;
+
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
+       if (!cappath) {
+               errno = ENOMEM;
+               return -1;
+       }
+
+       /* Setup temporary smb_filename structs. */
+       smb_fname_tmp = cp_smb_filename(talloc_tos(), smb_fname);
+       if (smb_fname_tmp == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
+       smb_fname_tmp->base_name = cappath;
+
+       ret = SMB_VFS_NEXT_UNLINKAT(handle,
+                       dirfsp,
+                       smb_fname_tmp,
+                       flags);
+
+       TALLOC_FREE(smb_fname_tmp);
+       return ret;
+}
+
 static int cap_chmod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
@@ -1042,6 +1075,7 @@ static struct vfs_fn_pointers vfs_cap_fns = {
        .stat_fn = cap_stat,
        .lstat_fn = cap_lstat,
        .unlink_fn = cap_unlink,
+       .unlinkat_fn = cap_unlinkat,
        .chmod_fn = cap_chmod,
        .chown_fn = cap_chown,
        .lchown_fn = cap_lchown,