diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-03-16 18:54:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:57:32 -0500 |
commit | d3087451c4ec25171ba956fe2cd4e1d0f64f7edc (patch) | |
tree | 9fc7f4b924a84789db962720ba989d881a4a277f /source4 | |
parent | a949db7c6d4bd35df59ba066111e6566172d4814 (diff) | |
download | samba-d3087451c4ec25171ba956fe2cd4e1d0f64f7edc.tar.gz samba-d3087451c4ec25171ba956fe2cd4e1d0f64f7edc.tar.bz2 samba-d3087451c4ec25171ba956fe2cd4e1d0f64f7edc.zip |
r14487: split smbsrv_request into two parts, one will be moved to ntvfs_request
but I don't to get the commit to large, to I'll do this tomorrow...
metze
(This used to be commit 10e627032d7d04f1ebf6efed248c426614f5aa6f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/ntvfs/cifs/vfs_cifs.c | 10 | ||||
-rw-r--r-- | source4/ntvfs/ipc/vfs_ipc.c | 58 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs.h | 6 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_generic.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_interface.c | 93 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_acl.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_fsinfo.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_open.c | 16 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_wait.c | 3 | ||||
-rw-r--r-- | source4/ntvfs/posix/vfs_posix.h | 2 | ||||
-rw-r--r-- | source4/ntvfs/unixuid/vfs_unixuid.c | 8 | ||||
-rw-r--r-- | source4/smb_server/smb/receive.c | 10 | ||||
-rw-r--r-- | source4/smb_server/smb/reply.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb/request.c | 4 | ||||
-rw-r--r-- | source4/smb_server/smb/service.c | 23 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 32 |
16 files changed, 182 insertions, 91 deletions
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 806585f8e9..ee831de665 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -53,7 +53,7 @@ struct async_info { void *parms; }; -#define SETUP_PID private->tree->session->pid = SVAL(req->in.hdr, HDR_PID) +#define SETUP_PID private->tree->session->pid = req->smbpid /* a handler for oplock break events from the server - these need to be passed @@ -136,9 +136,9 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, if (!NT_STATUS_IS_OK(status)) { return status; } - } else if (req->session->session_info->credentials) { + } else if (req->session_info->credentials) { DEBUG(5, ("CIFS backend: Using delegated credentials\n")); - credentials = req->session->session_info->credentials; + credentials = req->session_info->credentials; } else { DEBUG(1,("CIFS backend: You must supply server, user and password and or have delegated credentials\n")); return NT_STATUS_INVALID_PARAMETER; @@ -698,11 +698,11 @@ static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { struct cvfs_private *private = ntvfs->private_data; + struct async_info *a; /* find the matching request */ - struct async_info *a; for (a=private->pending;a;a=a->next) { - if (SVAL(a->req->in.hdr, HDR_MID) == SVAL(req->in.hdr, HDR_MID)) { + if (a->req->smbmid == req->smbmid) { break; } } diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 24ee1451d6..7b9433bcff 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -32,7 +32,6 @@ #include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" -#include "smbd/service_stream.h" #define IPC_BASE_FNUM 0x400 @@ -40,9 +39,9 @@ ipc$ connection. It needs to keep information about all open pipes */ struct ipc_private { - struct idr_context *idtree_fnum; + struct ntvfs_module_context *ntvfs; - struct stream_connection *stream_conn; + struct idr_context *idtree_fnum; struct dcesrv_context *dcesrv; @@ -56,22 +55,34 @@ struct ipc_private { uint16_t ipc_state; /* we need to remember the session it was opened on, as it is illegal to operate on someone elses fnum */ - struct smbsrv_session *session; + struct auth_session_info *session_info; /* we need to remember the client pid that opened the file so SMBexit works */ uint16_t smbpid; } *pipe_list; - }; /* find a open pipe give a file descriptor */ -static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t fnum) +static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t fnum, + struct auth_session_info *session_info) { - return idr_find(private->idtree_fnum, fnum); + struct pipe_state *s; + void *p; + + p = idr_find(private->idtree_fnum, fnum); + if (!p) return NULL; + + s = talloc_get_type(p, struct pipe_state); + + if (s->session_info != session_info) { + return NULL; + } + + return s; } @@ -96,10 +107,9 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, ntvfs->private_data = private; + private->ntvfs = ntvfs; private->pipe_list = NULL; - private->stream_conn = req->smb_conn->connection; - private->idtree_fnum = idr_init(private); NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); @@ -182,14 +192,14 @@ static struct socket_address *ipc_get_my_addr(struct dcesrv_connection *dce_conn { struct ipc_private *private = dce_conn->transport.private_data; - return socket_get_my_addr(private->stream_conn->socket, mem_ctx); + return ntvfs_get_my_addr(private->ntvfs, mem_ctx); } static struct socket_address *ipc_get_peer_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) { struct ipc_private *private = dce_conn->transport.private_data; - return socket_get_peer_addr(private->stream_conn->socket, mem_ctx); + return ntvfs_get_peer_addr(private->ntvfs, mem_ctx); } /* @@ -204,11 +214,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct dcerpc_binding *ep_description; struct ipc_private *private = ntvfs->private_data; int fnum; - struct stream_connection *srv_conn = req->smb_conn->connection; - - if (!req->session || !req->session->session_info) { - return NT_STATUS_ACCESS_DENIED; - } p = talloc(req, struct pipe_state); NT_STATUS_HAVE_NO_MEMORY(p); @@ -244,8 +249,8 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, status = dcesrv_endpoint_search_connect(private->dcesrv, p, ep_description, - req->session->session_info, - srv_conn->event.ctx, + req->session_info, + ntvfs->ctx->event_ctx, 0, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { @@ -261,7 +266,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, DLIST_ADD(private->pipe_list, p); p->smbpid = req->smbpid; - p->session = req->session; + p->session_info = req->session_info; p->private = private; *ps = p; @@ -407,7 +412,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, fnum = rd->readx.in.file.fnum; - p = pipe_state_find(private, fnum); + p = pipe_state_find(private, fnum, req->session_info); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -452,7 +457,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; - p = pipe_state_find(private, fnum); + p = pipe_state_find(private, fnum, req->session_info); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -501,7 +506,7 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, return ntvfs_map_close(ntvfs, req, io); } - p = pipe_state_find(private, io->close.in.file.fnum); + p = pipe_state_find(private, io->close.in.file.fnum, req->session_info); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -522,7 +527,8 @@ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, for (p=private->pipe_list; p; p=next) { next = p->next; - if (p->smbpid == req->smbpid) { + if (p->session_info == req->session_info && + p->smbpid == req->smbpid) { talloc_free(p); } } @@ -541,7 +547,7 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, for (p=private->pipe_list; p; p=next) { next = p->next; - if (p->session == req->session) { + if (p->session_info == req->session_info) { talloc_free(p); } } @@ -671,7 +677,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, NTSTATUS status; /* the fnum is in setup[1] */ - p = pipe_state_find(private, trans->in.setup[1]); + p = pipe_state_find(private, trans->in.setup[1], req->session_info); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -716,7 +722,7 @@ static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, struct pipe_state *p; /* the fnum is in setup[1] */ - p = pipe_state_find(private, trans->in.setup[1]); + p = pipe_state_find(private, trans->in.setup[1], req->session_info); if (!p) { return NT_STATUS_INVALID_HANDLE; } diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 2f43f5df20..58b95565e9 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -192,6 +192,12 @@ struct ntvfs_context { void *private_data; NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level); } oplock; + + struct { + void *private_data; + struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx); + struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx); + } client; }; diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 51b03606fb..f74092eda0 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -534,7 +534,7 @@ _PUBLIC_ NTSTATUS ntvfs_map_fsinfo(struct ntvfs_module_context *ntvfs, (fs2->generic.out.blocks_free * (double)fs2->generic.out.block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ - if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) { + if (bpunit > 64 && req->ctx->protocol <= PROTOCOL_LANMAN2) { fs->dskattr.out.blocks_per_unit = 64; fs->dskattr.out.units_total = 0xFFFF; fs->dskattr.out.units_free = 0xFFFF; diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c index 0888991877..f17acc9355 100644 --- a/source4/ntvfs/ntvfs_interface.c +++ b/source4/ntvfs/ntvfs_interface.c @@ -26,7 +26,7 @@ /* connect/disconnect */ _PUBLIC_ NTSTATUS ntvfs_connect(struct ntvfs_request *req, const char *sharename) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->connect) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -50,7 +50,7 @@ _PUBLIC_ NTSTATUS ntvfs_disconnect(struct ntvfs_context *ntvfs_ctx) a async request */ _PUBLIC_ NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -60,7 +60,7 @@ _PUBLIC_ NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) /* filesystem operations */ _PUBLIC_ NTSTATUS ntvfs_fsinfo(struct ntvfs_request *req, union smb_fsinfo *fs) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->fsinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -70,7 +70,7 @@ _PUBLIC_ NTSTATUS ntvfs_fsinfo(struct ntvfs_request *req, union smb_fsinfo *fs) /* path operations */ _PUBLIC_ NTSTATUS ntvfs_unlink(struct ntvfs_request *req, union smb_unlink *unl) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->unlink) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -79,7 +79,7 @@ _PUBLIC_ NTSTATUS ntvfs_unlink(struct ntvfs_request *req, union smb_unlink *unl) _PUBLIC_ NTSTATUS ntvfs_chkpath(struct ntvfs_request *req, union smb_chkpath *cp) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->chkpath) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -88,7 +88,7 @@ _PUBLIC_ NTSTATUS ntvfs_chkpath(struct ntvfs_request *req, union smb_chkpath *cp _PUBLIC_ NTSTATUS ntvfs_qpathinfo(struct ntvfs_request *req, union smb_fileinfo *st) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->qpathinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -97,7 +97,7 @@ _PUBLIC_ NTSTATUS ntvfs_qpathinfo(struct ntvfs_request *req, union smb_fileinfo _PUBLIC_ NTSTATUS ntvfs_setpathinfo(struct ntvfs_request *req, union smb_setfileinfo *st) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->setpathinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -106,7 +106,7 @@ _PUBLIC_ NTSTATUS ntvfs_setpathinfo(struct ntvfs_request *req, union smb_setfile _PUBLIC_ NTSTATUS ntvfs_open(struct ntvfs_request *req, union smb_open *oi) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->open) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -115,7 +115,7 @@ _PUBLIC_ NTSTATUS ntvfs_open(struct ntvfs_request *req, union smb_open *oi) _PUBLIC_ NTSTATUS ntvfs_mkdir(struct ntvfs_request *req, union smb_mkdir *md) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->mkdir) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -124,7 +124,7 @@ _PUBLIC_ NTSTATUS ntvfs_mkdir(struct ntvfs_request *req, union smb_mkdir *md) _PUBLIC_ NTSTATUS ntvfs_rmdir(struct ntvfs_request *req, struct smb_rmdir *rd) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->rmdir) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -133,7 +133,7 @@ _PUBLIC_ NTSTATUS ntvfs_rmdir(struct ntvfs_request *req, struct smb_rmdir *rd) _PUBLIC_ NTSTATUS ntvfs_rename(struct ntvfs_request *req, union smb_rename *ren) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->rename) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -142,7 +142,7 @@ _PUBLIC_ NTSTATUS ntvfs_rename(struct ntvfs_request *req, union smb_rename *ren) _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->copy) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -153,7 +153,7 @@ _PUBLIC_ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private, BOOL ntvfs_callback(void *private, union smb_search_data *file)) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -163,7 +163,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search _PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private, BOOL ntvfs_callback(void *private, union smb_search_data *file)) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -172,7 +172,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_ _PUBLIC_ NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search_close *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_close) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -182,7 +182,7 @@ _PUBLIC_ NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search /* operations on open files */ _PUBLIC_ NTSTATUS ntvfs_ioctl(struct ntvfs_request *req, union smb_ioctl *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->ioctl) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -191,7 +191,7 @@ _PUBLIC_ NTSTATUS ntvfs_ioctl(struct ntvfs_request *req, union smb_ioctl *io) _PUBLIC_ NTSTATUS ntvfs_read(struct ntvfs_request *req, union smb_read *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->read) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -200,7 +200,7 @@ _PUBLIC_ NTSTATUS ntvfs_read(struct ntvfs_request *req, union smb_read *io) _PUBLIC_ NTSTATUS ntvfs_write(struct ntvfs_request *req, union smb_write *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->write) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -209,7 +209,7 @@ _PUBLIC_ NTSTATUS ntvfs_write(struct ntvfs_request *req, union smb_write *io) _PUBLIC_ NTSTATUS ntvfs_seek(struct ntvfs_request *req, union smb_seek *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->seek) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -219,7 +219,7 @@ _PUBLIC_ NTSTATUS ntvfs_seek(struct ntvfs_request *req, union smb_seek *io) _PUBLIC_ NTSTATUS ntvfs_flush(struct ntvfs_request *req, union smb_flush *flush) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->flush) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -228,7 +228,7 @@ _PUBLIC_ NTSTATUS ntvfs_flush(struct ntvfs_request *req, _PUBLIC_ NTSTATUS ntvfs_lock(struct ntvfs_request *req, union smb_lock *lck) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->lock) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -237,7 +237,7 @@ _PUBLIC_ NTSTATUS ntvfs_lock(struct ntvfs_request *req, union smb_lock *lck) _PUBLIC_ NTSTATUS ntvfs_qfileinfo(struct ntvfs_request *req, union smb_fileinfo *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->qfileinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -246,7 +246,7 @@ _PUBLIC_ NTSTATUS ntvfs_qfileinfo(struct ntvfs_request *req, union smb_fileinfo _PUBLIC_ NTSTATUS ntvfs_setfileinfo(struct ntvfs_request *req, union smb_setfileinfo *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->setfileinfo) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -255,7 +255,7 @@ _PUBLIC_ NTSTATUS ntvfs_setfileinfo(struct ntvfs_request *req, union smb_setfile _PUBLIC_ NTSTATUS ntvfs_close(struct ntvfs_request *req, union smb_close *io) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->close) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -265,7 +265,7 @@ _PUBLIC_ NTSTATUS ntvfs_close(struct ntvfs_request *req, union smb_close *io) /* trans interface - used by IPC backend for pipes and RAP calls */ _PUBLIC_ NTSTATUS ntvfs_trans(struct ntvfs_request *req, struct smb_trans2 *trans) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->trans) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -275,7 +275,7 @@ _PUBLIC_ NTSTATUS ntvfs_trans(struct ntvfs_request *req, struct smb_trans2 *tran /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */ _PUBLIC_ NTSTATUS ntvfs_trans2(struct ntvfs_request *req, struct smb_trans2 *trans2) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->trans2) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -285,7 +285,7 @@ _PUBLIC_ NTSTATUS ntvfs_trans2(struct ntvfs_request *req, struct smb_trans2 *tra /* printing specific operations */ _PUBLIC_ NTSTATUS ntvfs_lpq(struct ntvfs_request *req, union smb_lpq *lpq) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->lpq) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -295,7 +295,7 @@ _PUBLIC_ NTSTATUS ntvfs_lpq(struct ntvfs_request *req, union smb_lpq *lpq) /* logoff - called when a vuid is closed */ _PUBLIC_ NTSTATUS ntvfs_logoff(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->logoff) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -304,7 +304,7 @@ _PUBLIC_ NTSTATUS ntvfs_logoff(struct ntvfs_request *req) _PUBLIC_ NTSTATUS ntvfs_exit(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->exit) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -316,7 +316,7 @@ _PUBLIC_ NTSTATUS ntvfs_exit(struct ntvfs_request *req) */ _PUBLIC_ NTSTATUS ntvfs_notify(struct ntvfs_request *req, union smb_notify *info) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->notify) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -328,7 +328,7 @@ _PUBLIC_ NTSTATUS ntvfs_notify(struct ntvfs_request *req, union smb_notify *info */ _PUBLIC_ NTSTATUS ntvfs_cancel(struct ntvfs_request *req) { - struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; + struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->cancel) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -667,6 +667,7 @@ _PUBLIC_ NTSTATUS ntvfs_next_exit(struct ntvfs_module_context *ntvfs, return ntvfs->next->ops->exit(ntvfs->next, req); } +/* oplock helpers */ _PUBLIC_ NTSTATUS ntvfs_set_oplock_handler(struct ntvfs_context *ntvfs, NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level), void *private_data) @@ -685,3 +686,33 @@ _PUBLIC_ NTSTATUS ntvfs_send_oplock_break(struct ntvfs_module_context *ntvfs, return ntvfs->ctx->oplock.handler(ntvfs->ctx->oplock.private_data, fnum, level); } + +/* client connection callback */ +_PUBLIC_ NTSTATUS ntvfs_set_addr_callbacks(struct ntvfs_context *ntvfs, + struct socket_address *(*my_addr)(void *private_data, TALLOC_CTX *mem_ctx), + struct socket_address *(*peer_addr)(void *private_data, TALLOC_CTX *mem_ctx), + void *private_data) +{ + ntvfs->client.get_peer_addr = my_addr; + ntvfs->client.get_my_addr = peer_addr; + ntvfs->client.private_data = private_data; + return NT_STATUS_OK; +} + +_PUBLIC_ struct socket_address *ntvfs_get_my_addr(struct ntvfs_module_context *ntvfs, TALLOC_CTX *mem_ctx) +{ + if (!ntvfs->ctx->client.get_my_addr) { + return NULL; + } + + return ntvfs->ctx->client.get_my_addr(ntvfs->ctx->client.private_data, mem_ctx); +} + +_PUBLIC_ struct socket_address *ntvfs_get_peer_addr(struct ntvfs_module_context *ntvfs, TALLOC_CTX *mem_ctx) +{ + if (!ntvfs->ctx->client.get_peer_addr) { + return NULL; + } + + return ntvfs->ctx->client.get_peer_addr(ntvfs->ctx->client.private_data, mem_ctx); +} diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c index 84ad62fcc8..f7647ae3e4 100644 --- a/source4/ntvfs/posix/pvfs_acl.c +++ b/source4/ntvfs/posix/pvfs_acl.c @@ -362,7 +362,7 @@ NTSTATUS pvfs_access_check(struct pvfs_state *pvfs, struct pvfs_filename *name, uint32_t *access_mask) { - struct security_token *token = req->session->session_info->security_token; + struct security_token *token = req->session_info->security_token; struct xattr_NTACL *acl; NTSTATUS status; struct security_descriptor *sd; diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c index 72293fb746..f86be9d29e 100644 --- a/source4/ntvfs/posix/pvfs_fsinfo.c +++ b/source4/ntvfs/posix/pvfs_fsinfo.c @@ -124,7 +124,7 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs, fs->dskattr.out.units_free = (blocks_free * (double)block_size) / (bpunit * 512); /* we must return a maximum of 2G to old DOS systems, or they get very confused */ - if (bpunit > 64 && req->smb_conn->negotiate.protocol <= PROTOCOL_LANMAN2) { + if (bpunit > 64 && req->ctx->protocol <= PROTOCOL_LANMAN2) { fs->dskattr.out.blocks_per_unit = 64; fs->dskattr.out.units_total = 0xFFFF; fs->dskattr.out.units_free = 0xFFFF; diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index 4f0615087a..3160519f73 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -52,7 +52,7 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs, smb_panic("pvfs_find_fd: idtree_fnum corruption\n"); } - if (req->session != f->session) { + if (req->session_info != f->session_info) { DEBUG(2,("pvfs_find_fd: attempt to use wrong session for fnum %d\n", fnum)); return NULL; @@ -263,7 +263,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs, } f->fnum = fnum; - f->session = req->session; + f->session_info = req->session_info; f->smbpid = req->smbpid; f->pvfs = pvfs; f->pending_list = NULL; @@ -680,7 +680,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs, } f->fnum = fnum; - f->session = req->session; + f->session_info = req->session_info; f->smbpid = req->smbpid; f->pvfs = pvfs; f->pending_list = NULL; @@ -847,7 +847,7 @@ static NTSTATUS pvfs_open_deny_dos(struct ntvfs_module_context *ntvfs, */ for (f2=pvfs->open_files;f2;f2=f2->next) { if (f2 != f && - f2->session == req->session && + f2->session_info == req->session_info && f2->smbpid == req->smbpid && (f2->handle->create_options & (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS | @@ -936,7 +936,7 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs, f->handle->odb_locking_key.data, f->handle->odb_locking_key.length); - end_time = timeval_add(&req->request_time, 0, pvfs->sharing_violation_delay); + end_time = timeval_add(&req->statistics.request_time, 0, pvfs->sharing_violation_delay); /* setup a pending lock */ status = odb_open_file_pending(lck, r); @@ -1105,7 +1105,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, } f->fnum = fnum; - f->session = req->session; + f->session_info = req->session_info; f->smbpid = req->smbpid; f->pvfs = pvfs; f->pending_list = NULL; @@ -1310,7 +1310,7 @@ NTSTATUS pvfs_logoff(struct ntvfs_module_context *ntvfs, for (f=pvfs->open_files;f;f=next) { next = f->next; - if (f->session == req->session) { + if (f->session_info == req->session_info) { talloc_free(f); } } @@ -1330,7 +1330,7 @@ NTSTATUS pvfs_exit(struct ntvfs_module_context *ntvfs, for (f=pvfs->open_files;f;f=next) { next = f->next; - if (f->session == req->session && + if (f->session_info == req->session_info && f->smbpid == req->smbpid) { talloc_free(f); } diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 9b2f478633..6cb24e1f92 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -171,8 +171,9 @@ NTSTATUS pvfs_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *r { struct pvfs_state *pvfs = ntvfs->private_data; struct pvfs_wait *pwait; + for (pwait=pvfs->wait_list;pwait;pwait=pwait->next) { - if (SVAL(req->in.hdr, HDR_MID) == SVAL(pwait->req->in.hdr, HDR_MID) && + if (req->smbmid == pwait->req->smbmid && req->smbpid == pwait->req->smbpid) { /* trigger a cancel on the request */ pwait->reason = PVFS_WAIT_CANCEL; diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index 71120965c2..f75e7d3563 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -159,7 +159,7 @@ struct pvfs_file { /* we need to remember the session it was opened on, as it is illegal to operate on someone elses fnum */ - struct smbsrv_session *session; + struct auth_session_info *session_info; /* we need to remember the client pid that opened the file so SMBexit works */ diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c index cc7e13fde0..9f6a4f9cb7 100644 --- a/source4/ntvfs/unixuid/vfs_unixuid.c +++ b/source4/ntvfs/unixuid/vfs_unixuid.c @@ -150,18 +150,18 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, struct unix_sec_ctx *newsec; NTSTATUS status; - if (req->session == NULL) { + if (req->session_info == NULL) { return NT_STATUS_ACCESS_DENIED; } - token = req->session->session_info->security_token; + token = req->session_info->security_token; *sec = save_unix_security(req); if (*sec == NULL) { return NT_STATUS_NO_MEMORY; } - if (req->session->session_info->security_token == private->last_token) { + if (token == private->last_token) { newsec = private->last_sec_ctx; } else { status = nt_token_to_unix_security(ntvfs, req, token, &newsec); @@ -172,7 +172,7 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, talloc_free(private->last_sec_ctx); } private->last_sec_ctx = newsec; - private->last_token = req->session->session_info->security_token; + private->last_token = token; talloc_steal(private, newsec); } diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 2abfda7e36..44e385dc73 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -143,9 +143,7 @@ NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob) return NT_STATUS_OK; } - req->flags = CVAL(req->in.hdr, HDR_FLG); req->flags2 = SVAL(req->in.hdr, HDR_FLG2); - req->smbpid = SVAL(req->in.hdr, HDR_PID); if (!smbsrv_signing_check_incoming(req)) { smbsrv_send_error(req, NT_STATUS_ACCESS_DENIED); @@ -554,6 +552,14 @@ static void switch_message(int type, struct smbsrv_request *req) return; } +/* TODO: remove this stuff */ +req->smbpid = SVAL(req->in.hdr, HDR_PID); +req->smbmid = SVAL(req->in.hdr, HDR_MID); +req->statistics.request_time = req->request_time; +if (req->session) req->session_info = req->session->session_info; +if (req->tcon) req->ctx = req->tcon->ntvfs; +/* TODO: end */ + smb_messages[type].fn(req); } diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c index cc625b6d03..7171618f8c 100644 --- a/source4/smb_server/smb/reply.c +++ b/source4/smb_server/smb/reply.c @@ -1208,8 +1208,10 @@ void smbsrv_reply_exit(struct smbsrv_request *req) for (tcon=req->smb_conn->smb_tcons.list;tcon;tcon=tcon->next) { req->tcon = tcon; +req->ctx = req->tcon->ntvfs; status = ntvfs_exit(req); req->tcon = NULL; +req->ctx = NULL; if (!NT_STATUS_IS_OK(status)) { smbsrv_send_error(req, status); return; diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index cc72b412e7..1a3ff23b93 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -40,13 +40,11 @@ struct smbsrv_request *smbsrv_init_request(struct smbsrv_connection *smb_conn) { struct smbsrv_request *req; - req = talloc(smb_conn, struct smbsrv_request); + req = talloc_zero(smb_conn, struct smbsrv_request); if (!req) { return NULL; } - ZERO_STRUCTP(req); - /* setup the request context */ req->smb_conn = smb_conn; diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index dcd91f1917..76607a0e0f 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -47,6 +47,21 @@ static int find_service(const char *service) return iService; } +static struct socket_address *smbsrv_get_my_addr(void *p, TALLOC_CTX *mem_ctx) +{ + struct smbsrv_connection *smb_conn = talloc_get_type(p, + struct smbsrv_connection); + + return socket_get_my_addr(smb_conn->connection->socket, mem_ctx); +} + +static struct socket_address *smbsrv_get_peer_addr(void *p, TALLOC_CTX *mem_ctx) +{ + struct smbsrv_connection *smb_conn = talloc_get_type(p, + struct smbsrv_connection); + + return socket_get_peer_addr(smb_conn->connection->socket, mem_ctx); +} /**************************************************************************** Make a connection, given the snum to connect to, and the vuser of the @@ -93,6 +108,14 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, goto failed; } + status = ntvfs_set_addr_callbacks(tcon->ntvfs, smbsrv_get_my_addr, smbsrv_get_peer_addr, req->smb_conn); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n")); + goto failed; + } + + req->ctx = tcon->ntvfs; + /* Invoke NTVFS connection hook */ status = ntvfs_connect(req, lp_servicename(snum)); if (!NT_STATUS_IS_OK(status)) { diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 2b06eb9d5b..ab110890d0 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -134,7 +134,7 @@ struct smbsrv_tcon { functions */ struct smbsrv_request { /* the smbsrv_connection needs a list of requests queued for send */ - struct smbsrv_request_foo *next, *prev; + struct smbsrv_request *next, *prev; /* the server_context contains all context specific to this SMB socket */ struct smbsrv_connection *smb_conn; @@ -148,11 +148,8 @@ struct smbsrv_request { /* a set of flags to control usage of the request. See REQ_CONTROL_* */ unsigned control_flags; - /* the smb pid is needed for locking contexts */ - uint16_t smbpid; - /* the flags from the SMB request, in raw form (host byte order) */ - uint16_t flags, flags2; + uint16_t flags2; /* the system time when the request arrived */ struct timeval request_time; @@ -167,11 +164,32 @@ struct smbsrv_request { /* the sequence number for signing */ uint64_t seq_num; + struct request_buffer in; + struct request_buffer out; + + /* + * the following elemets will be part of a future ntvfs_request struct + */ + + /* the ntvfs_context this requests belongs to */ + struct ntvfs_context *ctx; + /* ntvfs per request async states */ struct ntvfs_async_state *async_states; - struct request_buffer in; - struct request_buffer out; + /* the session_info, with security_token and maybe delegated credentials */ + struct auth_session_info *session_info; + + /* the smb pid is needed for locking contexts */ + uint16_t smbpid; + +uint16_t smbmid; + + /* some statictics for the management tools */ + struct { + /* the system time when the request arrived */ + struct timeval request_time; + } statistics; }; /* this contains variables that should be used in % substitutions for |