From e3880fa759cfa03222262327854fe7bbe585fe01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:30:20 +0000 Subject: r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count() rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8) --- source4/ntvfs/posix/pvfs_open.c | 53 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/posix/pvfs_open.c') diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index a1c6dcdcfe..f3bec4085e 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -27,11 +27,16 @@ /* find open file handle given fnum */ -struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs, uint16_t fnum) +struct pvfs_file *pvfs_find_fd(struct smbsrv_request *req, uint16_t fnum) { + NTVFS_GET_PRIVATE(pvfs_state, pvfs, req); struct pvfs_file *f; for (f=pvfs->open_files;f;f=f->next) { if (f->fnum == fnum) { + if (req->session != f->session) { + DEBUG(2,("pvfs_find_fd: attempt to use wrong session for fnum %d\n", fnum)); + return NULL; + } return f; } } @@ -146,6 +151,8 @@ do_open: f->fnum = fd; f->fd = fd; f->name = talloc_steal(f, name); + f->session = req->session; + f->smbpid = req->smbpid; /* setup a destructor to avoid file descriptor leaks on abnormal termination */ @@ -183,7 +190,7 @@ NTSTATUS pvfs_close(struct smbsrv_request *req, union smb_close *io) return NT_STATUS_INVALID_LEVEL; } - f = pvfs_find_fd(pvfs, io->close.in.fnum); + f = pvfs_find_fd(req, io->close.in.fnum); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -202,3 +209,45 @@ NTSTATUS pvfs_close(struct smbsrv_request *req, union smb_close *io) return status; } + +/* + logoff - close all file descriptors open by a vuid +*/ +NTSTATUS pvfs_logoff(struct smbsrv_request *req) +{ + NTVFS_GET_PRIVATE(pvfs_state, pvfs, req); + struct pvfs_file *f, *next; + + for (f=pvfs->open_files;f;f=next) { + next = f->next; + if (f->session == req->session) { + talloc_set_destructor(f, NULL); + DLIST_REMOVE(pvfs->open_files, f); + talloc_free(f); + } + } + + return NT_STATUS_OK; +} + + +/* + exit - close files for the current pid +*/ +NTSTATUS pvfs_exit(struct smbsrv_request *req) +{ + NTVFS_GET_PRIVATE(pvfs_state, pvfs, req); + struct pvfs_file *f, *next; + + for (f=pvfs->open_files;f;f=next) { + next = f->next; + if (f->smbpid == req->smbpid) { + talloc_set_destructor(f, NULL); + DLIST_REMOVE(pvfs->open_files, f); + talloc_free(f); + } + } + + return NT_STATUS_OK; +} + -- cgit