]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: stat path before calling openat_pathref_fsp() in smbd_dirptr_get_entry()
authorRalph Boehme <slow@samba.org>
Mon, 1 Feb 2021 11:09:39 +0000 (12:09 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 5 Feb 2021 06:22:35 +0000 (06:22 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dir.c

index 010186edc455a4a743a00737c490f89ab992c596..d7b1363205ccb49444f0a00f64162e5f9a191428 100644 (file)
@@ -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) {