diff --git a/source3/modules/vfs_widelinks.c b/source3/modules/vfs_widelinks.c index 4339f6de9e0..f9378b69c57 100644 --- a/source3/modules/vfs_widelinks.c +++ b/source3/modules/vfs_widelinks.c @@ -340,6 +340,48 @@ static int widelinks_lstat(vfs_handle_struct *handle, return SMB_VFS_NEXT_STAT(handle, smb_fname); } +static int widelinks_fstatat( + struct vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + SMB_STRUCT_STAT *sbuf, + int flags) +{ + struct widelinks_config *config = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, + config, + struct widelinks_config, + return -1); + + if (!config->active) { + /* Module not active. */ + return SMB_VFS_NEXT_FSTATAT(handle, + dirfsp, + smb_fname, + sbuf, + flags); + } + + if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) { + /* POSIX sees symlinks. */ + return SMB_VFS_NEXT_FSTATAT(handle, + dirfsp, + smb_fname, + sbuf, + flags); + } + + /* Don't see symlinks. */ + flags &= ~AT_SYMLINK_NOFOLLOW; + + return SMB_VFS_NEXT_FSTATAT(handle, + dirfsp, + smb_fname, + sbuf, + flags); +} + static int widelinks_openat(vfs_handle_struct *handle, const struct files_struct *dirfsp, const struct smb_filename *smb_fname, @@ -408,6 +450,7 @@ static struct vfs_fn_pointers vfs_widelinks_fns = { .openat_fn = widelinks_openat, .lstat_fn = widelinks_lstat, + .fstatat_fn = widelinks_fstatat, /* * NB. We don't need an lchown function as this * is only called (a) on directory create and