]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use fsp_get_pathref_fd() when close()ing fds
authorRalph Boehme <slow@samba.org>
Sat, 3 Oct 2020 19:24:29 +0000 (21:24 +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/locking/posix.c
source3/modules/vfs_aio_fork.c
source3/modules/vfs_fruit.c
source3/modules/vfs_streams_xattr.c
source3/smbd/open.c

index a233f74d5934843377289d00b31a6ef6183d0d51..536d8bf802bb47c1ee54d9bc73c7324b468362db 100644 (file)
@@ -521,10 +521,11 @@ static void add_fd_to_close_entry_fn(
        void *private_data)
 {
        struct add_fd_to_close_entry_state *state = private_data;
+       int fd = fsp_get_pathref_fd(state->fsp);
        TDB_DATA values[] = {
                value,
-               { .dptr = (uint8_t *)&(state->fsp->fh->fd),
-                 .dsize = sizeof(state->fsp->fh->fd) },
+               { .dptr = (uint8_t *)&fd,
+                 .dsize = sizeof(fd) },
        };
        NTSTATUS status;
 
@@ -593,7 +594,7 @@ int fd_close_posix(const struct files_struct *fsp)
                 * open file description lock semantics which only removes
                 * locks on the file descriptor we're closing. Just close.
                 */
-               return close(fsp->fh->fd);
+               return close(fsp_get_pathref_fd(fsp));
        }
 
        if (get_lock_ref_count(fsp)) {
@@ -626,7 +627,7 @@ int fd_close_posix(const struct files_struct *fsp)
         * Finally close the fd associated with this fsp.
         */
 
-       return close(fsp->fh->fd);
+       return close(fsp_get_pathref_fd(fsp));
 }
 
 /****************************************************************************
index f58d37ece1395c5816d6165d31919c038c7439f3..772906fb7716e98646e76de6b878a7a32fd1bf30 100644 (file)
@@ -419,8 +419,8 @@ static int aio_child_destructor(struct aio_child *child)
 static struct files_struct *close_fsp_fd(struct files_struct *fsp,
                                         void *private_data)
 {
-       if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) {
-               close(fsp->fh->fd);
+       if ((fsp->fh != NULL) && (fsp_get_pathref_fd(fsp) != -1)) {
+               close(fsp_get_pathref_fd(fsp));
                fsp_set_fd(fsp, -1);
        }
        return NULL;
index 4da4c8b0ec6c71cec7d964f1750f88f4383196a0..902ce0e9b15abf3733b661c316ec797e60de54ae 100644 (file)
@@ -1669,7 +1669,7 @@ static int fruit_close_meta(vfs_handle_struct *handle,
                break;
 
        case FRUIT_META_NETATALK:
-               ret = close(fsp->fh->fd);
+               ret = close(fsp_get_pathref_fd(fsp));
                fsp_set_fd(fsp, -1);
                break;
 
@@ -1698,7 +1698,7 @@ static int fruit_close_rsrc(vfs_handle_struct *handle,
                break;
 
        case FRUIT_RSRC_XATTR:
-               ret = close(fsp->fh->fd);
+               ret = close(fsp_get_pathref_fd(fsp));
                fsp_set_fd(fsp, -1);
                break;
 
@@ -1716,7 +1716,7 @@ static int fruit_close(vfs_handle_struct *handle,
        int ret;
        int fd;
 
-       fd = fsp->fh->fd;
+       fd = fsp_get_pathref_fd(fsp);
 
        DBG_DEBUG("Path [%s] fd [%d]\n", smb_fname_str_dbg(fsp->fsp_name), fd);
 
index f564efcb6e703a7bd23f094adc4233222cd6c71d..70e26f5f92964997b7d732fd8cf2d64e6c4d4088 100644 (file)
@@ -505,7 +505,7 @@ static int streams_xattr_close(vfs_handle_struct *handle,
        int ret;
        int fd;
 
-       fd = fsp->fh->fd;
+       fd = fsp_get_pathref_fd(fsp);
 
        DBG_DEBUG("streams_xattr_close called [%s] fd [%d]\n",
                        smb_fname_str_dbg(fsp->fsp_name), fd);
index e79877cc9c9dd7cd90b944cc0cfc33ac6d35347e..11f3112ad851c6b4fa0a55b90fd168d52a647bfc 100644 (file)
@@ -847,7 +847,7 @@ NTSTATUS fd_close(files_struct *fsp)
        if (fsp->dptr) {
                dptr_CloseDir(fsp);
        }
-       if (fsp->fh->fd == -1) {
+       if (fsp_get_pathref_fd(fsp) == -1) {
                /*
                 * Either a directory where the dptr_CloseDir() already closed
                 * the fd or a stat open.