s3: Call fd_close from close_directory
authorTim Prouty <tprouty@samba.org>
Thu, 27 Nov 2008 00:47:14 +0000 (16:47 -0800)
committerTim Prouty <tprouty@samba.org>
Tue, 9 Dec 2008 22:51:48 +0000 (14:51 -0800)
Some implementations of SMB_VFS_CREATE_FILE implementations actually
keep an fd open for directories just as files.  In this case it is
necessary to call fd_close when closing directories.  This is safe
because fd_close is a no-op when fd == -1, which is true for directory
opens originating from open.c (the default SMB_VFS_CREATE_FILE
implementation).

source3/smbd/close.c

index ce918ab6a32554bb090be6c9d048b738ca18ddcb..f91f1fcf8fe143391d5d042ac91bcad814400552 100644 (file)
@@ -694,6 +694,13 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                        fsp, NT_STATUS_OK);
        }
 
+       status = fd_close(fsp);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("Could not close dir! fname=%s, fd=%d, err=%d=%s\n",
+                         fsp->fsp_name, fsp->fh->fd, errno, strerror(errno)));
+       }
+
        /*
         * Do the code common to files and directories.
         */