summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-26 11:30:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:18 -0500
commite3880fa759cfa03222262327854fe7bbe585fe01 (patch)
tree7000172fad1b5cdcc0d071698ee3e203e61a8f4f /source4/ntvfs/posix
parentad053090b817105a0974f4b8bf0b90e002297903 (diff)
downloadsamba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.gz
samba-e3880fa759cfa03222262327854fe7bbe585fe01.tar.bz2
samba-e3880fa759cfa03222262327854fe7bbe585fe01.zip
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)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c53
-rw-r--r--source4/ntvfs/posix/pvfs_qfileinfo.c2
-rw-r--r--source4/ntvfs/posix/pvfs_read.c3
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c2
-rw-r--r--source4/ntvfs/posix/pvfs_write.c4
-rw-r--r--source4/ntvfs/posix/vfs_posix.c10
-rw-r--r--source4/ntvfs/posix/vfs_posix.h8
7 files changed, 66 insertions, 16 deletions
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;
+}
+
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
index 649036b09a..81706bcfe8 100644
--- a/source4/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -114,7 +114,7 @@ NTSTATUS pvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
return ntvfs_map_qfileinfo(req, info, pvfs->ops);
}
- f = pvfs_find_fd(pvfs, info->generic.in.fnum);
+ f = pvfs_find_fd(req, info->generic.in.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c
index cbb0317638..72ac00a32d 100644
--- a/source4/ntvfs/posix/pvfs_read.c
+++ b/source4/ntvfs/posix/pvfs_read.c
@@ -36,7 +36,8 @@ NTSTATUS pvfs_read(struct smbsrv_request *req, union smb_read *rd)
return NT_STATUS_NOT_SUPPORTED;
}
- f = pvfs_find_fd(pvfs, rd->readx.in.fnum);
+
+ f = pvfs_find_fd(req, rd->readx.in.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index c2c58415be..2ea2fdaf8e 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -33,7 +33,7 @@ NTSTATUS pvfs_setfileinfo(struct smbsrv_request *req,
struct utimbuf unix_times;
struct pvfs_file *f;
- f = pvfs_find_fd(pvfs, info->generic.file.fnum);
+ f = pvfs_find_fd(req, info->generic.file.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c
index ac9d23b88f..02ba1b8228 100644
--- a/source4/ntvfs/posix/pvfs_write.c
+++ b/source4/ntvfs/posix/pvfs_write.c
@@ -35,7 +35,7 @@ NTSTATUS pvfs_write(struct smbsrv_request *req, union smb_write *wr)
switch (wr->generic.level) {
case RAW_WRITE_WRITEX:
- f = pvfs_find_fd(pvfs, wr->writex.in.fnum);
+ f = pvfs_find_fd(req, wr->writex.in.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
@@ -53,7 +53,7 @@ NTSTATUS pvfs_write(struct smbsrv_request *req, union smb_write *wr)
return NT_STATUS_OK;
case RAW_WRITE_WRITE:
- f = pvfs_find_fd(pvfs, wr->write.in.fnum);
+ f = pvfs_find_fd(req, wr->write.in.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 8705317b2a..7ae7c6759a 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -161,15 +161,6 @@ static NTSTATUS pvfs_flush(struct smbsrv_request *req, struct smb_flush *io)
}
/*
- exit - closing files?
-*/
-static NTSTATUS pvfs_exit(struct smbsrv_request *req)
-{
- DEBUG(0,("pvfs_exit not implemented\n"));
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
lock a byte range
*/
static NTSTATUS pvfs_lock(struct smbsrv_request *req, union smb_lock *lck)
@@ -241,6 +232,7 @@ NTSTATUS ntvfs_posix_init(void)
ops.search_next = pvfs_search_next;
ops.search_close = pvfs_search_close;
ops.trans = pvfs_trans;
+ ops.logoff = pvfs_logoff;
/* register ourselves with the NTVFS subsystem. We register
under the name 'default' as we wish to be the default
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index bfb1fbf7ca..96ab7f85b2 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -107,6 +107,14 @@ struct pvfs_file {
int fd;
uint16_t fnum;
struct pvfs_filename *name;
+
+ /* we need to remember the session it was opened on,
+ as it is illegal to operate on someone elses fnum */
+ struct smbsrv_session *session;
+
+ /* we need to remember the client pid that
+ opened the file so SMBexit works */
+ uint16_t smbpid;
};