smbd: use fd_openat()
authorRalph Boehme <slow@samba.org>
Fri, 8 May 2020 14:32:56 +0000 (16:32 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:35 +0000 (20:38 +0000)
This leaves basically two callers of fd_open():

* open_internal_dirfsp_at()
* smbd_smb2_query_directory_send()

Those will be the only codepaths that use full paths relative to the share root
and so require and use the symlink race protection provided by
non_widelink_open().

Of course, until we actuall start passing real dirfsps to fd_openat(),
fd_openat() internally calls fd_open().

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

index 0b0885238937fbfdbcd4c3436047141f99df0556..b71e06819d77fe0ab1a1d1b3f0091e6117c443bb 100644 (file)
@@ -815,7 +815,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
                flags = O_RDONLY;
        }
 
-       status = fd_open(fsp, flags, 0 /* mode */);
+       status = fd_openat(fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(lck);
                DEBUG(1, ("vfs_default_durable_reconnect: failed to open "
index a1d5f4b0c91b9c8d091d35835c3744c10f906f23..286f1b8e6f7a6162083ce7de9403b93a41fffc69 100644 (file)
@@ -1116,7 +1116,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                /*
                 * We're not creating the file, just pass through.
                 */
-               status = fd_open(fsp, flags, mode);
+               status = fd_openat(fsp, flags, mode);
                *file_created = false;
                return status;
        }
@@ -1125,7 +1125,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                /*
                 * Fail if already exists, just pass through.
                 */
-               status = fd_open(fsp, flags, mode);
+               status = fd_openat(fsp, flags, mode);
 
                /*
                 * Here we've opened with O_CREAT|O_EXCL. If that went
@@ -1165,7 +1165,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                retry_status = NT_STATUS_OBJECT_NAME_COLLISION;
        }
 
-       status = fd_open(fsp, curr_flags, mode);
+       status = fd_openat(fsp, curr_flags, mode);
        if (NT_STATUS_IS_OK(status)) {
                *file_created = !file_existed;
                return NT_STATUS_OK;
@@ -1184,7 +1184,7 @@ static NTSTATUS fd_open_atomic(files_struct *fsp,
                        curr_flags = flags | O_EXCL;
                }
 
-               status = fd_open(fsp, curr_flags, mode);
+               status = fd_openat(fsp, curr_flags, mode);
        }
 
        *file_created = (NT_STATUS_IS_OK(status) && !file_existed);
@@ -4584,7 +4584,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        flags |= O_DIRECTORY;
 #endif
 
-       status = fd_open(fsp, flags, 0);
+       status = fd_openat(fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("Could not open fd for "
                        "%s (%s)\n",