From: Ralph Boehme Date: Mon, 1 Feb 2021 11:09:39 +0000 (+0100) Subject: smbd: stat path before calling openat_pathref_fsp() in smbd_dirptr_get_entry() X-Git-Tag: tevent-0.11.0~1823 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87e97e1b519159b5f4c5ed4ef684783855e79ac3;p=thirdparty%2Fsamba.git smbd: stat path before calling openat_pathref_fsp() in smbd_dirptr_get_entry() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 010186edc45..d7b1363205c 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -798,6 +798,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, const char *dpath = dirptr->smb_dname->base_name; bool dirptr_path_is_dot = ISDOT(dpath); NTSTATUS status; + int ret; *_smb_fname = NULL; *_mode = 0; @@ -892,11 +893,27 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, return false; } + if (!VALID_STAT(smb_fname->st)) { + /* + * If stat() fails with ENOENT it might be a + * msdfs-symlink in Windows context, this is checked + * below, for now we just want to fill stat info as good + * as we can. + */ + ret = vfs_stat(conn, smb_fname); + if (ret != 0 && errno != ENOENT) { + TALLOC_FREE(smb_fname); + TALLOC_FREE(dname); + TALLOC_FREE(fname); + continue; + } + } + /* Create smb_fname with NULL stream_name. */ atname = synthetic_smb_fname(talloc_tos(), dname, NULL, - &sbuf, + &smb_fname->st, dirptr->smb_dname->twrp, dirptr->smb_dname->flags); if (atname == NULL) {