From: Ralph Boehme Date: Wed, 20 May 2020 21:03:30 +0000 (+0200) Subject: vfs_widelinks: implement SMB_VFS_OPENAT() X-Git-Tag: ldb-2.2.0~388 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c71215bd64b012ab6ff485f73c8a42390fb4fba6;p=thirdparty%2Fsamba.git vfs_widelinks: implement SMB_VFS_OPENAT() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_widelinks.c b/source3/modules/vfs_widelinks.c index 9f5661b84ae..5267c8b218e 100644 --- a/source3/modules/vfs_widelinks.c +++ b/source3/modules/vfs_widelinks.c @@ -388,6 +388,39 @@ static int widelinks_open(vfs_handle_struct *handle, mode); } +static int widelinks_openat(vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + files_struct *fsp, + int flags, + mode_t mode) +{ + struct widelinks_config *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, + config, + struct widelinks_config, + return -1); + + if (config->active && + (config->cwd != NULL) && + !(smb_fname->flags & SMB_FILENAME_POSIX_PATH)) + { + /* + * Module active, openat after chdir (see note 1b above) and not + * a POSIX open (POSIX sees symlinks), so remove O_NOFOLLOW. + */ + flags = (flags & ~O_NOFOLLOW); + } + + return SMB_VFS_NEXT_OPENAT(handle, + dirfsp, + smb_fname, + fsp, + flags, + mode); +} + static struct dirent *widelinks_readdir(vfs_handle_struct *handle, DIR *dirp, SMB_STRUCT_STAT *sbuf) @@ -425,6 +458,7 @@ static struct vfs_fn_pointers vfs_widelinks_fns = { .connect_fn = widelinks_connect, .open_fn = widelinks_open, + .openat_fn = widelinks_openat, .lstat_fn = widelinks_lstat, /* * NB. We don't need an lchown function as this