r14487: split smbsrv_request into two parts, one will be moved to ntvfs_request
authorStefan Metzmacher <metze@samba.org>
Thu, 16 Mar 2006 18:54:19 +0000 (18:54 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:32 +0000 (13:57 -0500)
but I don't to get the commit to large, to I'll do this tomorrow...

metze
(This used to be commit 10e627032d7d04f1ebf6efed248c426614f5aa6f)

16 files changed:
source4/ntvfs/cifs/vfs_cifs.c
source4/ntvfs/ipc/vfs_ipc.c
source4/ntvfs/ntvfs.h
source4/ntvfs/ntvfs_generic.c
source4/ntvfs/ntvfs_interface.c
source4/ntvfs/posix/pvfs_acl.c
source4/ntvfs/posix/pvfs_fsinfo.c
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/pvfs_wait.c
source4/ntvfs/posix/vfs_posix.h
source4/ntvfs/unixuid/vfs_unixuid.c
source4/smb_server/smb/receive.c
source4/smb_server/smb/reply.c
source4/smb_server/smb/request.c
source4/smb_server/smb/service.c
source4/smb_server/smb_server.h

index 806585f8e9d4f9061f877fa13200003f69d1a319..ee831de665832d9272f2160b16d435e1295d2f2a 100644 (file)
@@ -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;
                }
        }
index 24ee1451d69dbd06729f3427af7a5a9cc8df0b23..7b9433bcffdc6ef7c08238a742dd4e45faaa5154 100644 (file)
@@ -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;
        }
index 2f43f5df208109d397d89ba9df4eb7897f166593..58b95565e984651ffca818df8d6dfe2e7fe71298 100644 (file)
@@ -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;
 };
 
 
index 51b03606fbc05700ff998f4c4902d38e760fdc5a..f74092eda0a12198fe7919285f66a28765d3c229 100644 (file)
@@ -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;
index 0888991877271cc9c3aba5f4cad892aaf30e7f0e..f17acc9355ed0e33eaa05e7ab1e7ebd57dc9178f 100644 (file)
@@ -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);
+}
index 84ad62fcc83355b49cf4fb474591e600e2412a65..f7647ae3e4dba9f845fd15ee0dc14bc1f40564e3 100644 (file)
@@ -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;
index 72293fb746fdde9d471b1b415d67501e6672a160..f86be9d29e24e1e4aabe74886396abace9b277d8 100644 (file)
@@ -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;
index 4f0615087abc7b0735a801437826e1bedb0f0f02..3160519f738660a9a76db561bbc9ad4b325a55d9 100644 (file)
@@ -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);
                }
index 9b2f4786333c01649787ca78b10ceb68607621ca..6cb24e1f92e684bc9a907b7819ac0ad22280f839 100644 (file)
@@ -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;
index 71120965c2fcf5f2588d7c89f440dea21f0c621f..f75e7d35637a001e9103b3af1e9e0900f8b81a0c 100644 (file)
@@ -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 */
index cc7e13fde05fb583701a2d282eab281b1dec19e5..9f6a4f9cb78264a7e60d2fa18c2ede7209296d22 100644 (file)
@@ -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);
        }
 
index 2abfda7e36d2fee01c9e890292f8934477be54ff..44e385dc7333891e5d315a8881bb39b872ae0908 100644 (file)
@@ -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);
 }
 
index cc625b6d03bd564e209a412964f5f180279591ad..7171618f8cb844cba4e3087524fdaaeb958a4df6 100644 (file)
@@ -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;
index cc72b412e70f6937bc5ece3a9b1292ead1ec6dee..1a3ff23b930e5ceb24babdff46e07d01cf114626 100644 (file)
@@ -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;
 
index dcd91f1917f6a8649606689462e659fc9727ee2f..76607a0e0f150413e942824775fa908396187021 100644 (file)
@@ -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)) {
index 2b06eb9d5b4f865580e12ced716f79029541d77c..ab110890d0be38009b56cf693351c73d498a7abf 100644 (file)
@@ -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