diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/ntvfs/cifs/vfs_cifs.c | 37 | ||||
-rw-r--r-- | source4/ntvfs/ipc/vfs_ipc.c | 9 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs.h | 27 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_base.c | 26 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_interface.c | 81 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_dirlist.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_fsinfo.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_search.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_wait.c | 4 | ||||
-rw-r--r-- | source4/ntvfs/posix/vfs_posix.c | 27 | ||||
-rw-r--r-- | source4/ntvfs/posix/vfs_posix.h | 2 | ||||
-rw-r--r-- | source4/ntvfs/print/vfs_print.c | 14 | ||||
-rw-r--r-- | source4/ntvfs/simple/vfs_simple.c | 28 | ||||
-rw-r--r-- | source4/smb_server/management.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb/receive.c | 11 | ||||
-rw-r--r-- | source4/smb_server/smb/service.c | 43 | ||||
-rw-r--r-- | source4/smb_server/smb2/tcon.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 11 | ||||
-rw-r--r-- | source4/smb_server/tcon.c | 28 |
19 files changed, 214 insertions, 144 deletions
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 9f3af57016..806585f8e9 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -38,7 +38,7 @@ struct cvfs_private { struct smbcli_tree *tree; struct smbcli_transport *transport; - struct smbsrv_tcon *tcon; + struct ntvfs_module_context *ntvfs; struct async_info *pending; BOOL map_generic; }; @@ -62,9 +62,12 @@ struct async_info { static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) { struct cvfs_private *private = p_private; - + NTSTATUS status; + DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum)); - return req_send_oplock_break(private->tcon, fnum, level); + status = ntvfs_send_oplock_break(private->ntvfs, fnum, level); + if (!NT_STATUS_IS_OK(status)) return False; + return True; } /* @@ -73,12 +76,12 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; NTSTATUS status; struct cvfs_private *private; const char *host, *user, *pass, *domain, *remote_share; struct smb_composite_connect io; struct composite_context *creq; + int snum = ntvfs->ctx->config.snum; struct cli_credentials *credentials; BOOL machine_account; @@ -87,16 +90,16 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, * For now we use parametric options, type cifs. * Later we will use security=server and auth_server.c. */ - host = lp_parm_string(req->tcon->service, "cifs", "server"); - user = lp_parm_string(req->tcon->service, "cifs", "user"); - pass = lp_parm_string(req->tcon->service, "cifs", "password"); - domain = lp_parm_string(req->tcon->service, "cifs", "domain"); - remote_share = lp_parm_string(req->tcon->service, "cifs", "share"); + host = lp_parm_string(snum, "cifs", "server"); + user = lp_parm_string(snum, "cifs", "user"); + pass = lp_parm_string(snum, "cifs", "password"); + domain = lp_parm_string(snum, "cifs", "domain"); + remote_share = lp_parm_string(snum, "cifs", "share"); if (!remote_share) { remote_share = sharename; } - machine_account = lp_parm_bool(req->tcon->service, "cifs", "use_machine_account", False); + machine_account = lp_parm_bool(snum, "cifs", "use_machine_account", False); private = talloc_zero(ntvfs, struct cvfs_private); if (!private) { @@ -151,7 +154,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.service = remote_share; io.in.service_type = "?????"; - creq = smb_composite_connect_send(&io, private, tcon->smb_conn->connection->event.ctx); + creq = smb_composite_connect_send(&io, private, ntvfs->ctx->event_ctx); status = smb_composite_connect_recv(creq, private); NT_STATUS_NOT_OK_RETURN(status); @@ -159,15 +162,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, private->transport = private->tree->session->transport; SETUP_PID; - private->tcon = req->tcon; + private->ntvfs = ntvfs; + + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - tcon->dev_type = talloc_strdup(tcon, "A:"); - /* we need to receive oplock break requests from the server */ smbcli_oplock_handler(private->transport, oplock_handler, private); - private->map_generic = lp_parm_bool(req->tcon->service, + private->map_generic = lp_parm_bool(ntvfs->ctx->config.snum, "cifs", "mapgeneric", False); return NT_STATUS_OK; diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index ad5c9594d5..7a572268d4 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -79,14 +79,13 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; - tcon->fs_type = talloc_strdup(tcon, "IPC"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->dev_type = talloc_strdup(tcon, "IPC"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* prepare the private state for this connection */ private = talloc(ntvfs, struct ipc_private); diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 0e15ee1542..2f43f5df20 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -158,17 +158,40 @@ struct ntvfs_ops { struct ntvfs_module_context { struct ntvfs_module_context *prev, *next; - void *private_data; - const struct ntvfs_ops *ops; + struct ntvfs_context *ctx; int depth; + const struct ntvfs_ops *ops; + void *private_data; }; struct ntvfs_context { enum ntvfs_type type; + + /* the reported filesystem type */ + char *fs_type; + + /* the reported device type */ + char *dev_type; + + enum protocol_types protocol; + /* * linked list of module contexts */ struct ntvfs_module_context *modules; + + struct { + int snum; + } config; + + uint32_t server_id; + struct event_context *event_ctx; + struct messaging_context *msg_ctx; + + struct { + void *private_data; + NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level); + } oplock; }; diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c index 7351d6b2a6..5abf449b8c 100644 --- a/source4/ntvfs/ntvfs_base.c +++ b/source4/ntvfs/ntvfs_base.c @@ -118,9 +118,12 @@ _PUBLIC_ const struct ntvfs_critical_sizes *ntvfs_interface_version(void) /* initialise a connection structure to point at a NTVFS backend */ -NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) +NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, int snum, enum ntvfs_type type, + enum protocol_types protocol, + struct event_context *ev, struct messaging_context *msg, + uint32_t server_id, struct ntvfs_context **_ctx) { - const char **handlers = lp_ntvfs_handler(req->tcon->service); + const char **handlers = lp_ntvfs_handler(snum); int i; struct ntvfs_context *ctx; @@ -128,19 +131,21 @@ NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) return NT_STATUS_INTERNAL_ERROR; } - ctx = talloc(req->tcon, struct ntvfs_context); + ctx = talloc_zero(mem_ctx, struct ntvfs_context); NT_STATUS_HAVE_NO_MEMORY(ctx); - ctx->type = type; - ctx->modules = NULL; + ctx->protocol = protocol; + ctx->type = type; + ctx->config.snum = snum; + ctx->event_ctx = ev; + ctx->msg_ctx = msg; + ctx->server_id = server_id; for (i=0; handlers[i]; i++) { struct ntvfs_module_context *ntvfs; - ntvfs = talloc(ctx, struct ntvfs_module_context); + ntvfs = talloc_zero(ctx, struct ntvfs_module_context); NT_STATUS_HAVE_NO_MEMORY(ntvfs); - - ntvfs->private_data = NULL; - + ntvfs->ctx = ctx; ntvfs->ops = ntvfs_backend_byname(handlers[i], ctx->type); if (!ntvfs->ops) { DEBUG(1,("ntvfs_init_connection: failed to find backend=%s, type=%d\n", @@ -155,8 +160,7 @@ NTSTATUS ntvfs_init_connection(struct ntvfs_request *req, enum ntvfs_type type) return NT_STATUS_INTERNAL_ERROR; } - req->tcon->ntvfs_ctx = ctx; - + *_ctx = ctx; return NT_STATUS_OK; } diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c index 68166e5132..0888991877 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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->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_ctx->modules; + struct ntvfs_module_context *ntvfs = req->tcon->ntvfs->modules; if (!ntvfs->ops->cancel) { return NT_STATUS_NOT_IMPLEMENTED; } @@ -666,3 +666,22 @@ _PUBLIC_ NTSTATUS ntvfs_next_exit(struct ntvfs_module_context *ntvfs, } return ntvfs->next->ops->exit(ntvfs->next, req); } + +_PUBLIC_ NTSTATUS ntvfs_set_oplock_handler(struct ntvfs_context *ntvfs, + NTSTATUS (*handler)(void *private_data, uint16_t fnum, uint8_t level), + void *private_data) +{ + ntvfs->oplock.handler = handler; + ntvfs->oplock.private_data = private_data; + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ntvfs_send_oplock_break(struct ntvfs_module_context *ntvfs, + uint16_t fnum, uint8_t level) +{ + if (!ntvfs->ctx->oplock.handler) { + return NT_STATUS_OK; + } + + return ntvfs->ctx->oplock.handler(ntvfs->ctx->oplock.private_data, fnum, level); +} diff --git a/source4/ntvfs/posix/pvfs_dirlist.c b/source4/ntvfs/posix/pvfs_dirlist.c index 9838072080..a61fc458b3 100644 --- a/source4/ntvfs/posix/pvfs_dirlist.c +++ b/source4/ntvfs/posix/pvfs_dirlist.c @@ -177,7 +177,7 @@ static void dcache_add(struct pvfs_dir *dir, const char *name) const char *pvfs_list_next(struct pvfs_dir *dir, uint_t *ofs) { struct dirent *de; - enum protocol_types protocol = dir->pvfs->tcon->smb_conn->negotiate.protocol; + enum protocol_types protocol = dir->pvfs->ntvfs->ctx->protocol; /* non-wildcard searches are easy */ if (dir->no_wildcard) { diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c index 6b8f0504f2..553681a3d4 100644 --- a/source4/ntvfs/posix/pvfs_fsinfo.c +++ b/source4/ntvfs/posix/pvfs_fsinfo.c @@ -169,7 +169,7 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs, case RAW_QFS_ATTRIBUTE_INFORMATION: fs->attribute_info.out.fs_attr = pvfs->fs_attribs; fs->attribute_info.out.max_file_component_length = 255; - fs->attribute_info.out.fs_type.s = req->tcon->fs_type; + fs->attribute_info.out.fs_type.s = ntvfs->ctx->fs_type; return NT_STATUS_OK; case RAW_QFS_QUOTA_INFORMATION: diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index 6aa9163f1e..c74bac5a3d 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -72,7 +72,7 @@ static void pvfs_search_timer(struct event_context *ev, struct timed_event *te, */ static void pvfs_search_setup_timer(struct pvfs_search_state *search) { - struct event_context *ev = search->pvfs->tcon->smb_conn->connection->event.ctx; + struct event_context *ev = search->pvfs->ntvfs->ctx->event_ctx; talloc_free(search->te); search->te = event_add_timed(ev, search, timeval_current_ofs(search->pvfs->search_inactivity_time, 0), diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 241382ba0b..9b2f478633 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -134,8 +134,8 @@ void *pvfs_wait_message(struct pvfs_state *pvfs, pwait->private = private; pwait->handler = fn; - pwait->msg_ctx = pvfs->tcon->smb_conn->connection->msg_ctx; - pwait->ev = req->tcon->smb_conn->connection->event.ctx; + pwait->msg_ctx = pvfs->ntvfs->ctx->msg_ctx; + pwait->ev = pvfs->ntvfs->ctx->event_ctx; pwait->msg_type = msg_type; pwait->req = talloc_reference(pwait, req); pwait->pvfs = pvfs; diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index ba53dc65e0..31588fdf78 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -38,7 +38,7 @@ */ static void pvfs_setup_options(struct pvfs_state *pvfs) { - int snum = pvfs->tcon->service; + int snum = pvfs->ntvfs->ctx->config.snum; const char *eadb; if (lp_map_hidden(snum)) pvfs->flags |= PVFS_FLAG_MAP_HIDDEN; @@ -114,23 +114,22 @@ static void pvfs_setup_options(struct pvfs_state *pvfs) static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; struct pvfs_state *pvfs; struct stat st; char *base_directory; NTSTATUS status; - pvfs = talloc_zero(tcon, struct pvfs_state); + pvfs = talloc_zero(ntvfs, struct pvfs_state); NT_STATUS_HAVE_NO_MEMORY(pvfs); /* for simplicity of path construction, remove any trailing slash now */ - base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service)); + base_directory = talloc_strdup(pvfs, lp_pathname(ntvfs->ctx->config.snum)); NT_STATUS_HAVE_NO_MEMORY(base_directory); if (strcmp(base_directory, "/") != 0) { trim_string(base_directory, NULL, "/"); } - pvfs->tcon = tcon; + pvfs->ntvfs = ntvfs; pvfs->base_directory = base_directory; /* the directory must exist. Note that we deliberately don't @@ -141,25 +140,25 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, return NT_STATUS_BAD_NETWORK_NAME; } - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->dev_type = talloc_strdup(tcon, "A:"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); ntvfs->private_data = pvfs; pvfs->brl_context = brl_init(pvfs, - pvfs->tcon->smb_conn->connection->server_id, - pvfs->tcon->service, - pvfs->tcon->smb_conn->connection->msg_ctx); + pvfs->ntvfs->ctx->server_id, + pvfs->ntvfs->ctx->config.snum, + pvfs->ntvfs->ctx->msg_ctx); if (pvfs->brl_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } pvfs->odb_context = odb_init(pvfs, - pvfs->tcon->smb_conn->connection->server_id, - pvfs->tcon->smb_conn->connection->msg_ctx); + pvfs->ntvfs->ctx->server_id, + pvfs->ntvfs->ctx->msg_ctx); if (pvfs->odb_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index a22b55198c..84828fb3ce 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -31,7 +31,7 @@ /* this is the private structure for the posix vfs backend. It is used to hold per-connection (per tree connect) state information */ struct pvfs_state { - struct smbsrv_tcon *tcon; + struct ntvfs_module_context *ntvfs; const char *base_directory; struct GUID *base_fs_uuid; diff --git a/source4/ntvfs/print/vfs_print.c b/source4/ntvfs/print/vfs_print.c index eb17ef9c63..bd1615d603 100644 --- a/source4/ntvfs/print/vfs_print.c +++ b/source4/ntvfs/print/vfs_print.c @@ -35,13 +35,11 @@ static NTSTATUS print_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct smbsrv_tcon *tcon = req->tcon; + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); - - tcon->dev_type = talloc_strdup(tcon, "LPT1:"); - NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "LPT1:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); return NT_STATUS_OK; } @@ -78,6 +76,8 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs, } if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) { + int snum = ntvfs->ctx->config.snum; + /* a request for the print job id of an open print job */ io->ioctl.out.blob = data_blob_talloc(req, NULL, 32); @@ -86,7 +86,7 @@ static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs, p = (char *)io->ioctl.out.blob.data; SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */); push_string(p+2, lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII); - push_string(p+18, lp_servicename(req->tcon->service), 13, STR_TERMINATE|STR_ASCII); + push_string(p+18, lp_servicename(snum), 13, STR_TERMINATE|STR_ASCII); return NT_STATUS_OK; } diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index fe43776dcc..2f5a8af8f5 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -40,7 +40,7 @@ #define O_DIRECTORY 0 #endif -#define CHECK_READ_ONLY(req) do { if (lp_readonly(req->tcon->service)) return NT_STATUS_ACCESS_DENIED; } while (0) +#define CHECK_READ_ONLY(req) do { if (lp_readonly(ntvfs->ctx->config.snum)) return NT_STATUS_ACCESS_DENIED; } while (0) /* connect to a share - used when a tree_connect operation comes @@ -52,13 +52,13 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct smbsrv_tcon *tcon = req->tcon; struct svfs_private *private; + int snum = ntvfs->ctx->config.snum; private = talloc(ntvfs, struct svfs_private); private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, lp_pathname(tcon->service)); + private->connectpath = talloc_strdup(private, lp_pathname(snum)); private->open_files = NULL; private->search = NULL; @@ -69,8 +69,10 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, return NT_STATUS_BAD_NETWORK_NAME; } - tcon->fs_type = talloc_strdup(tcon, "NTFS"); - tcon->dev_type = talloc_strdup(tcon, "A:"); + ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); + ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); + NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); ntvfs->private_data = private; @@ -306,12 +308,14 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, int fd, flags; struct svfs_file *f; int create_flags, rdwr_flags; + BOOL readonly; if (io->generic.level != RAW_OPEN_GENERIC) { return ntvfs_map_open(ntvfs, req, io); } - if (lp_readonly(req->tcon->service)) { + readonly = lp_readonly(ntvfs->ctx->config.snum); + if (readonly) { create_flags = 0; rdwr_flags = O_RDONLY; } else { @@ -345,7 +349,7 @@ static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, if (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) { flags = O_RDONLY | O_DIRECTORY; - if (lp_readonly(req->tcon->service)) { + if (readonly) { goto do_open; } switch (io->generic.in.open_disposition) { @@ -376,9 +380,11 @@ do_open: return map_nt_error_from_unix(errno); } - f = talloc(req->tcon, struct svfs_file); + f = talloc(ntvfs, struct svfs_file); + NT_STATUS_HAVE_NO_MEMORY(f); f->fd = fd; - f->name = talloc_strdup(req->tcon, unix_path); + f->name = talloc_strdup(f, unix_path); + NT_STATUS_HAVE_NO_MEMORY(f->name); DLIST_ADD(private->open_files, f); @@ -719,8 +725,8 @@ static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.quota_soft = 0; fs->generic.out.quota_hard = 0; fs->generic.out.quota_flags = 0; - fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service)); - fs->generic.out.fs_type = req->tcon->fs_type; + fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(ntvfs->ctx->config.snum)); + fs->generic.out.fs_type = ntvfs->ctx->fs_type; return NT_STATUS_OK; } diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c index bb153d3c5e..b55a9f7d57 100644 --- a/source4/smb_server/management.c +++ b/source4/smb_server/management.c @@ -100,7 +100,7 @@ static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg, } info->tid = tcon->tid; - info->share_name = lp_servicename(tcon->service); + info->share_name = tcon->share_name; info->connect_time = timeval_to_nttime(&tcon->statistics.connect_time); i++; } diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 8430871c19..4eed107d97 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -30,17 +30,16 @@ /* send an oplock break request to a client */ -BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t level) +NTSTATUS smbsrv_send_oplock_break(void *p, uint16_t fnum, uint8_t level) { + struct smbsrv_tcon *tcon = talloc_get_type(p, struct smbsrv_tcon); struct smbsrv_request *req; req = smbsrv_init_request(tcon->smb_conn); - if (!req) { - return False; - } + NT_STATUS_HAVE_NO_MEMORY(req); smbsrv_setup_reply(req, 8, 0); - + SCVAL(req->out.hdr,HDR_COM,SMBlockingX); SSVAL(req->out.hdr,HDR_TID,tcon->tid); SSVAL(req->out.hdr,HDR_PID,0xFFFF); @@ -59,7 +58,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve SSVAL(req->out.vwv, VWV(7), 0); smbsrv_send_reply(req); - return True; + return NT_STATUS_OK; } static void switch_message(int type, struct smbsrv_request *req); diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 49c2384e98..c805d081df 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -67,35 +67,45 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, return NT_STATUS_ACCESS_DENIED; } - tcon = smbsrv_smb_tcon_new(req->smb_conn); + tcon = smbsrv_smb_tcon_new(req->smb_conn, lp_servicename(snum)); if (!tcon) { DEBUG(0,("Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; } req->tcon = tcon; - tcon->service = snum; - /* init ntvfs function pointers */ - status = ntvfs_init_connection(req, type); + status = ntvfs_init_connection(tcon, snum, type, + req->smb_conn->negotiate.protocol, + req->smb_conn->connection->event.ctx, + req->smb_conn->connection->msg_ctx, + req->smb_conn->connection->server_id, + &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("ntvfs_init_connection failed for service %s\n", - lp_servicename(tcon->service))); - req->tcon = NULL; - talloc_free(tcon); - return status; + lp_servicename(snum))); + goto failed; + } + + status = ntvfs_set_oplock_handler(tcon->ntvfs, smbsrv_send_oplock_break, tcon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n")); + goto failed; } /* Invoke NTVFS connection hook */ status = ntvfs_connect(req, lp_servicename(snum)); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("make_connection: NTVFS make connection failed!\n")); - req->tcon = NULL; - talloc_free(tcon); - return status; + goto failed; } return NT_STATUS_OK; + +failed: + req->tcon = NULL; + talloc_free(tcon); + return status; } /**************************************************************************** @@ -155,6 +165,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) { NTSTATUS status; + int snum; /* can only do bare tcon in share level security */ if (!req->session && lp_security() != SEC_SHARE) { @@ -183,11 +194,13 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) return status; } + snum = req->tcon->ntvfs->config.snum; + con->tconx.out.tid = req->tcon->tid; - con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type); - con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type); - con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2); - if (lp_msdfs_root(req->tcon->service) && lp_host_msdfs()) { + con->tconx.out.dev_type = talloc_strdup(req, req->tcon->ntvfs->dev_type); + con->tconx.out.fs_type = talloc_strdup(req, req->tcon->ntvfs->fs_type); + con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(snum) << 2); + if (lp_msdfs_root(snum) && lp_host_msdfs()) { con->tconx.out.options |= SMB_SHARE_IN_DFS; } diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 9fb2a03ce3..836c13a019 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -28,7 +28,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tr { struct smbsrv_tcon *tcon; - tcon = smbsrv_smb2_tcon_new(req->session); + tcon = smbsrv_smb2_tcon_new(req->session, "fake"); NT_STATUS_HAVE_NO_MEMORY(tcon); /* TODO: do real tree connect */ diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index ab24381026..2b06eb9d5b 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -103,16 +103,11 @@ struct smbsrv_tcon { */ uint32_t tid; /* an index passed over the wire (the TID) */ - int service; + /* the share name */ + const char *share_name; /* the NTVFS context - see source/ntvfs/ for details */ - struct ntvfs_context *ntvfs_ctx; - - /* the reported filesystem type */ - char *fs_type; - - /* the reported device type */ - char *dev_type; + struct ntvfs_context *ntvfs; /* some stuff to support share level security */ struct { diff --git a/source4/smb_server/tcon.c b/source4/smb_server/tcon.c index 90fe20a4c8..95e42d6537 100644 --- a/source4/smb_server/tcon.c +++ b/source4/smb_server/tcon.c @@ -93,16 +93,16 @@ static int smbsrv_tcon_destructor(void *ptr) { struct smbsrv_tcon *tcon = talloc_get_type(ptr, struct smbsrv_tcon); struct smbsrv_tcons_context *tcons_ctx; - struct socket_address *client_addr; + client_addr = socket_get_peer_addr(tcon->smb_conn->connection->socket, ptr); DEBUG(3,("%s closed connection to service %s\n", client_addr ? client_addr->addr : "(unknown)", - lp_servicename(tcon->service))); + tcon->share_name)); /* tell the ntvfs backend that we are disconnecting */ - if (tcon->ntvfs_ctx) { - ntvfs_disconnect(tcon->ntvfs_ctx); + if (tcon->ntvfs) { + ntvfs_disconnect(tcon->ntvfs); } if (tcon->smb2.session) { @@ -119,7 +119,9 @@ static int smbsrv_tcon_destructor(void *ptr) /* find first available connection slot */ -static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, struct smbsrv_session *smb_sess) +static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, + struct smbsrv_session *smb_sess, + const char *share_name) { TALLOC_CTX *mem_ctx; struct smbsrv_tcons_context *tcons_ctx; @@ -138,11 +140,13 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s if (!tcon) return NULL; tcon->smb_conn = smb_conn; tcon->smb2.session = smb_sess; + tcon->share_name = talloc_strdup(tcon, share_name); + if (!tcon->share_name) goto failed; i = idr_get_new_random(tcons_ctx->idtree_tid, tcon, tcons_ctx->idtree_limit); if (i == -1) { DEBUG(1,("ERROR! Out of connection structures\n")); - return NULL; + goto failed; } tcon->tid = i; @@ -153,14 +157,18 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s tcon->statistics.connect_time = timeval_current(); return tcon; + +failed: + talloc_free(tcon); + return NULL; } -struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn) +struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn, const char *share_name) { - return smbsrv_tcon_new(smb_conn, NULL); + return smbsrv_tcon_new(smb_conn, NULL, share_name); } -struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess) +struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess, const char *share_name) { - return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess); + return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess, share_name); } |