]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Make open_directory() always open a fd.
authorJeremy Allison <jra@samba.org>
Fri, 28 Jun 2019 17:20:35 +0000 (10:20 -0700)
committerRalph Boehme <slow@samba.org>
Sun, 30 Jun 2019 11:32:17 +0000 (11:32 +0000)
As we never use kernel oplocks on directory handles,
there is no reason not to always open file descriptors (no
more "stat" opens on directories).

Preparing to have SMB1search use real directory
opens.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 095d8c2427d99af659ae682794cad092fb702ce1..411c917e55f7bbb1eb85a72b7eabcd9f6b350002 100644 (file)
@@ -4237,33 +4237,19 @@ static NTSTATUS open_directory(connection_struct *conn,
        */
        ZERO_STRUCT(mtimespec);
 
-       if (access_mask & (FILE_LIST_DIRECTORY|
-                          FILE_ADD_FILE|
-                          FILE_ADD_SUBDIRECTORY|
-                          FILE_TRAVERSE|
-                          DELETE_ACCESS|
-                          FILE_DELETE_CHILD|
-                          WRITE_DAC_ACCESS|
-                          WRITE_OWNER_ACCESS|
-                          READ_CONTROL_ACCESS)) {
 #ifdef O_DIRECTORY
-               status = fd_open(conn, fsp, O_RDONLY|O_DIRECTORY, 0);
+       status = fd_open(conn, fsp, O_RDONLY|O_DIRECTORY, 0);
 #else
-               /* POSIX allows us to open a directory with O_RDONLY. */
-               status = fd_open(conn, fsp, O_RDONLY, 0);
+       /* POSIX allows us to open a directory with O_RDONLY. */
+       status = fd_open(conn, fsp, O_RDONLY, 0);
 #endif
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(5, ("open_directory: Could not open fd for "
-                               "%s (%s)\n",
-                               smb_fname_str_dbg(smb_dname),
-                               nt_errstr(status)));
-                       file_free(req, fsp);
-                       return status;
-               }
-       } else {
-               fsp->fh->fd = -1;
-               DEBUG(10, ("Not opening Directory %s\n",
-                       smb_fname_str_dbg(smb_dname)));
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_INFO("Could not open fd for "
+                       "%s (%s)\n",
+                       smb_fname_str_dbg(smb_dname),
+                       nt_errstr(status));
+               file_free(req, fsp);
+               return status;
        }
 
        status = vfs_stat_fsp(fsp);