]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: pass a dirfsp to fd_open() and rename it to fd_openat()
authorRalph Boehme <slow@samba.org>
Tue, 13 Oct 2020 12:38:28 +0000 (14:38 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
For now no change in behaviour as all callers still pass conn->cwd_fsp. This
just prepared fd_openat() to deal with real dirfsp's pass by callers later on
when adding calls to fd_openat(dirfspm ...) in the directory enumeration loop.

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

index 12a7a6ae84ae9fcc39acc547518058d3706af4bf..d905c7dd552761f5b64243b33295f0e7a7457bdd 100644 (file)
@@ -813,7 +813,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
                flags = O_RDONLY;
        }
 
-       status = fd_open(fsp, flags, 0);
+       status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(lck);
                DEBUG(1, ("vfs_default_durable_reconnect: failed to open "
index cbe09155ab365d77fffdbc6097bd681d344de00e..b53c5e924339306d0b37af994b51796a68a4f6b1 100644 (file)
@@ -233,7 +233,7 @@ NTSTATUS open_internal_dirfsp(connection_struct *conn,
 #ifdef O_DIRECTORY
        open_flags |= O_DIRECTORY;
 #endif
-       status = fd_open(fsp, open_flags, 0);
+       status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, open_flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("Could not open fd for %s (%s)\n",
                         smb_fname_str_dbg(smb_dname),
index 7f0163ffb7bb84d2245589dc023a57fefade24de..bf96584bac93f38de9a044c6fb503ee9a40546ba 100644 (file)
@@ -825,12 +825,13 @@ static int non_widelink_open(files_struct *fsp,
  fd support routines - attempt to do a dos_open.
 ****************************************************************************/
 
-NTSTATUS fd_open(files_struct *fsp,
-                int flags,
-                mode_t mode)
+NTSTATUS fd_openat(const struct files_struct *dirfsp,
+                  struct smb_filename *smb_fname,
+                  files_struct *fsp,
+                  int flags,
+                  mode_t mode)
 {
        struct connection_struct *conn = fsp->conn;
-       struct smb_filename *smb_fname = fsp->fsp_name;
        NTSTATUS status = NT_STATUS_OK;
        int fd;
 
@@ -1095,7 +1096,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->conn->cwd_fsp, fsp->fsp_name, fsp, flags, mode);
                *file_created = false;
                return status;
        }
@@ -1104,7 +1105,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->conn->cwd_fsp, fsp->fsp_name, fsp, flags, mode);
 
                /*
                 * Here we've opened with O_CREAT|O_EXCL. If that went
@@ -1144,7 +1145,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->conn->cwd_fsp, fsp->fsp_name, fsp, curr_flags, mode);
        if (NT_STATUS_IS_OK(status)) {
                *file_created = !file_existed;
                return NT_STATUS_OK;
@@ -1163,7 +1164,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->conn->cwd_fsp, fsp->fsp_name, fsp, curr_flags, mode);
        }
 
        *file_created = (NT_STATUS_IS_OK(status) && !file_existed);
@@ -4496,7 +4497,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        flags |= O_DIRECTORY;
 #endif
 
-       status = fd_open(fsp, flags, 0);
+       status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_INFO("Could not open fd for "
                        "%s (%s)\n",
index b768e81afe9c6b660e9c32852825ff7343b8a6f9..4d7f0488ab4e053763bedfa2d682c51d2f4b6ae9 100644 (file)
@@ -713,8 +713,10 @@ NTSTATUS check_parent_access(struct connection_struct *conn,
                                struct files_struct *dirfsp,
                                struct smb_filename *smb_fname,
                                uint32_t access_mask);
-NTSTATUS fd_open(files_struct *fsp,
-                int flags, mode_t mode);
+NTSTATUS fd_openat(const struct files_struct *dirfsp,
+                  struct smb_filename *smb_fname,
+                  files_struct *fsp,
+                  int flags, mode_t mode);
 NTSTATUS fd_close(files_struct *fsp);
 void change_file_owner_to_parent(connection_struct *conn,
                                 struct smb_filename *inherit_from_dir,
index ba10f925a46ff88ca25449739b3ff4d3981de70f..1eb2b395d4c83d77c0bee89871e82d8d777b448d 100644 (file)
@@ -387,7 +387,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
 #ifdef O_DIRECTORY
                flags |= O_DIRECTORY;
 #endif
-               status = fd_open(fsp, flags, 0);
+               status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
                if (tevent_req_nterror(req, status)) {
                        return tevent_req_post(req, ev);
                }