]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use fsp_get_pathref_fd() for logical fd comparisons
authorRalph Boehme <slow@samba.org>
Mon, 5 Oct 2020 05:51:50 +0000 (07:51 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/files.c
source3/smbd/reply.c
source3/smbd/smb1_utils.c
source3/torture/cmd_vfs.c

index 02d3b0605523c8b9ce1979eea94eb5991de5c67a..7a5afa2f082d8e5a2187e4161acc708f80510084 100644 (file)
@@ -386,7 +386,7 @@ files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd)
        files_struct *fsp;
 
        for (fsp=sconn->files; fsp; fsp=fsp->next,count++) {
-               if (fsp->fh->fd == fd) {
+               if (fsp_get_pathref_fd(fsp) == fd) {
                        if (count > 10) {
                                DLIST_PROMOTE(sconn->files, fsp);
                        }
@@ -419,7 +419,7 @@ files_struct *file_find_dif(struct smbd_server_connection *sconn,
                                DLIST_PROMOTE(sconn->files, fsp);
                        }
                        /* Paranoia check. */
-                       if ((fsp->fh->fd == -1) &&
+                       if ((fsp_get_pathref_fd(fsp) == -1) &&
                            (fsp->oplock_type != NO_OPLOCK &&
                             fsp->oplock_type != LEASE_OPLOCK)) {
                                struct file_id_buf idbuf;
index 0c6778bda766377a05be376578673c50e303d0d6..a7bbccbd5b2b5a0ff315dbd5bacc6bbe4e375efc 100644 (file)
@@ -420,7 +420,7 @@ bool check_fsp(connection_struct *conn, struct smb_request *req,
                reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
                return False;
        }
-       if (fsp->fh->fd == -1) {
+       if (fsp_get_pathref_fd(fsp) == -1) {
                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
                return False;
        }
index 25a178007dce039ea615e36876924529bf9c34dc..d4655ff638f26b5ca1f74fe802df571cc6fa2208 100644 (file)
@@ -64,7 +64,7 @@ struct files_struct *fcb_or_dos_open(
                          fsp->fh->private_options,
                          fsp->access_mask);
 
-               if (fsp->fh->fd != -1 &&
+               if (fsp_get_pathref_fd(fsp) != -1 &&
                    fsp->vuid == req->vuid &&
                    fsp->file_pid == req->smbpid &&
                    (fsp->fh->private_options &
index cae2042ae723dd522ff271a3bb46004a53da05c1..cf2c4984a22490a81108b7af9ebb59aa6a9c9408 100644 (file)
@@ -446,8 +446,8 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->fsp_flags.is_directory = false;
 
-       vfs->files[fsp->fh->fd] = fsp;
-       printf("open: fd=%d\n", fsp->fh->fd);
+       vfs->files[fsp_get_pathref_fd(fsp)] = fsp;
+       printf("open: fd=%d\n", fsp_get_pathref_fd(fsp));
        return NT_STATUS_OK;
 }