From: Noel Power Date: Thu, 27 Jul 2023 12:26:21 +0000 (+0100) Subject: s3/modules: Fix DFS links when widelinks = yes X-Git-Tag: samba-4.17.11~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10f3fafc6f4fedbc182894c3d03fd2939cfcee18;p=thirdparty%2Fsamba.git s3/modules: Fix DFS links when widelinks = yes In openat(), even if we fail to open the file, propagate stat if and only if the object is a link in a DFS share. This allows calling code to further process the link. Also remove knownfail Pair-Programmed-With: Jeremy Alison BUG: https://bugzilla.samba.org/show_bug.cgi?id=15435 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Jul 29 00:43:52 UTC 2023 on atb-devel-224 (cherry picked from commit 0bf8b25aacdf2f5c746922320b32e3f0886c81f5) Autobuild-User(v4-17-test): Jule Anger Autobuild-Date(v4-17-test): Thu Aug 3 12:46:29 UTC 2023 on sn-devel-184 --- diff --git a/selftest/knownfail.d/smbclient-bug15435 b/selftest/knownfail.d/smbclient-bug15435 deleted file mode 100644 index c7d64a1e66a..00000000000 --- a/selftest/knownfail.d/smbclient-bug15435 +++ /dev/null @@ -1 +0,0 @@ -^samba3.blackbox.smbclient-bug15435.smbclient diff --git a/source3/modules/vfs_widelinks.c b/source3/modules/vfs_widelinks.c index a86f62572ac..c68468a950b 100644 --- a/source3/modules/vfs_widelinks.c +++ b/source3/modules/vfs_widelinks.c @@ -348,7 +348,7 @@ static int widelinks_openat(vfs_handle_struct *handle, { struct vfs_open_how how = *_how; struct widelinks_config *config = NULL; - + int ret; SMB_VFS_HANDLE_GET_DATA(handle, config, struct widelinks_config, @@ -365,11 +365,33 @@ static int widelinks_openat(vfs_handle_struct *handle, how.flags = (how.flags & ~O_NOFOLLOW); } - return SMB_VFS_NEXT_OPENAT(handle, + ret = SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, &how); + if (config->is_dfs_share && ret == -1 && errno == ENOENT) { + struct smb_filename *full_fname = NULL; + int lstat_ret; + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + errno = ENOMEM; + return -1; + } + lstat_ret = SMB_VFS_NEXT_LSTAT(handle, + full_fname); + if (lstat_ret != -1 && + VALID_STAT(full_fname->st) && + S_ISLNK(full_fname->st.st_ex_mode)) { + fsp->fsp_name->st = full_fname->st; + } + TALLOC_FREE(full_fname); + errno = ENOENT; + } + return ret; } static struct dirent *widelinks_readdir(vfs_handle_struct *handle,