From: Jeremy Allison Date: Thu, 12 Sep 2019 16:36:34 +0000 (-0700) Subject: s3: VFS: vfs_cap. Implement unlinkat(). X-Git-Tag: talloc-2.3.1~647 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4794e8dbb108d8fe7e09a11a5bf651dcdf55c2a2;p=thirdparty%2Fsamba.git s3: VFS: vfs_cap. Implement unlinkat(). This is identical to unlink(), as there are no special cases needed for rmdir(). Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index 683e4fbc6d4..ba7a7aa3598 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -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,