Add the SEC_DIR_LIST check to dptr_create().
authorJeremy Allison <jra@samba.org>
Fri, 4 Nov 2011 23:46:47 +0000 (16:46 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 7 Nov 2011 20:11:03 +0000 (21:11 +0100)
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Mon Nov  7 21:11:03 CET 2011 on sn-devel-104

source3/smbd/dir.c

index a11c131b49c92e6b0373ef2aaba2125bad63d43b..322c2fe5195f4fef761fe2be8844751dbb64f1f4 100644 (file)
@@ -452,6 +452,33 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
                }
                dir_hnd = OpenDir_fsp(NULL, conn, fsp, wcard, attr);
        } else {
+               int ret;
+               struct smb_filename *smb_dname = NULL;
+               NTSTATUS status = create_synthetic_smb_fname(talloc_tos(),
+                                               path,
+                                               NULL,
+                                               NULL,
+                                               &smb_dname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+               if (lp_posix_pathnames()) {
+                       ret = SMB_VFS_LSTAT(conn, smb_dname);
+               } else {
+                       ret = SMB_VFS_STAT(conn, smb_dname);
+               }
+               if (ret == -1) {
+                       return map_nt_error_from_unix(errno);
+               }
+               if (!S_ISDIR(smb_dname->st.st_ex_mode)) {
+                       return NT_STATUS_NOT_A_DIRECTORY;
+               }
+               status = smbd_check_access_rights(conn,
+                                               smb_dname,
+                                               SEC_DIR_LIST);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
                dir_hnd = OpenDir(NULL, conn, path, wcard, attr);
        }