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,