diff options
author | Jeremy Allison <jra@samba.org> | 2011-02-08 15:05:00 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-02-08 15:06:00 -0800 |
commit | 224fc03cb56b0d76f6ad7f18dd0528d6b0e57fb1 (patch) | |
tree | c7729d94124f674ce87419a8ff6b758b00cde445 /source3 | |
parent | ad3d1adea3cdf42aee644dd853193b53a142c2f1 (diff) | |
download | samba-224fc03cb56b0d76f6ad7f18dd0528d6b0e57fb1.tar.gz samba-224fc03cb56b0d76f6ad7f18dd0528d6b0e57fb1.tar.bz2 samba-224fc03cb56b0d76f6ad7f18dd0528d6b0e57fb1.zip |
Pass fsp to dptr_CloseDir(). Cope with setting the fd if we're closing an fd that opendir knows about.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/smbd/close.c | 4 | ||||
-rw-r--r-- | source3/smbd/dir.c | 12 | ||||
-rw-r--r-- | source3/smbd/open.c | 3 | ||||
-rw-r--r-- | source3/smbd/smb2_find.c | 5 |
5 files changed, 14 insertions, 12 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 77a7a4055a..00e9de4c13 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4548,7 +4548,7 @@ void dptr_closepath(struct smbd_server_connection *sconn, char *path,uint16 spid); NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, bool expect_close,uint16 spid, const char *wcard, bool wcard_has_wild, uint32 attr, struct dptr_struct **dptr_ret); -int dptr_CloseDir(struct dptr_struct *dptr); +void dptr_CloseDir(files_struct *fsp); void dptr_SeekDir(struct dptr_struct *dptr, long offset); long dptr_TellDir(struct dptr_struct *dptr); bool dptr_has_wild(struct dptr_struct *dptr); diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 25ed9a3c4d..d5a824f868 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1061,10 +1061,6 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, strerror(errno))); } - if (fsp->dptr) { - dptr_CloseDir(fsp->dptr); - } - /* * Do the code common to files and directories. */ diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 7c9d6e262e..f81206e0ec 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -554,10 +554,16 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, Wrapper functions to access the lower level directory handles. ****************************************************************************/ -int dptr_CloseDir(struct dptr_struct *dptr) +void dptr_CloseDir(files_struct *fsp) { - dptr_close_internal(dptr); - return 0; + if (fsp->dptr) { + if (fsp->fh->fd == dirfd(fsp->dptr->dir_hnd->dir)) { + /* The call below closes the underlying fd. */ + fsp->fh->fd = -1; + } + dptr_close_internal(fsp->dptr); + fsp->dptr = NULL; + } } void dptr_SeekDir(struct dptr_struct *dptr, long offset) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ded3d344c5..a9a12eaa0b 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -168,6 +168,9 @@ NTSTATUS fd_close(files_struct *fsp) { int ret; + if (fsp->dptr) { + dptr_CloseDir(fsp); + } if (fsp->fh->fd == -1) { return NT_STATUS_OK; /* What we used to call a stat open. */ } diff --git a/source3/smbd/smb2_find.c b/source3/smbd/smb2_find.c index 9a7738ab76..b10446c3f1 100644 --- a/source3/smbd/smb2_find.c +++ b/source3/smbd/smb2_find.c @@ -317,10 +317,7 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx, } if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) { - if (fsp->dptr) { - dptr_CloseDir(fsp->dptr); - fsp->dptr = NULL; - } + dptr_CloseDir(fsp); } if (fsp->dptr == NULL) { |