From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/ntvfs/ipc/vfs_ipc.c | 295 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100644 source4/ntvfs/ipc/vfs_ipc.c (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c new file mode 100644 index 0000000000..fe310d104e --- /dev/null +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -0,0 +1,295 @@ +/* + Unix SMB/CIFS implementation. + default IPC$ NTVFS backend + Copyright (C) Andrew Tridgell 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + this implements the IPC$ backend, called by the NTVFS subsystem to + handle requests on IPC$ shares +*/ + + +#include "includes.h" + +/* + connect to a share - always works +*/ +static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) +{ + struct tcon_context *conn = req->conn; + + conn->fs_type = talloc_strdup(conn->mem_ctx, "IPC"); + conn->dev_type = talloc_strdup(conn->mem_ctx, "IPC"); + + return NT_STATUS_OK; +} + +/* + disconnect from a share +*/ +static NTSTATUS ipc_disconnect(struct tcon_context *tcon) +{ + return NT_STATUS_OK; +} + +/* + delete a file +*/ +static NTSTATUS ipc_unlink(struct request_context *req, struct smb_unlink *unl) +{ + return NT_STATUS_ACCESS_DENIED; +} + + +/* + ioctl interface - we don't do any +*/ +static NTSTATUS ipc_ioctl(struct request_context *req, struct smb_ioctl *io) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + check if a directory exists +*/ +static NTSTATUS ipc_chkpath(struct request_context *req, struct smb_chkpath *cp) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + return info on a pathname +*/ +static NTSTATUS ipc_qpathinfo(struct request_context *req, union smb_fileinfo *info) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + set info on a pathname +*/ +static NTSTATUS ipc_setpathinfo(struct request_context *req, union smb_setfileinfo *st) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + open a file +*/ +static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + create a directory +*/ +static NTSTATUS ipc_mkdir(struct request_context *req, union smb_mkdir *md) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + remove a directory +*/ +static NTSTATUS ipc_rmdir(struct request_context *req, struct smb_rmdir *rd) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + rename a set of files +*/ +static NTSTATUS ipc_rename(struct request_context *req, struct smb_rename *ren) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + copy a set of files +*/ +static NTSTATUS ipc_copy(struct request_context *req, struct smb_copy *cp) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + read from a file +*/ +static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + write to a file +*/ +static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + seek in a file +*/ +static NTSTATUS ipc_seek(struct request_context *req, struct smb_seek *io) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + flush a file +*/ +static NTSTATUS ipc_flush(struct request_context *req, struct smb_flush *io) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + close a file +*/ +static NTSTATUS ipc_close(struct request_context *req, union smb_close *io) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + exit - closing files? +*/ +static NTSTATUS ipc_exit(struct request_context *req) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + lock a byte range +*/ +static NTSTATUS ipc_lock(struct request_context *req, union smb_lock *lck) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + set info on a open file +*/ +static NTSTATUS ipc_setfileinfo(struct request_context *req, union smb_setfileinfo *info) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + query info on a open file +*/ +static NTSTATUS ipc_qfileinfo(struct request_context *req, union smb_fileinfo *info) +{ + return NT_STATUS_ACCESS_DENIED; +} + + +/* + return filesystem info +*/ +static NTSTATUS ipc_fsinfo(struct request_context *req, union smb_fsinfo *fs) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + return print queue info +*/ +static NTSTATUS ipc_lpq(struct request_context *req, union smb_lpq *lpq) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + list files in a directory matching a wildcard pattern +*/ +NTSTATUS ipc_search_first(struct request_context *req, union smb_search_first *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + continue listing files in a directory +*/ +NTSTATUS ipc_search_next(struct request_context *req, union smb_search_next *io, + void *search_private, + BOOL (*callback)(void *, union smb_search_data *)) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/* + end listing files in a directory +*/ +NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *io) +{ + return NT_STATUS_ACCESS_DENIED; +} + + +/* + initialialise the IPC backend, registering ourselves with the ntvfs subsystem + */ +BOOL ipc_vfs_init(void) +{ + BOOL ret; + struct ntvfs_ops ops; + + ZERO_STRUCT(ops); + + /* fill in all the operations */ + ops.connect = ipc_connect; + ops.disconnect = ipc_disconnect; + ops.unlink = ipc_unlink; + ops.chkpath = ipc_chkpath; + ops.qpathinfo = ipc_qpathinfo; + ops.setpathinfo = ipc_setpathinfo; + ops.open = ipc_open; + ops.mkdir = ipc_mkdir; + ops.rmdir = ipc_rmdir; + ops.rename = ipc_rename; + ops.copy = ipc_copy; + ops.ioctl = ipc_ioctl; + ops.read = ipc_read; + ops.write = ipc_write; + ops.seek = ipc_seek; + ops.flush = ipc_flush; + ops.close = ipc_close; + ops.exit = ipc_exit; + ops.lock = ipc_lock; + ops.setfileinfo = ipc_setfileinfo; + ops.qfileinfo = ipc_qfileinfo; + ops.fsinfo = ipc_fsinfo; + ops.lpq = ipc_lpq; + ops.search_first = ipc_search_first; + ops.search_next = ipc_search_next; + ops.search_close = ipc_search_close; + + /* register ourselves with the NTVFS subsystem. */ + ret = ntvfs_register("ipc", NTVFS_IPC, &ops); + + if (!ret) { + DEBUG(0,("Failed to register IPC backend!\n")); + return False; + } + + return True; +} -- cgit From 75c0125fb71b0562e7bdd85c391764796b5f12f6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 16:04:21 +0000 Subject: - added SMBntrename test suite - allow username of form DOMAIN\username or DOMAIN/username - added ntrename to gentest (This used to be commit 2b464472c17b791eb5b117f89d5aaea2bf60f6ad) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index fe310d104e..b13c358dd5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -114,7 +114,7 @@ static NTSTATUS ipc_rmdir(struct request_context *req, struct smb_rmdir *rd) /* rename a set of files */ -static NTSTATUS ipc_rename(struct request_context *req, struct smb_rename *ren) +static NTSTATUS ipc_rename(struct request_context *req, union smb_rename *ren) { return NT_STATUS_ACCESS_DENIED; } -- cgit From a846e592058726b670e40505493a4668bd856186 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Nov 2003 03:15:26 +0000 Subject: CVS: ---------------------------------------------------------------------- CVS: Enter Log. Lines beginning with `CVS:' are removed automatically CVS: CVS: Committing in . CVS: CVS: Modified Files: CVS: Makefile.in configure.in include/includes.h include/ntvfs.h CVS: include/smb.h lib/iconv.c lib/module.c ntvfs/ntvfs_base.c CVS: ntvfs/cifs/vfs_cifs.c ntvfs/ipc/vfs_ipc.c CVS: ntvfs/posix/vfs_posix.c ntvfs/print/vfs_print.c CVS: ntvfs/reference/vfs_ref.c ntvfs/simple/vfs_simple.c CVS: passdb/pdb_interface.c CVS: Added Files: CVS: include/module.h CVS: ---------------------------------------------------------------------- Update to the modules system. Fixed: - get rid of smb_probe_module - merge older updates from 3.0 - introduced register_subsystem() and register_backend() functions - adapt ntvfs and charset to use new register functions - made smb_load_modules() work recursively (e.g. 'preload modules = /usr/lib/samba') - got rid of some old remains Things that still need work: - Did I break tankFS? I don't think so, but I can't test it here :-( - Add 'postload modules = ' (for modules that need to be loaded after fork() in smbd, if applicable) - Convert RPC, auth, passdb, etc to use new register_{subsystem,backend}() functions - Accept wildcards in 'preload modules' option, instead of loading recursively (This used to be commit 7512b9ab1a8b3103f7a6c13f736353c46a26b668) --- source4/ntvfs/ipc/vfs_ipc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b13c358dd5..da5c42507a 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -248,14 +248,16 @@ NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *i /* initialialise the IPC backend, registering ourselves with the ntvfs subsystem */ -BOOL ipc_vfs_init(void) +NTSTATUS ntvfs_ipc_init(void) { - BOOL ret; + NTSTATUS ret; struct ntvfs_ops ops; ZERO_STRUCT(ops); /* fill in all the operations */ + ops.name = "ipc"; + ops.type = NTVFS_IPC; ops.connect = ipc_connect; ops.disconnect = ipc_disconnect; ops.unlink = ipc_unlink; @@ -284,12 +286,12 @@ BOOL ipc_vfs_init(void) ops.search_close = ipc_search_close; /* register ourselves with the NTVFS subsystem. */ - ret = ntvfs_register("ipc", NTVFS_IPC, &ops); + ret = register_backend("ntvfs", &ops); - if (!ret) { + if (!NT_STATUS_IS_OK(ret)) { DEBUG(0,("Failed to register IPC backend!\n")); - return False; + return ret; } - return True; + return ret; } -- cgit From 926240428c0646aabb13539745940b61a7cf44a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Dec 2003 02:03:06 +0000 Subject: * patch based on work by Jim Myers to unify the ioctl handling to be more like the other major SMB functions * added SMBntrename code (This used to be commit f2d3dc9893fa0e089c407fa16ce9ff13587e70cd) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index da5c42507a..7ada031bd5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -58,7 +58,7 @@ static NTSTATUS ipc_unlink(struct request_context *req, struct smb_unlink *unl) /* ioctl interface - we don't do any */ -static NTSTATUS ipc_ioctl(struct request_context *req, struct smb_ioctl *io) +static NTSTATUS ipc_ioctl(struct request_context *req, union smb_ioctl *io) { return NT_STATUS_ACCESS_DENIED; } -- cgit From 2bde98c0ee67b4c60c5906b3b2f297cf4922c67c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Dec 2003 22:24:33 +0000 Subject: the rest of the initial rpc server side infrastructure (This used to be commit 5fb01b0ec0321724c25669151ea7c20e6ec182d0) --- source4/ntvfs/ipc/vfs_ipc.c | 182 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7ada031bd5..7ad02bb8cb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -25,16 +25,102 @@ #include "includes.h" +/* this is the private structure used to keep the state of an open + ipc$ connection. It needs to keep information about all open + pipes */ +struct ipc_private { + + uint16 next_fnum; + uint16 num_open; + + /* a list of open pipes */ + struct pipe_state { + struct pipe_state *next, *prev; + TALLOC_CTX *mem_ctx; + const char *pipe_name; + uint16 fnum; + struct dcesrv_state *pipe_state; + } *pipe_list; + +}; + + +/* + find the next fnum available on this connection +*/ +static uint16 find_next_fnum(struct ipc_private *ipc) +{ + struct pipe_state *p; + uint32 ret; + + if (ipc->num_open == 0xFFFF) { + return 0; + } + +again: + ret = ipc->next_fnum++; + + for (p=ipc->pipe_list; p; p=p->next) { + if (p->fnum == ret) { + goto again; + } + } + + return ret; +} + + +/* + shutdown a single pipe. Called on a close or disconnect +*/ +static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) +{ + TALLOC_CTX *mem_ctx = private->pipe_list->mem_ctx; + dcesrv_endpoint_disconnect(private->pipe_list->pipe_state); + DLIST_REMOVE(private->pipe_list, private->pipe_list); + talloc_destroy(mem_ctx); +} + + +/* + find a open pipe give a file descriptor +*/ +static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16 fnum) +{ + struct pipe_state *p; + + for (p=private->pipe_list; p; p=p->next) { + if (p->fnum == fnum) { + return p; + } + } + + return NULL; +} + + /* connect to a share - always works */ static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) { struct tcon_context *conn = req->conn; + struct ipc_private *private; conn->fs_type = talloc_strdup(conn->mem_ctx, "IPC"); conn->dev_type = talloc_strdup(conn->mem_ctx, "IPC"); + /* prepare the private state for this connection */ + private = talloc(conn->mem_ctx, sizeof(struct ipc_private)); + if (!private) { + return NT_STATUS_NO_MEMORY; + } + conn->ntvfs_private = (void *)private; + + private->pipe_list = NULL; + private->next_fnum = 1; + private->num_open = 0; + return NT_STATUS_OK; } @@ -43,6 +129,13 @@ static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) */ static NTSTATUS ipc_disconnect(struct tcon_context *tcon) { + struct ipc_private *private = tcon->ntvfs_private; + + /* close any pipes that are open. Discard any unread data */ + while (private->pipe_list) { + pipe_shutdown(private, private->pipe_list); + } + return NT_STATUS_OK; } @@ -88,11 +181,79 @@ static NTSTATUS ipc_setpathinfo(struct request_context *req, union smb_setfilein } /* - open a file + open a file - used for MSRPC pipes */ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) { - return NT_STATUS_ACCESS_DENIED; + struct pipe_state *p; + TALLOC_CTX *mem_ctx; + NTSTATUS status; + struct dcesrv_endpoint endpoint; + struct ipc_private *private = req->conn->ntvfs_private; + + /* for now only handle NTcreateX style opens */ + if (oi->generic.level != RAW_OPEN_NTCREATEX) { + return NT_STATUS_ACCESS_DENIED; + } + + mem_ctx = talloc_init("ipc_open '%s'", oi->ntcreatex.in.fname); + if (!mem_ctx) { + return NT_STATUS_NO_MEMORY; + } + + p = talloc(mem_ctx, sizeof(struct pipe_state)); + if (!p) { + talloc_destroy(mem_ctx); + return NT_STATUS_NO_MEMORY; + } + p->mem_ctx = mem_ctx; + + p->pipe_name = talloc_strdup(mem_ctx, oi->ntcreatex.in.fname); + if (!p->pipe_name) { + talloc_destroy(mem_ctx); + return NT_STATUS_NO_MEMORY; + } + + p->fnum = find_next_fnum(private); + if (p->fnum == 0) { + talloc_destroy(mem_ctx); + return NT_STATUS_TOO_MANY_OPENED_FILES; + } + + if (strncasecmp(p->pipe_name, "\\pipe\\", 6) != 0) { + talloc_destroy(mem_ctx); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + p->pipe_name += 6; + + /* + we're all set, now ask the dcerpc server subsystem to open the + endpoint. At this stage the pipe isn't bound, so we don't + know what interface the user actually wants, just that they want + one of the interfaces attached to this pipe endpoint. + + TODO: note that we aren't passing any credentials here. We + will need to do that once the credentials infrastructure is + finalised for Samba4 + */ + + endpoint.type = ENDPOINT_SMB; + endpoint.info.smb_pipe = p->pipe_name; + + status = dcesrv_endpoint_connect(req->smb, &endpoint, &p->pipe_state); + if (!NT_STATUS_IS_OK(status)) { + talloc_destroy(mem_ctx); + return status; + } + + private->num_open++; + + DLIST_ADD(private->pipe_list, p); + + ZERO_STRUCT(oi->ntcreatex.out); + oi->ntcreatex.out.fnum = p->fnum; + + return NT_STATUS_OK; } /* @@ -164,7 +325,22 @@ static NTSTATUS ipc_flush(struct request_context *req, struct smb_flush *io) */ static NTSTATUS ipc_close(struct request_context *req, union smb_close *io) { - return NT_STATUS_ACCESS_DENIED; + struct ipc_private *private = req->conn->ntvfs_private; + struct pipe_state *p; + + if (io->generic.level != RAW_CLOSE_CLOSE) { + return NT_STATUS_ACCESS_DENIED; + } + + p = pipe_state_find(private, io->close.in.fnum); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + pipe_shutdown(private, p); + private->num_open--; + + return NT_STATUS_OK; } /* -- cgit From fcc4efd1ea637c810eed8444080b87d7f92c837a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 11 Dec 2003 09:07:45 +0000 Subject: the next step in the dcerpc server code. Added the link between the IPC IO routines and the dcerpc endpoint servers. (This used to be commit 4929c53bc8dddda8a763fdfbcf81a79776d01113) --- source4/ntvfs/ipc/vfs_ipc.c | 146 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 6 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7ad02bb8cb..5ab608c46b 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -220,11 +220,9 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) return NT_STATUS_TOO_MANY_OPENED_FILES; } - if (strncasecmp(p->pipe_name, "\\pipe\\", 6) != 0) { - talloc_destroy(mem_ctx); - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + while (p->pipe_name[0] == '\\') { + p->pipe_name++; } - p->pipe_name += 6; /* we're all set, now ask the dcerpc server subsystem to open the @@ -293,7 +291,51 @@ static NTSTATUS ipc_copy(struct request_context *req, struct smb_copy *cp) */ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) { - return NT_STATUS_ACCESS_DENIED; + struct ipc_private *private = req->conn->ntvfs_private; + DATA_BLOB data; + uint16 fnum; + struct pipe_state *p; + NTSTATUS status; + + switch (rd->generic.level) { + case RAW_READ_READ: + fnum = rd->read.in.fnum; + data.length = rd->read.in.count; + data.data = rd->read.out.data; + break; + case RAW_READ_READX: + fnum = rd->readx.in.fnum; + data.length = rd->readx.in.maxcnt; + data.data = rd->readx.out.data; + break; + default: + return NT_STATUS_NOT_SUPPORTED; + } + + p = pipe_state_find(private, fnum); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + status = dcesrv_output(p->pipe_state, &data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + switch (rd->generic.level) { + case RAW_READ_READ: + rd->read.out.nread = data.length; + break; + case RAW_READ_READX: + rd->readx.out.remaining = 0; + rd->readx.out.compaction_mode = 0; + rd->readx.out.nread = data.length; + break; + default: + return NT_STATUS_NOT_SUPPORTED; + } + + return NT_STATUS_OK; } /* @@ -301,7 +343,52 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) */ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) { - return NT_STATUS_ACCESS_DENIED; + struct ipc_private *private = req->conn->ntvfs_private; + DATA_BLOB data; + uint16 fnum; + struct pipe_state *p; + NTSTATUS status; + + switch (wr->generic.level) { + case RAW_WRITE_WRITE: + fnum = wr->write.in.fnum; + data.data = wr->write.in.data; + data.length = wr->write.in.count; + break; + + case RAW_WRITE_WRITEX: + fnum = wr->writex.in.fnum; + data.data = wr->writex.in.data; + data.length = wr->writex.in.count; + break; + + default: + return NT_STATUS_NOT_SUPPORTED; + } + + p = pipe_state_find(private, fnum); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + status = dcesrv_input(p->pipe_state, &data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + switch (wr->generic.level) { + case RAW_WRITE_WRITE: + wr->write.out.nwritten = data.length; + break; + case RAW_WRITE_WRITEX: + wr->writex.out.nwritten = data.length; + wr->writex.out.remaining = 0; + break; + default: + return NT_STATUS_NOT_SUPPORTED; + } + + return NT_STATUS_OK; } /* @@ -421,6 +508,52 @@ NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *i } +/* SMBtrans - used to provide access to SMB pipes */ +static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) +{ + struct pipe_state *p; + struct ipc_private *private = req->conn->ntvfs_private; + NTSTATUS status; + + if (trans->in.setup_count != 2 || + trans->in.setup[0] != TRANSACT_DCERPCCMD) { + return NT_STATUS_INVALID_PARAMETER; + } + + /* the fnum is in setup[1] */ + p = pipe_state_find(private, trans->in.setup[1]); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + /* pass the data to the dcerpc server. Note that we don't + expect this to fail, and things like NDR faults are not + reported at this stage. Those sorts of errors happen in the + dcesrv_output stage */ + status = dcesrv_input(p->pipe_state, &trans->in.data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* + now ask the dcerpc system for some output. This doesn't yet handle + async calls. Again, we only expect NT_STATUS_OK. If the call fails then + the error is encoded at the dcerpc level + */ + status = dcesrv_output(p->pipe_state, &trans->out.data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + trans->out.setup_count = 0; + trans->out.setup = NULL; + trans->out.params = data_blob(NULL, 0); + + return NT_STATUS_OK; +} + + + /* initialialise the IPC backend, registering ourselves with the ntvfs subsystem */ @@ -460,6 +593,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.search_first = ipc_search_first; ops.search_next = ipc_search_next; ops.search_close = ipc_search_close; + ops.trans = ipc_trans; /* register ourselves with the NTVFS subsystem. */ ret = register_backend("ntvfs", &ops); -- cgit From 16309de71d6c8de96e869aeaab0b879185991d87 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 12 Dec 2003 03:59:09 +0000 Subject: * the RPC-ECHO pipe now works in smbd, as long as the data sizes don't cause fragmented pdus (I'll add fragments shortly) * change data_blob_talloc() to not zero memory when the 2nd argument is NULL. The zeroing just masks bugs, and can't even allow a DOS attack * modified pidl to ensure that [ref] arguments to the out side of functions are allocated when parsing the in side. This allows rpc backends to assume that [ref] variables are all setup. Doesn't work correctly for [ref] arrays yet * changed DLIST_ADD_END() to take the type instead of a tmp variable. This means you don't need to declare a silly tmp variable in the caller (This used to be commit 46e0a358198eeb9af1907ee2a29025d3ab23b6d1) --- source4/ntvfs/ipc/vfs_ipc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 5ab608c46b..b57e72f14a 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -526,6 +526,11 @@ static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) return NT_STATUS_INVALID_HANDLE; } + trans->out.data = data_blob_talloc(req->mem_ctx, NULL, trans->in.max_data); + if (!trans->out.data.data) { + return NT_STATUS_NO_MEMORY; + } + /* pass the data to the dcerpc server. Note that we don't expect this to fail, and things like NDR faults are not reported at this stage. Those sorts of errors happen in the -- cgit From 8faa77f177833eeee245391840d06771f46e0136 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 13 Dec 2003 04:46:50 +0000 Subject: rpcdump.exe now works fine against a Samba4 server for some reason the epm_Lookup replies can't be parsed by ethereal, although w2k parses then fine as does the Samba4 NDR code. (This used to be commit 097e7ca99d947932df5674c36e628ca6b8f31d3a) --- source4/ntvfs/ipc/vfs_ipc.c | 63 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b57e72f14a..04825ec632 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -40,6 +40,7 @@ struct ipc_private { const char *pipe_name; uint16 fnum; struct dcesrv_state *pipe_state; + uint16 ipc_state; } *pipe_list; }; @@ -223,6 +224,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) while (p->pipe_name[0] == '\\') { p->pipe_name++; } + p->ipc_state = 0x5ff; /* we're all set, now ask the dcerpc server subsystem to open the @@ -250,6 +252,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) ZERO_STRUCT(oi->ntcreatex.out); oi->ntcreatex.out.fnum = p->fnum; + oi->ntcreatex.out.ipc_state = p->ipc_state; return NT_STATUS_OK; } @@ -508,17 +511,12 @@ NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *i } -/* SMBtrans - used to provide access to SMB pipes */ -static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) +/* SMBtrans - handle a DCERPC command */ +static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *trans) { struct pipe_state *p; struct ipc_private *private = req->conn->ntvfs_private; NTSTATUS status; - - if (trans->in.setup_count != 2 || - trans->in.setup[0] != TRANSACT_DCERPCCMD) { - return NT_STATUS_INVALID_PARAMETER; - } /* the fnum is in setup[1] */ p = pipe_state_find(private, trans->in.setup[1]); @@ -558,6 +556,57 @@ static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) } +/* SMBtrans - set named pipe state */ +static NTSTATUS ipc_set_nm_pipe_state(struct request_context *req, struct smb_trans2 *trans) +{ + struct pipe_state *p; + struct ipc_private *private = req->conn->ntvfs_private; + + /* the fnum is in setup[1] */ + p = pipe_state_find(private, trans->in.setup[1]); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + if (trans->in.params.length != 2) { + return NT_STATUS_INVALID_PARAMETER; + } + p->ipc_state = SVAL(trans->in.params.data, 0); + + trans->out.setup_count = 0; + trans->out.setup = NULL; + trans->out.params = data_blob(NULL, 0); + trans->out.data = data_blob(NULL, 0); + + return NT_STATUS_OK; +} + + +/* SMBtrans - used to provide access to SMB pipes */ +static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) +{ + NTSTATUS status; + + if (trans->in.setup_count != 2) { + return NT_STATUS_INVALID_PARAMETER; + } + + switch (trans->in.setup[0]) { + case TRANSACT_SETNAMEDPIPEHANDLESTATE: + status = ipc_set_nm_pipe_state(req, trans); + break; + case TRANSACT_DCERPCCMD: + status = ipc_dcerpc_cmd(req, trans); + break; + default: + status = NT_STATUS_INVALID_PARAMETER; + break; + } + + return status; +} + + /* initialialise the IPC backend, registering ourselves with the ntvfs subsystem -- cgit From d4705378ce88d1bb2f787338c531998d37d078ef Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 13 Dec 2003 10:58:48 +0000 Subject: dcerpc over tcp in the samba4 server now works to some extent. It needs quite a bit more work to get it finished. The biggest missing feature is the lack of NTLMSSP which is needed for basic authentication over tcp (This used to be commit 9fb0f0369356909c99389e2cbc525be27c08793c) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 04825ec632..a3b3ab19b7 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -240,7 +240,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) endpoint.type = ENDPOINT_SMB; endpoint.info.smb_pipe = p->pipe_name; - status = dcesrv_endpoint_connect(req->smb, &endpoint, &p->pipe_state); + status = dcesrv_endpoint_connect(&req->smb->dcesrv, &endpoint, &p->pipe_state); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(mem_ctx); return status; -- cgit From 24c22aef90d8534ee2d016b37b2b302f1367d106 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 09:02:58 +0000 Subject: a fairly large commit! This adds support for bigendian rpc in the client. I have installed SUN pcnetlink locally and am using it to test the samba4 rpc code. This allows us to easily find places where we have stuffed up the types (such as 2 uint16 versus a uint32), as testing both big-endian and little-endian easily shows which is correct. I have now used this to fix several bugs like that in the samba4 IDL. In order to make this work I also had to redefine a GUID as a true structure, not a blob. From the pcnetlink wire it is clear that it is indeed defined as a structure (the byte order changes). This required changing lots of Samba code to use a GUID as a structure. I also had to fix the if_version code in dcerpc syntax IDs, as it turns out they are a single uint32 not two uint16s. The big-endian support is a bit ugly at the moment, and breaks the layering in some places. More work is needed, especially on the server side. (This used to be commit bb1af644a5a7b188290ce36232f255da0e5d66d2) --- source4/ntvfs/ipc/vfs_ipc.c | 86 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index a3b3ab19b7..96f28895c9 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -181,10 +181,13 @@ static NTSTATUS ipc_setpathinfo(struct request_context *req, union smb_setfilein return NT_STATUS_ACCESS_DENIED; } + + /* - open a file - used for MSRPC pipes + open a file backend - used for MSRPC pipes */ -static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) +static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, + struct pipe_state **ps) { struct pipe_state *p; TALLOC_CTX *mem_ctx; @@ -192,12 +195,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) struct dcesrv_endpoint endpoint; struct ipc_private *private = req->conn->ntvfs_private; - /* for now only handle NTcreateX style opens */ - if (oi->generic.level != RAW_OPEN_NTCREATEX) { - return NT_STATUS_ACCESS_DENIED; - } - - mem_ctx = talloc_init("ipc_open '%s'", oi->ntcreatex.in.fname); + mem_ctx = talloc_init("ipc_open '%s'", fname); if (!mem_ctx) { return NT_STATUS_NO_MEMORY; } @@ -209,7 +207,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) } p->mem_ctx = mem_ctx; - p->pipe_name = talloc_strdup(mem_ctx, oi->ntcreatex.in.fname); + p->pipe_name = talloc_strdup(mem_ctx, fname); if (!p->pipe_name) { talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; @@ -250,11 +248,79 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) DLIST_ADD(private->pipe_list, p); + *ps = p; + + return NT_STATUS_OK; +} + +/* + open a file with ntcreatex - used for MSRPC pipes +*/ +static NTSTATUS ipc_open_ntcreatex(struct request_context *req, union smb_open *oi) +{ + struct pipe_state *p; + NTSTATUS status; + + status = ipc_open_generic(req, oi->ntcreatex.in.fname, &p); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + ZERO_STRUCT(oi->ntcreatex.out); oi->ntcreatex.out.fnum = p->fnum; oi->ntcreatex.out.ipc_state = p->ipc_state; - return NT_STATUS_OK; + return status; +} + +/* + open a file with openx - used for MSRPC pipes +*/ +static NTSTATUS ipc_open_openx(struct request_context *req, union smb_open *oi) +{ + struct pipe_state *p; + NTSTATUS status; + const char *fname = oi->openx.in.fname; + + if (strncasecmp(fname, "PIPE\\", 5) != 0) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + fname += 4; + + status = ipc_open_generic(req, fname, &p); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + ZERO_STRUCT(oi->openx.out); + oi->openx.out.fnum = p->fnum; + oi->openx.out.ftype = 2; + oi->openx.out.devstate = p->ipc_state; + + return status; +} + +/* + open a file - used for MSRPC pipes +*/ +static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) +{ + NTSTATUS status; + + switch (oi->generic.level) { + case RAW_OPEN_NTCREATEX: + status = ipc_open_ntcreatex(req, oi); + break; + case RAW_OPEN_OPENX: + status = ipc_open_openx(req, oi); + break; + default: + status = NT_STATUS_NOT_SUPPORTED; + break; + } + + return status; } /* -- cgit From 7e6cf43756b7643e2f0ee7ada5076f36f3a24bb7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 Jan 2004 22:55:27 +0000 Subject: This patch adds a better dcerpc server infastructure. 1.) We now register endpoint servers add startup via register_backend() and later use the smb.conf 'dcerpc endpoint servers' parameter to setup the dcesrv_context 2.) each endpoint server can register at context creation time as much interfaces as it wants (multiple interfaces on one endpoint are supported!) (NOTE: there's a difference between 'endpoint server' and 'endpoint'! for details look at rpc_server/dcesrv_server.h) 3.) one endpoint can have a security descriptor registered to it self this will be checked in the future when a client wants to connect to an smb pipe endpoint. 4.) we now have a 'remote' endpoint server, which works like the ntvfs_cifs module it takes this options in the [globals] section: dcerpc remote:interfaces = srvsvc, winreg, w32time, epmapper dcerpc remote:binding = ... dcerpc remote:user = ... dcerpc remote:password = ... 5.) we currently have tree endpoint servers: epmapper, rpcecho and remote the default for the 'dcerpc endpiont servers = epmapper, rpcecho' for testing you can also do dcerpc endpoint servers = rpcecho, remote, epmapper dcerpc remote:interfaces = srvsvc, samr, netlogon 6,) please notice the the epmapper now only returns NO_ENTRIES (but I think we'll find a solution for this too:-) 7.) also there're some other stuff left, but step by step :-) This patch also includes updates for the register_subsystem() , ntvfs_init(), and some other funtions to check for duplicate subsystem registration metze (hmmm, my first large commit...I hope it works as supposed :-) (This used to be commit 917e45dafd5be4c2cd90ff425b8d6f8403122349) --- source4/ntvfs/ipc/vfs_ipc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 96f28895c9..cd300b6589 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -1,7 +1,9 @@ /* Unix SMB/CIFS implementation. default IPC$ NTVFS backend + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Stefan (metze) Metzmacher 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +41,7 @@ struct ipc_private { TALLOC_CTX *mem_ctx; const char *pipe_name; uint16 fnum; - struct dcesrv_state *pipe_state; + struct dcesrv_connection *dce_conn; uint16 ipc_state; } *pipe_list; @@ -77,7 +79,7 @@ again: static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) { TALLOC_CTX *mem_ctx = private->pipe_list->mem_ctx; - dcesrv_endpoint_disconnect(private->pipe_list->pipe_state); + dcesrv_endpoint_disconnect(private->pipe_list->dce_conn); DLIST_REMOVE(private->pipe_list, private->pipe_list); talloc_destroy(mem_ctx); } @@ -192,7 +194,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, struct pipe_state *p; TALLOC_CTX *mem_ctx; NTSTATUS status; - struct dcesrv_endpoint endpoint; + struct dcesrv_ep_description ep_description; struct ipc_private *private = req->conn->ntvfs_private; mem_ctx = talloc_init("ipc_open '%s'", fname); @@ -235,10 +237,10 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, finalised for Samba4 */ - endpoint.type = ENDPOINT_SMB; - endpoint.info.smb_pipe = p->pipe_name; + ep_description.type = ENDPOINT_SMB; + ep_description.info.smb_pipe = p->pipe_name; - status = dcesrv_endpoint_connect(&req->smb->dcesrv, &endpoint, &p->pipe_state); + status = dcesrv_endpoint_search_connect(&req->smb->dcesrv, &ep_description, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(mem_ctx); return status; @@ -386,7 +388,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_output(p->pipe_state, &data); + status = dcesrv_output(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -440,7 +442,7 @@ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_input(p->pipe_state, &data); + status = dcesrv_input(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -599,7 +601,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t expect this to fail, and things like NDR faults are not reported at this stage. Those sorts of errors happen in the dcesrv_output stage */ - status = dcesrv_input(p->pipe_state, &trans->in.data); + status = dcesrv_input(p->dce_conn, &trans->in.data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -609,7 +611,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t async calls. Again, we only expect NT_STATUS_OK. If the call fails then the error is encoded at the dcerpc level */ - status = dcesrv_output(p->pipe_state, &trans->out.data); + status = dcesrv_output(p->dce_conn, &trans->out.data); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From 7a4da9654e30ea96b326448c3e9111c2a5604f58 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Jan 2004 05:54:17 +0000 Subject: dcerpc server output now copes with the client blocking part way through a read. This happens to also avoid a memcpy on output for dcerpc over tcp. (This used to be commit e7c53ad1856e299d82d84b5837189ae3191c32de) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index cd300b6589..c6d5a52960 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -388,7 +388,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_output(p->dce_conn, &data); + status = dcesrv_output_blob(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -611,7 +611,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t async calls. Again, we only expect NT_STATUS_OK. If the call fails then the error is encoded at the dcerpc level */ - status = dcesrv_output(p->dce_conn, &trans->out.data); + status = dcesrv_output_blob(p->dce_conn, &trans->out.data); if (!NT_STATUS_IS_OK(status)) { return status; } -- cgit From 894e02f80c254da4edca5dbae99561d205c63fbe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2004 13:28:29 +0000 Subject: some DEBUG and comment fixes metze (This used to be commit 5ac4f878687eb0fa95a2e5830a8372168a27d3b3) --- source4/ntvfs/ipc/vfs_ipc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index c6d5a52960..cf1d21bf33 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -686,9 +686,11 @@ NTSTATUS ntvfs_ipc_init(void) ZERO_STRUCT(ops); - /* fill in all the operations */ - ops.name = "ipc"; + /* fill in the name and type */ + ops.name = "default"; ops.type = NTVFS_IPC; + + /* fill in all the operations */ ops.connect = ipc_connect; ops.disconnect = ipc_disconnect; ops.unlink = ipc_unlink; -- cgit From 0f581e4af943a7e5dfd71d1c308ac668f287aed3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 May 2004 11:23:50 +0000 Subject: r623: setUserInfo level 24 (password set) now works in the SAMR server. This includes all of the password complexity, password history and other password restrictions. (This used to be commit cb070b9084d95cf5178edbef951b75eab62b7220) --- source4/ntvfs/ipc/vfs_ipc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index cf1d21bf33..1c02e8fadc 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -252,6 +252,11 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, *ps = p; + /* tell the RPC layer the transport session key */ + if (req->user_ctx->vuser) { + dcesrv_set_session_key(p->dce_conn, req->user_ctx->vuser->session_key); + } + return NT_STATUS_OK; } -- cgit From f9d8f8843dc0ab8c9d59abde7222e0f118b86b5d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 16:24:13 +0000 Subject: r884: convert samba4 to use [u]int32_t instead of [u]int32 metze (This used to be commit 0e5517d937a2eb7cf707991d1c7498c1ab456095) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 1c02e8fadc..635b14b821 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -54,7 +54,7 @@ struct ipc_private { static uint16 find_next_fnum(struct ipc_private *ipc) { struct pipe_state *p; - uint32 ret; + uint32_t ret; if (ipc->num_open == 0xFFFF) { return 0; -- cgit From f88bf54c7f6d1c2ef833047eb8327953c304b5ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:24:24 +0000 Subject: r889: convert samba4 to use [u]int16_t instead of [u]int16 metze (This used to be commit af6f1f8a01bebbecd99bc8c066519e89966e65e3) --- source4/ntvfs/ipc/vfs_ipc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 635b14b821..9a2589a2ee 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -32,17 +32,17 @@ pipes */ struct ipc_private { - uint16 next_fnum; - uint16 num_open; + uint16_t next_fnum; + uint16_t num_open; /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; TALLOC_CTX *mem_ctx; const char *pipe_name; - uint16 fnum; + uint16_t fnum; struct dcesrv_connection *dce_conn; - uint16 ipc_state; + uint16_t ipc_state; } *pipe_list; }; @@ -51,7 +51,7 @@ struct ipc_private { /* find the next fnum available on this connection */ -static uint16 find_next_fnum(struct ipc_private *ipc) +static uint16_t find_next_fnum(struct ipc_private *ipc) { struct pipe_state *p; uint32_t ret; @@ -88,7 +88,7 @@ static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) /* find a open pipe give a file descriptor */ -static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16 fnum) +static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t fnum) { struct pipe_state *p; @@ -369,7 +369,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) { struct ipc_private *private = req->conn->ntvfs_private; DATA_BLOB data; - uint16 fnum; + uint16_t fnum; struct pipe_state *p; NTSTATUS status; @@ -421,7 +421,7 @@ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) { struct ipc_private *private = req->conn->ntvfs_private; DATA_BLOB data; - uint16 fnum; + uint16_t fnum; struct pipe_state *p; NTSTATUS status; -- cgit From 0d466258be1fc7156de469daec07b79701557168 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 5 Jun 2004 01:39:08 +0000 Subject: r1019: Push the auth subsystem away from using typedef, and over to the 'all goodness and light' struct ;-) Break apart the auth subsystem's return strucutres, into the parts that a netlogon call cares about, and the parts that are for a local session. This is the 'struct session_info' and it will almost completly replace the current information stored on a vuid, but be generic to all login methods (RPC over TCP, for example). Andrew Bartlett (This used to be commit d199697014d9562f9439a30b950fda798c5ef419) --- source4/ntvfs/ipc/vfs_ipc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 9a2589a2ee..7ebf35d5cb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -254,7 +254,9 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, /* tell the RPC layer the transport session key */ if (req->user_ctx->vuser) { - dcesrv_set_session_key(p->dce_conn, req->user_ctx->vuser->session_key); + /* TODO: Fix this to push more than just a session key + * down - we need the entire session_info, reference counted... */ + dcesrv_set_session_key(p->dce_conn, req->user_ctx->vuser->session_info->session_key); } return NT_STATUS_OK; -- cgit From b717b40235b2433b26b20ced36142c250f9c411e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 7 Jun 2004 21:34:32 +0000 Subject: r1078: the dxesrv_crypto_* implementations should now explicit set the dce_conn->auth_state.session_info ( the ntlmssp one works fine, but the schannel one isn't implemented yet) this is also set by the ntvfs_ipc backend on the endpoint connect. metze (This used to be commit ad3dd1789e9f124493519cb4731d9f5a563fd051) --- source4/ntvfs/ipc/vfs_ipc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7ebf35d5cb..9279e0e85a 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -195,6 +195,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, TALLOC_CTX *mem_ctx; NTSTATUS status; struct dcesrv_ep_description ep_description; + struct auth_session_info *session_info = NULL; struct ipc_private *private = req->conn->ntvfs_private; mem_ctx = talloc_init("ipc_open '%s'", fname); @@ -240,7 +241,18 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, ep_description.type = ENDPOINT_SMB; ep_description.info.smb_pipe = p->pipe_name; - status = dcesrv_endpoint_search_connect(&req->smb->dcesrv, &ep_description, &p->dce_conn); + /* tell the RPC layer the session_info */ + if (req->user_ctx->vuser) { + /* + * TODO: we need to reference count the entire session_info + */ + session_info = req->user_ctx->vuser->session_info; + } + + status = dcesrv_endpoint_search_connect(&req->smb->dcesrv, + &ep_description, + session_info, + &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(mem_ctx); return status; @@ -252,13 +264,6 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, *ps = p; - /* tell the RPC layer the transport session key */ - if (req->user_ctx->vuser) { - /* TODO: Fix this to push more than just a session key - * down - we need the entire session_info, reference counted... */ - dcesrv_set_session_key(p->dce_conn, req->user_ctx->vuser->session_info->session_key); - } - return NT_STATUS_OK; } -- cgit From b00103dac1bf9e559e132c62e768dba9408b94eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Jun 2004 06:49:24 +0000 Subject: r1165: fixed handling of SMBtrans replies that should return STATUS_BUFFER_OVERFLOW when more data is present. (This used to be commit 0e557fe85748558affd20a58455c4b75fee69e27) --- source4/ntvfs/ipc/vfs_ipc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 9279e0e85a..5b61c9285e 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -401,7 +401,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) } status = dcesrv_output_blob(p->dce_conn, &data); - if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_ERR(status)) { return status; } @@ -418,7 +418,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) return NT_STATUS_NOT_SUPPORTED; } - return NT_STATUS_OK; + return status; } /* @@ -624,7 +624,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t the error is encoded at the dcerpc level */ status = dcesrv_output_blob(p->dce_conn, &trans->out.data); - if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_ERR(status)) { return status; } @@ -632,7 +632,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t trans->out.setup = NULL; trans->out.params = data_blob(NULL, 0); - return NT_STATUS_OK; + return status; } -- cgit From d4ae6ae74d712b74800e360590052d318d2fd101 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 07:41:15 +0000 Subject: r1277: rename struct server_context to smbsrv_ontext because I need server_context fot the generic server infastructure metze (This used to be commit 0712f9f30797e65362c99423c0cf158a2f539000) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 5b61c9285e..8cef711d69 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -249,7 +249,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, session_info = req->user_ctx->vuser->session_info; } - status = dcesrv_endpoint_search_connect(&req->smb->dcesrv, + status = dcesrv_endpoint_search_connect(&req->smb_ctx->dcesrv, &ep_description, session_info, &p->dce_conn); -- cgit From 4ddb2d347d86818a13d71d0eb2f0f8983c2cc41f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 08:27:36 +0000 Subject: r1279: rename struct tcon_context to smbsrv_tcon metze (This used to be commit 99473fab4b1ff87a795f3c08f4c521d9beb504c0) --- source4/ntvfs/ipc/vfs_ipc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8cef711d69..b726dd6116 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -107,18 +107,18 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t */ static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) { - struct tcon_context *conn = req->conn; + struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; - conn->fs_type = talloc_strdup(conn->mem_ctx, "IPC"); - conn->dev_type = talloc_strdup(conn->mem_ctx, "IPC"); + tcon->fs_type = talloc_strdup(tcon->mem_ctx, "IPC"); + tcon->dev_type = talloc_strdup(tcon->mem_ctx, "IPC"); /* prepare the private state for this connection */ - private = talloc(conn->mem_ctx, sizeof(struct ipc_private)); + private = talloc(tcon->mem_ctx, sizeof(struct ipc_private)); if (!private) { return NT_STATUS_NO_MEMORY; } - conn->ntvfs_private = (void *)private; + tcon->ntvfs_private = (void *)private; private->pipe_list = NULL; private->next_fnum = 1; @@ -130,7 +130,7 @@ static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) /* disconnect from a share */ -static NTSTATUS ipc_disconnect(struct tcon_context *tcon) +static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon) { struct ipc_private *private = tcon->ntvfs_private; @@ -196,7 +196,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, NTSTATUS status; struct dcesrv_ep_description ep_description; struct auth_session_info *session_info = NULL; - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; mem_ctx = talloc_init("ipc_open '%s'", fname); if (!mem_ctx) { @@ -374,7 +374,7 @@ static NTSTATUS ipc_copy(struct request_context *req, struct smb_copy *cp) */ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) { - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -426,7 +426,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) */ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) { - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -495,7 +495,7 @@ static NTSTATUS ipc_flush(struct request_context *req, struct smb_flush *io) */ static NTSTATUS ipc_close(struct request_context *req, union smb_close *io) { - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -595,7 +595,7 @@ NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *i static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; NTSTATUS status; /* the fnum is in setup[1] */ @@ -640,7 +640,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t static NTSTATUS ipc_set_nm_pipe_state(struct request_context *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = req->conn->ntvfs_private; + struct ipc_private *private = req->tcon->ntvfs_private; /* the fnum is in setup[1] */ p = pipe_state_find(private, trans->in.setup[1]); -- cgit From 8bf537d119be3e1823ad41b8b8af0d163251b1c5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 08:39:00 +0000 Subject: r1280: rename struct request_context to smbsrv_request metze (This used to be commit a85d2db5826a84b812ea5162a11f54edd25f74e3) --- source4/ntvfs/ipc/vfs_ipc.c | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b726dd6116..8d3eaa2bb4 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -105,7 +105,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t /* connect to a share - always works */ -static NTSTATUS ipc_connect(struct request_context *req, const char *sharename) +static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) { struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -145,7 +145,7 @@ static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon) /* delete a file */ -static NTSTATUS ipc_unlink(struct request_context *req, struct smb_unlink *unl) +static NTSTATUS ipc_unlink(struct smbsrv_request *req, struct smb_unlink *unl) { return NT_STATUS_ACCESS_DENIED; } @@ -154,7 +154,7 @@ static NTSTATUS ipc_unlink(struct request_context *req, struct smb_unlink *unl) /* ioctl interface - we don't do any */ -static NTSTATUS ipc_ioctl(struct request_context *req, union smb_ioctl *io) +static NTSTATUS ipc_ioctl(struct smbsrv_request *req, union smb_ioctl *io) { return NT_STATUS_ACCESS_DENIED; } @@ -162,7 +162,7 @@ static NTSTATUS ipc_ioctl(struct request_context *req, union smb_ioctl *io) /* check if a directory exists */ -static NTSTATUS ipc_chkpath(struct request_context *req, struct smb_chkpath *cp) +static NTSTATUS ipc_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -170,7 +170,7 @@ static NTSTATUS ipc_chkpath(struct request_context *req, struct smb_chkpath *cp) /* return info on a pathname */ -static NTSTATUS ipc_qpathinfo(struct request_context *req, union smb_fileinfo *info) +static NTSTATUS ipc_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -178,7 +178,7 @@ static NTSTATUS ipc_qpathinfo(struct request_context *req, union smb_fileinfo *i /* set info on a pathname */ -static NTSTATUS ipc_setpathinfo(struct request_context *req, union smb_setfileinfo *st) +static NTSTATUS ipc_setpathinfo(struct smbsrv_request *req, union smb_setfileinfo *st) { return NT_STATUS_ACCESS_DENIED; } @@ -188,7 +188,7 @@ static NTSTATUS ipc_setpathinfo(struct request_context *req, union smb_setfilein /* open a file backend - used for MSRPC pipes */ -static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, +static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, struct pipe_state **ps) { struct pipe_state *p; @@ -270,7 +270,7 @@ static NTSTATUS ipc_open_generic(struct request_context *req, const char *fname, /* open a file with ntcreatex - used for MSRPC pipes */ -static NTSTATUS ipc_open_ntcreatex(struct request_context *req, union smb_open *oi) +static NTSTATUS ipc_open_ntcreatex(struct smbsrv_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; @@ -290,7 +290,7 @@ static NTSTATUS ipc_open_ntcreatex(struct request_context *req, union smb_open * /* open a file with openx - used for MSRPC pipes */ -static NTSTATUS ipc_open_openx(struct request_context *req, union smb_open *oi) +static NTSTATUS ipc_open_openx(struct smbsrv_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; @@ -318,7 +318,7 @@ static NTSTATUS ipc_open_openx(struct request_context *req, union smb_open *oi) /* open a file - used for MSRPC pipes */ -static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) +static NTSTATUS ipc_open(struct smbsrv_request *req, union smb_open *oi) { NTSTATUS status; @@ -340,7 +340,7 @@ static NTSTATUS ipc_open(struct request_context *req, union smb_open *oi) /* create a directory */ -static NTSTATUS ipc_mkdir(struct request_context *req, union smb_mkdir *md) +static NTSTATUS ipc_mkdir(struct smbsrv_request *req, union smb_mkdir *md) { return NT_STATUS_ACCESS_DENIED; } @@ -348,7 +348,7 @@ static NTSTATUS ipc_mkdir(struct request_context *req, union smb_mkdir *md) /* remove a directory */ -static NTSTATUS ipc_rmdir(struct request_context *req, struct smb_rmdir *rd) +static NTSTATUS ipc_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd) { return NT_STATUS_ACCESS_DENIED; } @@ -356,7 +356,7 @@ static NTSTATUS ipc_rmdir(struct request_context *req, struct smb_rmdir *rd) /* rename a set of files */ -static NTSTATUS ipc_rename(struct request_context *req, union smb_rename *ren) +static NTSTATUS ipc_rename(struct smbsrv_request *req, union smb_rename *ren) { return NT_STATUS_ACCESS_DENIED; } @@ -364,7 +364,7 @@ static NTSTATUS ipc_rename(struct request_context *req, union smb_rename *ren) /* copy a set of files */ -static NTSTATUS ipc_copy(struct request_context *req, struct smb_copy *cp) +static NTSTATUS ipc_copy(struct smbsrv_request *req, struct smb_copy *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -372,7 +372,7 @@ static NTSTATUS ipc_copy(struct request_context *req, struct smb_copy *cp) /* read from a file */ -static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) +static NTSTATUS ipc_read(struct smbsrv_request *req, union smb_read *rd) { struct ipc_private *private = req->tcon->ntvfs_private; DATA_BLOB data; @@ -424,7 +424,7 @@ static NTSTATUS ipc_read(struct request_context *req, union smb_read *rd) /* write to a file */ -static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) +static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr) { struct ipc_private *private = req->tcon->ntvfs_private; DATA_BLOB data; @@ -477,7 +477,7 @@ static NTSTATUS ipc_write(struct request_context *req, union smb_write *wr) /* seek in a file */ -static NTSTATUS ipc_seek(struct request_context *req, struct smb_seek *io) +static NTSTATUS ipc_seek(struct smbsrv_request *req, struct smb_seek *io) { return NT_STATUS_ACCESS_DENIED; } @@ -485,7 +485,7 @@ static NTSTATUS ipc_seek(struct request_context *req, struct smb_seek *io) /* flush a file */ -static NTSTATUS ipc_flush(struct request_context *req, struct smb_flush *io) +static NTSTATUS ipc_flush(struct smbsrv_request *req, struct smb_flush *io) { return NT_STATUS_ACCESS_DENIED; } @@ -493,7 +493,7 @@ static NTSTATUS ipc_flush(struct request_context *req, struct smb_flush *io) /* close a file */ -static NTSTATUS ipc_close(struct request_context *req, union smb_close *io) +static NTSTATUS ipc_close(struct smbsrv_request *req, union smb_close *io) { struct ipc_private *private = req->tcon->ntvfs_private; struct pipe_state *p; @@ -516,7 +516,7 @@ static NTSTATUS ipc_close(struct request_context *req, union smb_close *io) /* exit - closing files? */ -static NTSTATUS ipc_exit(struct request_context *req) +static NTSTATUS ipc_exit(struct smbsrv_request *req) { return NT_STATUS_ACCESS_DENIED; } @@ -524,7 +524,7 @@ static NTSTATUS ipc_exit(struct request_context *req) /* lock a byte range */ -static NTSTATUS ipc_lock(struct request_context *req, union smb_lock *lck) +static NTSTATUS ipc_lock(struct smbsrv_request *req, union smb_lock *lck) { return NT_STATUS_ACCESS_DENIED; } @@ -532,7 +532,7 @@ static NTSTATUS ipc_lock(struct request_context *req, union smb_lock *lck) /* set info on a open file */ -static NTSTATUS ipc_setfileinfo(struct request_context *req, union smb_setfileinfo *info) +static NTSTATUS ipc_setfileinfo(struct smbsrv_request *req, union smb_setfileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -540,7 +540,7 @@ static NTSTATUS ipc_setfileinfo(struct request_context *req, union smb_setfilein /* query info on a open file */ -static NTSTATUS ipc_qfileinfo(struct request_context *req, union smb_fileinfo *info) +static NTSTATUS ipc_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -549,7 +549,7 @@ static NTSTATUS ipc_qfileinfo(struct request_context *req, union smb_fileinfo *i /* return filesystem info */ -static NTSTATUS ipc_fsinfo(struct request_context *req, union smb_fsinfo *fs) +static NTSTATUS ipc_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) { return NT_STATUS_ACCESS_DENIED; } @@ -557,7 +557,7 @@ static NTSTATUS ipc_fsinfo(struct request_context *req, union smb_fsinfo *fs) /* return print queue info */ -static NTSTATUS ipc_lpq(struct request_context *req, union smb_lpq *lpq) +static NTSTATUS ipc_lpq(struct smbsrv_request *req, union smb_lpq *lpq) { return NT_STATUS_ACCESS_DENIED; } @@ -565,7 +565,7 @@ static NTSTATUS ipc_lpq(struct request_context *req, union smb_lpq *lpq) /* list files in a directory matching a wildcard pattern */ -NTSTATUS ipc_search_first(struct request_context *req, union smb_search_first *io, +NTSTATUS ipc_search_first(struct smbsrv_request *req, union smb_search_first *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -575,7 +575,7 @@ NTSTATUS ipc_search_first(struct request_context *req, union smb_search_first *i /* continue listing files in a directory */ -NTSTATUS ipc_search_next(struct request_context *req, union smb_search_next *io, +NTSTATUS ipc_search_next(struct smbsrv_request *req, union smb_search_next *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -585,14 +585,14 @@ NTSTATUS ipc_search_next(struct request_context *req, union smb_search_next *io, /* end listing files in a directory */ -NTSTATUS ipc_search_close(struct request_context *req, union smb_search_close *io) +NTSTATUS ipc_search_close(struct smbsrv_request *req, union smb_search_close *io) { return NT_STATUS_ACCESS_DENIED; } /* SMBtrans - handle a DCERPC command */ -static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *trans) +static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; struct ipc_private *private = req->tcon->ntvfs_private; @@ -637,7 +637,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct request_context *req, struct smb_trans2 *t /* SMBtrans - set named pipe state */ -static NTSTATUS ipc_set_nm_pipe_state(struct request_context *req, struct smb_trans2 *trans) +static NTSTATUS ipc_set_nm_pipe_state(struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; struct ipc_private *private = req->tcon->ntvfs_private; @@ -663,7 +663,7 @@ static NTSTATUS ipc_set_nm_pipe_state(struct request_context *req, struct smb_tr /* SMBtrans - used to provide access to SMB pipes */ -static NTSTATUS ipc_trans(struct request_context *req, struct smb_trans2 *trans) +static NTSTATUS ipc_trans(struct smbsrv_request *req, struct smb_trans2 *trans) { NTSTATUS status; -- cgit From 118f3edd27f5adacc1da636ed05b33f04999584f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 Jun 2004 07:40:14 +0000 Subject: r1291: rename struct smbsrv_context to smbsrv_connection because this is the connection state per transport layer (tcp) connection I also moved the substructs directly into smbsrv_connection, because they don't need a struct name and we should allway pass the complete smbsrv_connection struct into functions metze (This used to be commit 60f823f201fcedf5473008e8453a6351e73a92c7) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8d3eaa2bb4..cf8b49ebb8 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -249,7 +249,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, session_info = req->user_ctx->vuser->session_info; } - status = dcesrv_endpoint_search_connect(&req->smb_ctx->dcesrv, + status = dcesrv_endpoint_search_connect(&req->smb_conn->dcesrv, &ep_description, session_info, &p->dce_conn); -- cgit From dc9f55dbec5f892b39d924d5fd033b5eec1e14e4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 29 Jun 2004 09:40:10 +0000 Subject: r1294: A nice, large, commit... This implements gensec for Samba's server side, and brings gensec up to the standards of a full subsystem. This means that use of the subsystem is by gensec_* functions, not function pointers in structures (this is internal). This causes changes in all the existing gensec users. Our RPC server no longer contains it's own generalised security scheme, and now calls gensec directly. Gensec has also taken over the role of auth/auth_ntlmssp.c An important part of gensec, is the output of the 'session_info' struct. This is now reference counted, so that we can correctly free it when a pipe is closed, no matter if it was inherited, or created by per-pipe authentication. The schannel code is reworked, to be in the same file for client and server. ntlm_auth is reworked to use gensec. The major problem with this code is the way it relies on subsystem auto-initialisation. The primary reason for this commit now.is to allow these problems to be looked at, and fixed. There are problems with the new code: - I've tested it with smbtorture, but currently don't have VMware and valgrind working (this I'll fix soon). - The SPNEGO code is client-only at this point. - We still do not do kerberos. Andrew Bartlett (This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec) --- source4/ntvfs/ipc/vfs_ipc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index cf8b49ebb8..f6a0015f1d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -243,9 +243,9 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, /* tell the RPC layer the session_info */ if (req->user_ctx->vuser) { - /* - * TODO: we need to reference count the entire session_info - */ + /* The session info is refcount-increased in the + dcesrv_endpoint_search_connect() function */ + session_info = req->user_ctx->vuser->session_info; } -- cgit From 3a6f761eb061d93837038f0aa75c2ffcb0ba3639 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 12 Jul 2004 16:35:48 +0000 Subject: r1470: Get the smb_trans2 structure out of the rap_cli_call struct. Initial attempt at RAP server infrastructure. Look at rap_server.c for the dummy functions that are supposed to implement the core functionality. ipc_rap.c contains all the data shuffling. _rap_shareenum and _rap_serverenum2 in ipc_rap.c are (I think) regular enough to be auto-generated. I did not test all the corner cases yet, but nevertheless I would like some comments on the general style. Volker P.S: samba-3 smbclient now doesn't freak out anymore, although the results are not entirely correct :-) (This used to be commit 08140cc1a838b4eaa23c897b280a46c95b7ef3e0) --- source4/ntvfs/ipc/vfs_ipc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index f6a0015f1d..73b3de314d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -667,6 +667,9 @@ static NTSTATUS ipc_trans(struct smbsrv_request *req, struct smb_trans2 *trans) { NTSTATUS status; + if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) + return ipc_rap_call(req, trans); + if (trans->in.setup_count != 2) { return NT_STATUS_INVALID_PARAMETER; } -- cgit From 5779a7da9aecb7329eb47e93000dc8b9de96d9ae Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 14 Jul 2004 12:44:31 +0000 Subject: r1499: combine struct user_struct and struct smbsrv_user to a struct smbsrv_session that the same as cli_session for the client we need a gensec_security pointer there (spnego support will follow) prefix some related functions with smbsrv_ metze (This used to be commit f276378157bb9994c4c91ce46150a510de5c33f8) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 73b3de314d..2e44b00c6b 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -242,11 +242,11 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, ep_description.info.smb_pipe = p->pipe_name; /* tell the RPC layer the session_info */ - if (req->user_ctx->vuser) { + if (req->session) { /* The session info is refcount-increased in the dcesrv_endpoint_search_connect() function */ - session_info = req->user_ctx->vuser->session_info; + session_info = req->session->session_info; } status = dcesrv_endpoint_search_connect(&req->smb_conn->dcesrv, -- cgit From 893c62d38388b20c52cf3c45069d836c46f42bd3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Sep 2004 05:39:06 +0000 Subject: r2249: got rid of some more mem_ctx elements in structures (This used to be commit 21ef338cbbe96acc8594ffc550ef60c6a40fb951) --- source4/ntvfs/ipc/vfs_ipc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2e44b00c6b..053222460c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -110,11 +110,11 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; - tcon->fs_type = talloc_strdup(tcon->mem_ctx, "IPC"); - tcon->dev_type = talloc_strdup(tcon->mem_ctx, "IPC"); + tcon->fs_type = talloc_strdup(tcon, "IPC"); + tcon->dev_type = talloc_strdup(tcon, "IPC"); /* prepare the private state for this connection */ - private = talloc(tcon->mem_ctx, sizeof(struct ipc_private)); + private = talloc_p(tcon, struct ipc_private); if (!private) { return NT_STATUS_NO_MEMORY; } @@ -604,7 +604,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *tr return NT_STATUS_INVALID_HANDLE; } - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, trans->in.max_data); + trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); if (!trans->out.data.data) { return NT_STATUS_NO_MEMORY; } -- cgit From a3cec511bbef2cc7768906f3af947ce2f900bde6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 23 Sep 2004 07:44:42 +0000 Subject: r2561: completely redid the ntvfs module chaining code, You can now do something like: ntvfs handler = nbench posix and the nbench pass-thru module will be called before the posix module. The chaining logic is now much saner, and less racy, with each level in the chain getting its own private pointer rather than relying on save/restore logic in the pass-thru module. The only pass-thru module we have at the moment is the nbench one (which records all traffic in a nbench compatibe format), but I plan on soon writing a "unixuid" pass-thru module that will implement the setegid()/setgroups()/seteuid() logic for standard posix uid handling. This separation of the posix backend from the uid handling should simplify the code, and make development easier. I also modified the nbench module so it can do multiple chaining, so if you want to you can do: ntvfs module = nbench nbench posix and it will save 2 copies of the log file in /tmp. This is really only useful for testing at the moment until we have more than one pass-thru module. (This used to be commit f84c0af35cb54c8fdc4933afefc18fa4c062aae4) --- source4/ntvfs/ipc/vfs_ipc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 053222460c..96e7820be5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -105,7 +105,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t /* connect to a share - always works */ -static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) +static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename, int depth) { struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -118,7 +118,7 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) if (!private) { return NT_STATUS_NO_MEMORY; } - tcon->ntvfs_private = (void *)private; + ntvfs_set_private(tcon, depth, private); private->pipe_list = NULL; private->next_fnum = 1; @@ -130,9 +130,9 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename) /* disconnect from a share */ -static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon) +static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon, int depth) { - struct ipc_private *private = tcon->ntvfs_private; + struct ipc_private *private = tcon->ntvfs_private_list[depth]; /* close any pipes that are open. Discard any unread data */ while (private->pipe_list) { @@ -196,7 +196,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, NTSTATUS status; struct dcesrv_ep_description ep_description; struct auth_session_info *session_info = NULL; - struct ipc_private *private = req->tcon->ntvfs_private; + NTVFS_GET_PRIVATE(ipc_private, private, req); mem_ctx = talloc_init("ipc_open '%s'", fname); if (!mem_ctx) { @@ -374,7 +374,7 @@ static NTSTATUS ipc_copy(struct smbsrv_request *req, struct smb_copy *cp) */ static NTSTATUS ipc_read(struct smbsrv_request *req, union smb_read *rd) { - struct ipc_private *private = req->tcon->ntvfs_private; + NTVFS_GET_PRIVATE(ipc_private, private, req); DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -426,7 +426,7 @@ static NTSTATUS ipc_read(struct smbsrv_request *req, union smb_read *rd) */ static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr) { - struct ipc_private *private = req->tcon->ntvfs_private; + NTVFS_GET_PRIVATE(ipc_private, private, req); DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -495,7 +495,7 @@ static NTSTATUS ipc_flush(struct smbsrv_request *req, struct smb_flush *io) */ static NTSTATUS ipc_close(struct smbsrv_request *req, union smb_close *io) { - struct ipc_private *private = req->tcon->ntvfs_private; + NTVFS_GET_PRIVATE(ipc_private, private, req); struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -595,7 +595,7 @@ NTSTATUS ipc_search_close(struct smbsrv_request *req, union smb_search_close *io static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = req->tcon->ntvfs_private; + NTVFS_GET_PRIVATE(ipc_private, private, req); NTSTATUS status; /* the fnum is in setup[1] */ @@ -639,8 +639,8 @@ static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *tr /* SMBtrans - set named pipe state */ static NTSTATUS ipc_set_nm_pipe_state(struct smbsrv_request *req, struct smb_trans2 *trans) { + NTVFS_GET_PRIVATE(ipc_private, private, req); struct pipe_state *p; - struct ipc_private *private = req->tcon->ntvfs_private; /* the fnum is in setup[1] */ p = pipe_state_find(private, trans->in.setup[1]); -- cgit From d79c7d41da373dea7f95506c178b18f0dd896043 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 25 Sep 2004 11:24:10 +0000 Subject: r2627: use the new talloc capabilities in a bunch more places in the rpc server code. This fixes a number of memory leaks I found when testing with valgrind and smbtorture, as the cascading effect of a talloc_free() ensures that anything derived from the top level object is destroyed on disconnect. (This used to be commit 76d0b8206ce64d6ff4a192979c43dddbec726d6e) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 96e7820be5..1ed2efba6b 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -249,7 +249,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, session_info = req->session->session_info; } - status = dcesrv_endpoint_search_connect(&req->smb_conn->dcesrv, + status = dcesrv_endpoint_search_connect(req->smb_conn->dcesrv, &ep_description, session_info, &p->dce_conn); -- cgit From 6310f40448f9f9e856874cbefcc25b753963a41e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 25 Sep 2004 12:48:56 +0000 Subject: r2634: use discard_const_p() in a few places (This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 1ed2efba6b..ce6629739a 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -435,13 +435,13 @@ static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr) switch (wr->generic.level) { case RAW_WRITE_WRITE: fnum = wr->write.in.fnum; - data.data = wr->write.in.data; + data.data = discard_const_p(void, wr->write.in.data); data.length = wr->write.in.count; break; case RAW_WRITE_WRITEX: fnum = wr->writex.in.fnum; - data.data = wr->writex.in.data; + data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; break; -- cgit From e3880fa759cfa03222262327854fe7bbe585fe01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 26 Sep 2004 11:30:20 +0000 Subject: r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count() rather than manual reference counts - properly support SMBexit in the cifs and posix backends - added a logoff method to all backends With these changes the RAW-CONTEXT test now passes against the posix backend (This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8) --- source4/ntvfs/ipc/vfs_ipc.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index ce6629739a..33e1287d21 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -43,6 +43,13 @@ struct ipc_private { uint16_t fnum; struct dcesrv_connection *dce_conn; 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; + + /* we need to remember the client pid that + opened the file so SMBexit works */ + uint16_t smbpid; } *pipe_list; }; @@ -262,6 +269,9 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, DLIST_ADD(private->pipe_list, p); + p->smbpid = req->smbpid; + p->session = req->session; + *ps = p; return NT_STATUS_OK; @@ -514,11 +524,39 @@ static NTSTATUS ipc_close(struct smbsrv_request *req, union smb_close *io) } /* - exit - closing files? + exit - closing files */ static NTSTATUS ipc_exit(struct smbsrv_request *req) { - return NT_STATUS_ACCESS_DENIED; + NTVFS_GET_PRIVATE(ipc_private, private, req); + struct pipe_state *p, *next; + + for (p=private->pipe_list; p; p=next) { + next = p->next; + if (p->smbpid == req->smbpid) { + pipe_shutdown(private, p); + } + } + + return NT_STATUS_OK; +} + +/* + logoff - closing files open by the user +*/ +static NTSTATUS ipc_logoff(struct smbsrv_request *req) +{ + NTVFS_GET_PRIVATE(ipc_private, private, req); + struct pipe_state *p, *next; + + for (p=private->pipe_list; p; p=next) { + next = p->next; + if (p->session == req->session) { + pipe_shutdown(private, p); + } + } + + return NT_STATUS_OK; } /* @@ -733,6 +771,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.search_next = ipc_search_next; ops.search_close = ipc_search_close; ops.trans = ipc_trans; + ops.logoff = ipc_logoff; /* register ourselves with the NTVFS subsystem. */ ret = register_backend("ntvfs", &ops); -- cgit From b2f1a29e4348a5bc34a87d72d526e23e421ed9d5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Sep 2004 05:44:59 +0000 Subject: r2710: continue with the new style of providing a parent context whenever possible to a structure creation routine. This makes for much easier global cleanup. (This used to be commit e14ee428ec357fab76a960387a9820a673786e27) --- source4/ntvfs/ipc/vfs_ipc.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 33e1287d21..59da6faea5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -38,7 +38,6 @@ struct ipc_private { /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; - TALLOC_CTX *mem_ctx; const char *pipe_name; uint16_t fnum; struct dcesrv_connection *dce_conn; @@ -85,10 +84,9 @@ again: */ static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) { - TALLOC_CTX *mem_ctx = private->pipe_list->mem_ctx; - dcesrv_endpoint_disconnect(private->pipe_list->dce_conn); - DLIST_REMOVE(private->pipe_list, private->pipe_list); - talloc_destroy(mem_ctx); + talloc_free(p->dce_conn); + DLIST_REMOVE(private->pipe_list, p); + talloc_destroy(p); } @@ -199,33 +197,25 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, struct pipe_state **ps) { struct pipe_state *p; - TALLOC_CTX *mem_ctx; NTSTATUS status; struct dcesrv_ep_description ep_description; struct auth_session_info *session_info = NULL; NTVFS_GET_PRIVATE(ipc_private, private, req); - mem_ctx = talloc_init("ipc_open '%s'", fname); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - p = talloc(mem_ctx, sizeof(struct pipe_state)); + p = talloc_p(private, struct pipe_state); if (!p) { - talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; } - p->mem_ctx = mem_ctx; - p->pipe_name = talloc_strdup(mem_ctx, fname); + p->pipe_name = talloc_strdup(p, fname); if (!p->pipe_name) { - talloc_destroy(mem_ctx); + talloc_free(p); return NT_STATUS_NO_MEMORY; } p->fnum = find_next_fnum(private); if (p->fnum == 0) { - talloc_destroy(mem_ctx); + talloc_free(p); return NT_STATUS_TOO_MANY_OPENED_FILES; } @@ -261,7 +251,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, session_info, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { - talloc_destroy(mem_ctx); + talloc_free(p); return status; } -- cgit From dcad0f6fd492506efd9a69b4e32c7bbfa5da90e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 29 Sep 2004 13:17:09 +0000 Subject: r2751: this is a new ntvfs design which tries to solve: - the stacking of modules - finding the modules private data - hide the ntvfs details from the calling layer - I set NTVFS_INTERFACE_VERSION 0 till we are closer to release (because we need to solve some async problems with the module stacking) metze (This used to be commit 3ff03b5cb21bb79afdd3b1609be9635f6688a539) --- source4/ntvfs/ipc/vfs_ipc.c | 131 +++++++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 49 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 59da6faea5..69fed6f86f 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -110,7 +110,8 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t /* connect to a share - always works */ -static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename, int depth) +static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, const char *sharename) { struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -123,7 +124,7 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename, i if (!private) { return NT_STATUS_NO_MEMORY; } - ntvfs_set_private(tcon, depth, private); + ntvfs->private_data = private; private->pipe_list = NULL; private->next_fnum = 1; @@ -135,9 +136,10 @@ static NTSTATUS ipc_connect(struct smbsrv_request *req, const char *sharename, i /* disconnect from a share */ -static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon, int depth) +static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs, + struct smbsrv_tcon *tcon) { - struct ipc_private *private = tcon->ntvfs_private_list[depth]; + struct ipc_private *private = ntvfs->private_data; /* close any pipes that are open. Discard any unread data */ while (private->pipe_list) { @@ -150,7 +152,8 @@ static NTSTATUS ipc_disconnect(struct smbsrv_tcon *tcon, int depth) /* delete a file */ -static NTSTATUS ipc_unlink(struct smbsrv_request *req, struct smb_unlink *unl) +static NTSTATUS ipc_unlink(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_unlink *unl) { return NT_STATUS_ACCESS_DENIED; } @@ -159,7 +162,8 @@ static NTSTATUS ipc_unlink(struct smbsrv_request *req, struct smb_unlink *unl) /* ioctl interface - we don't do any */ -static NTSTATUS ipc_ioctl(struct smbsrv_request *req, union smb_ioctl *io) +static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_ioctl *io) { return NT_STATUS_ACCESS_DENIED; } @@ -167,7 +171,8 @@ static NTSTATUS ipc_ioctl(struct smbsrv_request *req, union smb_ioctl *io) /* check if a directory exists */ -static NTSTATUS ipc_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp) +static NTSTATUS ipc_chkpath(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_chkpath *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -175,7 +180,8 @@ static NTSTATUS ipc_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp) /* return info on a pathname */ -static NTSTATUS ipc_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info) +static NTSTATUS ipc_qpathinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -183,7 +189,8 @@ static NTSTATUS ipc_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *in /* set info on a pathname */ -static NTSTATUS ipc_setpathinfo(struct smbsrv_request *req, union smb_setfileinfo *st) +static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_setfileinfo *st) { return NT_STATUS_ACCESS_DENIED; } @@ -193,14 +200,15 @@ static NTSTATUS ipc_setpathinfo(struct smbsrv_request *req, union smb_setfileinf /* open a file backend - used for MSRPC pipes */ -static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, +static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, const char *fname, struct pipe_state **ps) { struct pipe_state *p; NTSTATUS status; struct dcesrv_ep_description ep_description; struct auth_session_info *session_info = NULL; - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; p = talloc_p(private, struct pipe_state); if (!p) { @@ -270,12 +278,13 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname, /* open a file with ntcreatex - used for MSRPC pipes */ -static NTSTATUS ipc_open_ntcreatex(struct smbsrv_request *req, union smb_open *oi) +static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; - status = ipc_open_generic(req, oi->ntcreatex.in.fname, &p); + status = ipc_open_generic(ntvfs, req, oi->ntcreatex.in.fname, &p); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -290,7 +299,8 @@ static NTSTATUS ipc_open_ntcreatex(struct smbsrv_request *req, union smb_open *o /* open a file with openx - used for MSRPC pipes */ -static NTSTATUS ipc_open_openx(struct smbsrv_request *req, union smb_open *oi) +static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; @@ -302,7 +312,7 @@ static NTSTATUS ipc_open_openx(struct smbsrv_request *req, union smb_open *oi) fname += 4; - status = ipc_open_generic(req, fname, &p); + status = ipc_open_generic(ntvfs, req, fname, &p); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -318,16 +328,17 @@ static NTSTATUS ipc_open_openx(struct smbsrv_request *req, union smb_open *oi) /* open a file - used for MSRPC pipes */ -static NTSTATUS ipc_open(struct smbsrv_request *req, union smb_open *oi) +static NTSTATUS ipc_open(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_open *oi) { NTSTATUS status; switch (oi->generic.level) { case RAW_OPEN_NTCREATEX: - status = ipc_open_ntcreatex(req, oi); + status = ipc_open_ntcreatex(ntvfs, req, oi); break; case RAW_OPEN_OPENX: - status = ipc_open_openx(req, oi); + status = ipc_open_openx(ntvfs, req, oi); break; default: status = NT_STATUS_NOT_SUPPORTED; @@ -340,7 +351,8 @@ static NTSTATUS ipc_open(struct smbsrv_request *req, union smb_open *oi) /* create a directory */ -static NTSTATUS ipc_mkdir(struct smbsrv_request *req, union smb_mkdir *md) +static NTSTATUS ipc_mkdir(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_mkdir *md) { return NT_STATUS_ACCESS_DENIED; } @@ -348,7 +360,8 @@ static NTSTATUS ipc_mkdir(struct smbsrv_request *req, union smb_mkdir *md) /* remove a directory */ -static NTSTATUS ipc_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd) +static NTSTATUS ipc_rmdir(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_rmdir *rd) { return NT_STATUS_ACCESS_DENIED; } @@ -356,7 +369,8 @@ static NTSTATUS ipc_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd) /* rename a set of files */ -static NTSTATUS ipc_rename(struct smbsrv_request *req, union smb_rename *ren) +static NTSTATUS ipc_rename(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_rename *ren) { return NT_STATUS_ACCESS_DENIED; } @@ -364,7 +378,8 @@ static NTSTATUS ipc_rename(struct smbsrv_request *req, union smb_rename *ren) /* copy a set of files */ -static NTSTATUS ipc_copy(struct smbsrv_request *req, struct smb_copy *cp) +static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_copy *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -372,9 +387,10 @@ static NTSTATUS ipc_copy(struct smbsrv_request *req, struct smb_copy *cp) /* read from a file */ -static NTSTATUS ipc_read(struct smbsrv_request *req, union smb_read *rd) +static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_read *rd) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -424,9 +440,10 @@ static NTSTATUS ipc_read(struct smbsrv_request *req, union smb_read *rd) /* write to a file */ -static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr) +static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_write *wr) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; uint16_t fnum; struct pipe_state *p; @@ -477,7 +494,8 @@ static NTSTATUS ipc_write(struct smbsrv_request *req, union smb_write *wr) /* seek in a file */ -static NTSTATUS ipc_seek(struct smbsrv_request *req, struct smb_seek *io) +static NTSTATUS ipc_seek(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_seek *io) { return NT_STATUS_ACCESS_DENIED; } @@ -485,7 +503,8 @@ static NTSTATUS ipc_seek(struct smbsrv_request *req, struct smb_seek *io) /* flush a file */ -static NTSTATUS ipc_flush(struct smbsrv_request *req, struct smb_flush *io) +static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_flush *io) { return NT_STATUS_ACCESS_DENIED; } @@ -493,9 +512,10 @@ static NTSTATUS ipc_flush(struct smbsrv_request *req, struct smb_flush *io) /* close a file */ -static NTSTATUS ipc_close(struct smbsrv_request *req, union smb_close *io) +static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_close *io) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -516,9 +536,10 @@ static NTSTATUS ipc_close(struct smbsrv_request *req, union smb_close *io) /* exit - closing files */ -static NTSTATUS ipc_exit(struct smbsrv_request *req) +static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; struct pipe_state *p, *next; for (p=private->pipe_list; p; p=next) { @@ -534,9 +555,10 @@ static NTSTATUS ipc_exit(struct smbsrv_request *req) /* logoff - closing files open by the user */ -static NTSTATUS ipc_logoff(struct smbsrv_request *req) +static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; struct pipe_state *p, *next; for (p=private->pipe_list; p; p=next) { @@ -552,7 +574,8 @@ static NTSTATUS ipc_logoff(struct smbsrv_request *req) /* lock a byte range */ -static NTSTATUS ipc_lock(struct smbsrv_request *req, union smb_lock *lck) +static NTSTATUS ipc_lock(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_lock *lck) { return NT_STATUS_ACCESS_DENIED; } @@ -560,7 +583,8 @@ static NTSTATUS ipc_lock(struct smbsrv_request *req, union smb_lock *lck) /* set info on a open file */ -static NTSTATUS ipc_setfileinfo(struct smbsrv_request *req, union smb_setfileinfo *info) +static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_setfileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -568,7 +592,8 @@ static NTSTATUS ipc_setfileinfo(struct smbsrv_request *req, union smb_setfileinf /* query info on a open file */ -static NTSTATUS ipc_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info) +static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -577,7 +602,8 @@ static NTSTATUS ipc_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *in /* return filesystem info */ -static NTSTATUS ipc_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) +static NTSTATUS ipc_fsinfo(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_fsinfo *fs) { return NT_STATUS_ACCESS_DENIED; } @@ -585,7 +611,8 @@ static NTSTATUS ipc_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs) /* return print queue info */ -static NTSTATUS ipc_lpq(struct smbsrv_request *req, union smb_lpq *lpq) +static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_lpq *lpq) { return NT_STATUS_ACCESS_DENIED; } @@ -593,7 +620,8 @@ static NTSTATUS ipc_lpq(struct smbsrv_request *req, union smb_lpq *lpq) /* list files in a directory matching a wildcard pattern */ -NTSTATUS ipc_search_first(struct smbsrv_request *req, union smb_search_first *io, +static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_search_first *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -603,7 +631,8 @@ NTSTATUS ipc_search_first(struct smbsrv_request *req, union smb_search_first *io /* continue listing files in a directory */ -NTSTATUS ipc_search_next(struct smbsrv_request *req, union smb_search_next *io, +static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_search_next *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -613,17 +642,19 @@ NTSTATUS ipc_search_next(struct smbsrv_request *req, union smb_search_next *io, /* end listing files in a directory */ -NTSTATUS ipc_search_close(struct smbsrv_request *req, union smb_search_close *io) +static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, union smb_search_close *io) { return NT_STATUS_ACCESS_DENIED; } /* SMBtrans - handle a DCERPC command */ -static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *trans) +static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; NTSTATUS status; /* the fnum is in setup[1] */ @@ -665,9 +696,10 @@ static NTSTATUS ipc_dcerpc_cmd(struct smbsrv_request *req, struct smb_trans2 *tr /* SMBtrans - set named pipe state */ -static NTSTATUS ipc_set_nm_pipe_state(struct smbsrv_request *req, struct smb_trans2 *trans) +static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_trans2 *trans) { - NTVFS_GET_PRIVATE(ipc_private, private, req); + struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; /* the fnum is in setup[1] */ @@ -691,7 +723,8 @@ static NTSTATUS ipc_set_nm_pipe_state(struct smbsrv_request *req, struct smb_tra /* SMBtrans - used to provide access to SMB pipes */ -static NTSTATUS ipc_trans(struct smbsrv_request *req, struct smb_trans2 *trans) +static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_trans2 *trans) { NTSTATUS status; @@ -704,10 +737,10 @@ static NTSTATUS ipc_trans(struct smbsrv_request *req, struct smb_trans2 *trans) switch (trans->in.setup[0]) { case TRANSACT_SETNAMEDPIPEHANDLESTATE: - status = ipc_set_nm_pipe_state(req, trans); + status = ipc_set_nm_pipe_state(ntvfs, req, trans); break; case TRANSACT_DCERPCCMD: - status = ipc_dcerpc_cmd(req, trans); + status = ipc_dcerpc_cmd(ntvfs, req, trans); break; default: status = NT_STATUS_INVALID_PARAMETER; -- cgit From 142d295aa8e70477c85d1835f2907f81c4c3c519 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Oct 2004 13:27:22 +0000 Subject: r3039: This solves the problem of async handlers in ntvfs backends not being in the right state when called. For example, when we use the unixuid handler in the chain of handlers, and a backend decides to continue a call asynchronously then we need to ensure that the continuation happens with the right security context. The solution is to add a new ntvfs operation ntvfs_async_setup(), which calls all the way down through the layers, setting up anything that is required, and takes a private pointer. The backend wanting to make a async calls can use ntvfs_async_setup() to ensure that the modules above it are called when doing async processing. (This used to be commit a256e71029727fa1659ade6257085df537308c7d) --- source4/ntvfs/ipc/vfs_ipc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 69fed6f86f..b37b3e917d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -571,6 +571,16 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; } +/* + setup for an async call +*/ +static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, + void *private) +{ + return NT_STATUS_OK; +} + /* lock a byte range */ @@ -795,6 +805,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.search_close = ipc_search_close; ops.trans = ipc_trans; ops.logoff = ipc_logoff; + ops.async_setup = ipc_async_setup; /* register ourselves with the NTVFS subsystem. */ ret = register_backend("ntvfs", &ops); -- cgit From 31403d548e95ee6047009b78ed72e7144ece199a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Oct 2004 15:18:05 +0000 Subject: r3043: Use binding strings for specifying endpoints. The property for specifying a endpoint is now also 'endpoint' instead of 'endpoints'. The default endpoint (if none is specified) is still "ncacn_np:[\\pipe\\ifacename]", where ifacename is the name of the interface. Examples: [ uuid(60a15ec5-4de8-11d7-a637-005056a20182), endpoint("ncacn_np:[\\pipe\\rpcecho]", "ncacn_ip_tcp:") ] interface rpcecho { void dummy(); } dcerpc_binding is now converted to ep_description in the server, but I hope to completely eliminate ep_description later on. The eventual goal of all these changes is to make it easier to add transports as I'm going to add support for ncalrpc (local RPC over named pipes) and ncacn_unix_stream (Unix sockets). (This used to be commit f3da7c8b443a29b0c656c687a277384ae1353792) --- source4/ntvfs/ipc/vfs_ipc.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b37b3e917d..8c32a78512 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -227,9 +227,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, return NT_STATUS_TOO_MANY_OPENED_FILES; } - while (p->pipe_name[0] == '\\') { - p->pipe_name++; - } p->ipc_state = 0x5ff; /* @@ -310,8 +307,6 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - fname += 4; - status = ipc_open_generic(ntvfs, req, fname, &p); if (!NT_STATUS_IS_OK(status)) { return status; -- cgit From 2c081d2c47452acff3115637bbd16f780e23b76a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Oct 2004 16:07:08 +0000 Subject: r3046: \\PIPE\\ is internal (not actually included on the wire) (This used to be commit 7771b5d8fa3db759487474eb7172df45bb3221ae) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8c32a78512..238467a746 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -215,7 +215,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - p->pipe_name = talloc_strdup(p, fname); + p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); if (!p->pipe_name) { talloc_free(p); return NT_STATUS_NO_MEMORY; -- cgit From 06fe5d6cd92bbf87f80c3df305d136760d0f91d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 18 Oct 2004 16:25:36 +0000 Subject: r3047: Always include a \ again before the pipe name we're opening. Without a backslash works, but is not like Windows does it. (This used to be commit f6deb3d065e1a88f92bcb8a4a138453650c97b0b) --- source4/ntvfs/ipc/vfs_ipc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 238467a746..760cf07100 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -215,6 +215,8 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } + while (fname[0] == '\\') fname++; + p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); if (!p->pipe_name) { talloc_free(p); @@ -240,6 +242,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, finalised for Samba4 */ + printf("FINDING: %s\n", p->pipe_name); ep_description.type = ENDPOINT_SMB; ep_description.info.smb_pipe = p->pipe_name; @@ -303,10 +306,6 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, NTSTATUS status; const char *fname = oi->openx.in.fname; - if (strncasecmp(fname, "PIPE\\", 5) != 0) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - status = ipc_open_generic(ntvfs, req, fname, &p); if (!NT_STATUS_IS_OK(status)) { return status; -- cgit From 20d17b80571f0d0265c99c1ccdc21910c2eed043 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Oct 2004 08:28:31 +0000 Subject: r3081: several updates to ntvfs and server side async request handling in preparation for the full share modes and ntcreatex code that I am working on. highlights include: - changed the way a backend determines if it is allowed to process a request asynchronously. The previous method of looking at the send_fn caused problems when an intermediate ntvfs module disabled it, and the caller then wanted to finished processing using this function. The new method is a REQ_CONTROL_MAY_ASYNC flag in req->control_flags, which is also a bit easier to read - fixed 2 bugs in the readbraw server code. One related to trying to answer a readbraw with smb signing (which can't work, and crashed our signing code), the second related to error handling, which attempted to send a normal SMB error packet, when readbraw must send a 0 read reply (as it has no header) - added several more ntvfs_generic.c generic mapping functions. This means that backends no longer need to implement such esoteric functions as SMBwriteunlock() if they don't want to. The backend can just request the mapping layer turn it into a write followed by an unlock. This makes the backends considerably simpler as they only need to implement one style of each function for lock, read, write, open etc, rather than the full host of functions that SMB provides. A backend can still choose to implement them individually, of course, and the CIFS backend does that. - simplified the generic structures to make them identical to the principal call for several common SMB calls (such as RAW_WRITE_GENERIC now being an alias for RAW_WRITE_WRITEX). - started rewriting the pvfs_open() code in preparation for the full ntcreatex semantics. - in pvfs_open and ipc_open, initially allocate the open file structure as a child of the request, so on error we don't need to clean up. Then when we are going to succeed the open steal the pointer into the long term backend context. This makes for much simpler error handling (and fixes some bugs) - use a destructor in the ipc backend to make sure that everthing is cleaned up on receive error conditions. - switched the ipc backend to using idtree for fnum allocation - in the ntvfs_generic mapping routines, use a allocated secondary structure not a stack structure to ensure the request pointer remains valid even if the backend replies async. (This used to be commit 3457c1836c09c82956697eb21627dfa2ed37682e) --- source4/ntvfs/ipc/vfs_ipc.c | 171 ++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 118 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 760cf07100..f4eb007235 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -31,13 +31,12 @@ ipc$ connection. It needs to keep information about all open pipes */ struct ipc_private { - - uint16_t next_fnum; - uint16_t num_open; + void *idtree_fnum; /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; + struct ipc_private *private; const char *pipe_name; uint16_t fnum; struct dcesrv_connection *dce_conn; @@ -54,56 +53,12 @@ struct ipc_private { }; -/* - find the next fnum available on this connection -*/ -static uint16_t find_next_fnum(struct ipc_private *ipc) -{ - struct pipe_state *p; - uint32_t ret; - - if (ipc->num_open == 0xFFFF) { - return 0; - } - -again: - ret = ipc->next_fnum++; - - for (p=ipc->pipe_list; p; p=p->next) { - if (p->fnum == ret) { - goto again; - } - } - - return ret; -} - - -/* - shutdown a single pipe. Called on a close or disconnect -*/ -static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p) -{ - talloc_free(p->dce_conn); - DLIST_REMOVE(private->pipe_list, p); - talloc_destroy(p); -} - - /* find a open pipe give a file descriptor */ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t fnum) { - struct pipe_state *p; - - for (p=private->pipe_list; p; p=p->next) { - if (p->fnum == fnum) { - return p; - } - } - - return NULL; + return idr_find(private->idtree_fnum, fnum); } @@ -127,8 +82,11 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, ntvfs->private_data = private; private->pipe_list = NULL; - private->next_fnum = 1; - private->num_open = 0; + + private->idtree_fnum = idr_init(private); + if (private->idtree_fnum == NULL) { + return NT_STATUS_NO_MEMORY; + } return NT_STATUS_OK; } @@ -143,7 +101,7 @@ static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs, /* close any pipes that are open. Discard any unread data */ while (private->pipe_list) { - pipe_shutdown(private, private->pipe_list); + talloc_free(private->pipe_list); } return NT_STATUS_OK; @@ -196,6 +154,18 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, } +/* + destroy a open pipe structure +*/ +static int ipc_fd_destructor(void *ptr) +{ + struct pipe_state *p = ptr; + idr_remove(p->private->idtree_fnum, p->fnum); + DLIST_REMOVE(p->private->pipe_list, p); + talloc_free(p->dce_conn); + return 0; +} + /* open a file backend - used for MSRPC pipes @@ -209,8 +179,9 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct dcesrv_ep_description ep_description; struct auth_session_info *session_info = NULL; struct ipc_private *private = ntvfs->private_data; + int fnum; - p = talloc_p(private, struct pipe_state); + p = talloc_p(req, struct pipe_state); if (!p) { return NT_STATUS_NO_MEMORY; } @@ -219,16 +190,15 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); if (!p->pipe_name) { - talloc_free(p); return NT_STATUS_NO_MEMORY; } - p->fnum = find_next_fnum(private); - if (p->fnum == 0) { - talloc_free(p); + fnum = idr_get_new(private->idtree_fnum, p, UINT16_MAX); + if (fnum == -1) { return NT_STATUS_TOO_MANY_OPENED_FILES; } + p->fnum = fnum; p->ipc_state = 0x5ff; /* @@ -241,8 +211,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, will need to do that once the credentials infrastructure is finalised for Samba4 */ - - printf("FINDING: %s\n", p->pipe_name); ep_description.type = ENDPOINT_SMB; ep_description.info.smb_pipe = p->pipe_name; @@ -250,7 +218,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, if (req->session) { /* The session info is refcount-increased in the dcesrv_endpoint_search_connect() function */ - session_info = req->session->session_info; } @@ -259,19 +226,22 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, session_info, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { - talloc_free(p); + idr_remove(private->idtree_fnum, p->fnum); return status; } - private->num_open++; - DLIST_ADD(private->pipe_list, p); p->smbpid = req->smbpid; p->session = req->session; + p->private = private; *ps = p; + talloc_steal(private, p); + + talloc_set_destructor(p, ipc_fd_destructor); + return NT_STATUS_OK; } @@ -390,21 +360,14 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, struct pipe_state *p; NTSTATUS status; - switch (rd->generic.level) { - case RAW_READ_READ: - fnum = rd->read.in.fnum; - data.length = rd->read.in.count; - data.data = rd->read.out.data; - break; - case RAW_READ_READX: - fnum = rd->readx.in.fnum; - data.length = rd->readx.in.maxcnt; - data.data = rd->readx.out.data; - break; - default: - return NT_STATUS_NOT_SUPPORTED; + if (rd->generic.level != RAW_READ_GENERIC) { + return ntvfs_map_read(req, rd, ntvfs); } + fnum = rd->readx.in.fnum; + data.length = rd->readx.in.maxcnt; + data.data = rd->readx.out.data; + p = pipe_state_find(private, fnum); if (!p) { return NT_STATUS_INVALID_HANDLE; @@ -415,18 +378,9 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return status; } - switch (rd->generic.level) { - case RAW_READ_READ: - rd->read.out.nread = data.length; - break; - case RAW_READ_READX: - rd->readx.out.remaining = 0; - rd->readx.out.compaction_mode = 0; - rd->readx.out.nread = data.length; - break; - default: - return NT_STATUS_NOT_SUPPORTED; - } + rd->readx.out.remaining = 0; + rd->readx.out.compaction_mode = 0; + rd->readx.out.nread = data.length; return status; } @@ -443,23 +397,14 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, struct pipe_state *p; NTSTATUS status; - switch (wr->generic.level) { - case RAW_WRITE_WRITE: - fnum = wr->write.in.fnum; - data.data = discard_const_p(void, wr->write.in.data); - data.length = wr->write.in.count; - break; - - case RAW_WRITE_WRITEX: - fnum = wr->writex.in.fnum; - data.data = discard_const_p(void, wr->writex.in.data); - data.length = wr->writex.in.count; - break; - - default: - return NT_STATUS_NOT_SUPPORTED; + if (wr->generic.level != RAW_WRITE_GENERIC) { + return ntvfs_map_write(req, wr, ntvfs); } + fnum = wr->writex.in.fnum; + data.data = discard_const_p(void, wr->writex.in.data); + data.length = wr->writex.in.count; + p = pipe_state_find(private, fnum); if (!p) { return NT_STATUS_INVALID_HANDLE; @@ -470,17 +415,8 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return status; } - switch (wr->generic.level) { - case RAW_WRITE_WRITE: - wr->write.out.nwritten = data.length; - break; - case RAW_WRITE_WRITEX: - wr->writex.out.nwritten = data.length; - wr->writex.out.remaining = 0; - break; - default: - return NT_STATUS_NOT_SUPPORTED; - } + wr->writex.out.nwritten = data.length; + wr->writex.out.remaining = 0; return NT_STATUS_OK; } @@ -513,7 +449,7 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { - return NT_STATUS_ACCESS_DENIED; + return ntvfs_map_close(req, io, ntvfs); } p = pipe_state_find(private, io->close.in.fnum); @@ -521,8 +457,7 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - pipe_shutdown(private, p); - private->num_open--; + talloc_free(p); return NT_STATUS_OK; } @@ -539,7 +474,7 @@ 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) { - pipe_shutdown(private, p); + talloc_free(p); } } @@ -558,7 +493,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) { - pipe_shutdown(private, p); + talloc_free(p); } } -- cgit From ac989eda6d981ce47c7b345d5397450a3706f4d7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Oct 2004 12:47:02 +0000 Subject: r3114: - More work on merging the various structs that describe endpoints - Add protocol sequence to dcerpc transports (will be used later on) - Add more transports to the list (This used to be commit ab110192e6e2c1e5a3b2befe7b61158744f15d18) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index f4eb007235..8b1c9d2d8d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -211,7 +211,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, will need to do that once the credentials infrastructure is finalised for Samba4 */ - ep_description.type = ENDPOINT_SMB; + ep_description.type = NCACN_NP; ep_description.info.smb_pipe = p->pipe_name; /* tell the RPC layer the session_info */ -- cgit From a9081b527b33d536ca36d61ad2f7f34a6e6e69e5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Oct 2004 17:40:55 +0000 Subject: r3118: Eliminate struct dcesrv_ep_description and replace it with struct dcerpc_binding. (This used to be commit 2046e14cf8d010d4e715124859df2c1c3c782266) --- source4/ntvfs/ipc/vfs_ipc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8b1c9d2d8d..dc50f1671e 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -176,7 +176,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, { struct pipe_state *p; NTSTATUS status; - struct dcesrv_ep_description ep_description; + struct dcerpc_binding ep_description; struct auth_session_info *session_info = NULL; struct ipc_private *private = ntvfs->private_data; int fnum; @@ -211,8 +211,10 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, will need to do that once the credentials infrastructure is finalised for Samba4 */ - ep_description.type = NCACN_NP; - ep_description.info.smb_pipe = p->pipe_name; + ep_description.transport = NCACN_NP; + ep_description.options = talloc_array_p(req, char *, 2); + ep_description.options[0] = p->pipe_name; + ep_description.options[1] = NULL; /* tell the RPC layer the session_info */ if (req->session) { -- cgit From 6e8867bff5ac95a7f509e3fdc60183cc64d921eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Oct 2004 06:53:18 +0000 Subject: r3132: - fixed a type conflict found by talloc_array_p() - use struct idr_context * in ipc code (This used to be commit c33cdd0d550fcaf78573e73b50ffe530ea6d9b17) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index dc50f1671e..2109fb829e 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -31,7 +31,7 @@ ipc$ connection. It needs to keep information about all open pipes */ struct ipc_private { - void *idtree_fnum; + struct idr_context *idtree_fnum; /* a list of open pipes */ struct pipe_state { @@ -212,7 +212,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, finalised for Samba4 */ ep_description.transport = NCACN_NP; - ep_description.options = talloc_array_p(req, char *, 2); + ep_description.options = talloc_array_p(req, const char *, 2); ep_description.options[0] = p->pipe_name; ep_description.options[1] = NULL; -- cgit From 06b3879c8fec97ef5de9b969301611e28fff00de Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Oct 2004 22:46:47 +0000 Subject: r3167: Add a member 'endpoint' to the dcerpc_binding struct to use instead of options[0]. (This used to be commit 18582083af800abd3d8de40eb73255c8ae6598dd) --- source4/ntvfs/ipc/vfs_ipc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2109fb829e..dcbfdb948f 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -212,9 +212,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, finalised for Samba4 */ ep_description.transport = NCACN_NP; - ep_description.options = talloc_array_p(req, const char *, 2); - ep_description.options[0] = p->pipe_name; - ep_description.options[1] = NULL; + ep_description.endpoint = p->pipe_name; /* tell the RPC layer the session_info */ if (req->session) { -- cgit From 84bbf02e95639536c34140906aa4652ad61ea2c3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 26 Oct 2004 05:36:14 +0000 Subject: r3239: reads of more than UINT16_MAX bytes should return 0 bytes (This used to be commit 16c7dd641707b6b8b3159290ca9fa08053a10692) --- source4/ntvfs/ipc/vfs_ipc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index dcbfdb948f..f7eac65712 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -365,17 +365,23 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, } fnum = rd->readx.in.fnum; - data.length = rd->readx.in.maxcnt; - data.data = rd->readx.out.data; p = pipe_state_find(private, fnum); if (!p) { return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_output_blob(p->dce_conn, &data); - if (NT_STATUS_IS_ERR(status)) { - return status; + data.length = rd->readx.in.maxcnt; + data.data = rd->readx.out.data; + if (data.length > UINT16_MAX) { + data.length = 0; + } + + if (data.length != 0) { + status = dcesrv_output_blob(p->dce_conn, &data); + if (NT_STATUS_IS_ERR(status)) { + return status; + } } rd->readx.out.remaining = 0; -- cgit From f4ec1497a1047eab8a2077694c7629ca6bb9eaa4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 03:44:52 +0000 Subject: r3455: some more portability fixes. We nearly compile on solaris again now. (This used to be commit 4f33247f1ca60416415a61a7afac43c9dc8a61fd) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index f7eac65712..6b6dc97003 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -26,6 +26,7 @@ #include "includes.h" +#include "system/filesys.h" /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open -- cgit From 2df2d1b67f9bf2907f452688b2c54b73052cfb49 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 04:51:57 +0000 Subject: r3461: another place where "open" was used as a structure element (This used to be commit 1087ea830e7aead86d54a1836512e88554afc919) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 6b6dc97003..a0604a9d08 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -719,7 +719,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.chkpath = ipc_chkpath; ops.qpathinfo = ipc_qpathinfo; ops.setpathinfo = ipc_setpathinfo; - ops.open = ipc_open; + ops.openfile = ipc_open; ops.mkdir = ipc_mkdir; ops.rmdir = ipc_rmdir; ops.rename = ipc_rename; -- cgit From 3643fb11092e28a9538ef32cedce8ff21ad86a28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 06:42:15 +0000 Subject: r3463: separated out some more headers (asn_1.h, messages.h, dlinklist.h and ioctl.h) (This used to be commit b97e395c814762024336c1cf4d7c25be8da5813a) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index a0604a9d08..8bcf0382f9 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -27,6 +27,7 @@ #include "includes.h" #include "system/filesys.h" +#include "dlinklist.h" /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open -- cgit From aa34fcebf8aa0660574a7c6976b33b3f37985e27 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 07:18:24 +0000 Subject: r3466: split out request.h, signing.h, and smb_server.h (This used to be commit 7c4e6ebf05790dd6e29896dd316db0fff613aa4e) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 8bcf0382f9..dc43dff3aa 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -28,6 +28,7 @@ #include "includes.h" #include "system/filesys.h" #include "dlinklist.h" +#include "smb_server/smb_server.h" /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open -- cgit From c870ae8b898d3bcc81ed9fd1afd505d78dea52cc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 Nov 2004 11:28:38 +0000 Subject: r3528: added support for the SMBntcancel() operation, which cancels any outstanding async operation (triggering an immediate timeout). pvfs now passes the RAW-MUX test (This used to be commit 3423e2f41461d054067ef168b9b986f62cc8f77c) --- source4/ntvfs/ipc/vfs_ipc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index dc43dff3aa..271be09ac3 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -519,6 +519,15 @@ static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; } +/* + cancel an async call +*/ +static NTSTATUS ipc_cancel(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req) +{ + return NT_STATUS_UNSUCCESSFUL; +} + /* lock a byte range */ @@ -744,6 +753,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.trans = ipc_trans; ops.logoff = ipc_logoff; ops.async_setup = ipc_async_setup; + ops.cancel = ipc_cancel; /* register ourselves with the NTVFS subsystem. */ ret = register_backend("ntvfs", &ops); -- cgit From 31ded4901b4529ad2e49871502cab5ecba71483a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 14 Nov 2004 22:23:23 +0000 Subject: r3737: - Get rid of the register_subsystem() and register_backend() functions. - Re-disable tdbtool (it was building fine on my Debian box but other machines were having problems) (This used to be commit 0d7bb2c40b7a9ed59df3f8944133ea562697e814) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 271be09ac3..a53accd533 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -756,7 +756,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.cancel = ipc_cancel; /* register ourselves with the NTVFS subsystem. */ - ret = register_backend("ntvfs", &ops); + ret = ntvfs_register(&ops); if (!NT_STATUS_IS_OK(ret)) { DEBUG(0,("Failed to register IPC backend!\n")); -- cgit From 96f4d9815346edbb277583d417b4a8ae6c1c0a09 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 29 Nov 2004 06:18:58 +0000 Subject: r3993: use distinctive fnums in the ipc backend, to make monitoring sniffs easier (This used to be commit 54209ed05686a442156f7927c58d8656aa5e4900) --- source4/ntvfs/ipc/vfs_ipc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index a53accd533..b4c41d58d3 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -30,6 +30,8 @@ #include "dlinklist.h" #include "smb_server/smb_server.h" +#define IPC_BASE_FNUM 0x400 + /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open pipes */ @@ -196,7 +198,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - fnum = idr_get_new(private->idtree_fnum, p, UINT16_MAX); + fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX); if (fnum == -1) { return NT_STATUS_TOO_MANY_OPENED_FILES; } -- cgit From f2dbe4610704d97725a69c076af52fbb6e899640 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 12 Dec 2004 08:33:08 +0000 Subject: r4160: fixed the file_type in ntcreatex reply on a named pipe. NT4 requires this to be right. (This used to be commit e22de9734f66bee3c9eaf8191fcae9fb06a0034f) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b4c41d58d3..2f482bb5e4 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -267,6 +267,7 @@ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, ZERO_STRUCT(oi->ntcreatex.out); oi->ntcreatex.out.fnum = p->fnum; oi->ntcreatex.out.ipc_state = p->ipc_state; + oi->ntcreatex.out.file_type = FILE_TYPE_MESSAGE_MODE_PIPE; return status; } -- cgit From 91e9cf6d1a53cc63410e1535907a2ad015e80c82 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jan 2005 14:32:15 +0000 Subject: r4684: the smbsrv code should not know about rpc stuff just vfs_ipc metze (This used to be commit f85ebd1e8e19f5ff271dd7d79190fea16d6a98c4) --- source4/ntvfs/ipc/vfs_ipc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2f482bb5e4..2a19de1ec0 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -38,6 +38,8 @@ struct ipc_private { struct idr_context *idtree_fnum; + struct dcesrv_context *dcesrv; + /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; @@ -73,6 +75,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, const char *sharename) { + NTSTATUS status; struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -80,18 +83,19 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, tcon->dev_type = talloc_strdup(tcon, "IPC"); /* prepare the private state for this connection */ - private = talloc_p(tcon, struct ipc_private); - if (!private) { - return NT_STATUS_NO_MEMORY; - } + private = talloc(tcon, struct ipc_private); + NT_STATUS_HAVE_NO_MEMORY(private); + ntvfs->private_data = private; private->pipe_list = NULL; private->idtree_fnum = idr_init(private); - if (private->idtree_fnum == NULL) { - return NT_STATUS_NO_MEMORY; - } + NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); + + /* setup the DCERPC server subsystem */ + status = dcesrv_init_context(private, &private->dcesrv); + NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; } @@ -226,7 +230,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, session_info = req->session->session_info; } - status = dcesrv_endpoint_search_connect(req->smb_conn->dcesrv, + status = dcesrv_endpoint_search_connect(private->dcesrv, &ep_description, session_info, &p->dce_conn); -- cgit From fae215266b6711b24f4893653b146751885e4e5f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jan 2005 16:53:02 +0000 Subject: r4690: - add support for async rpc server replies the backend should check for (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_MAY_ASYNC) then it's allowed to reply async then the backend should mark that call as async with dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC; later it has to manualy set r->out.result and then send the reply by calling status = dcesrv_reply(p->dce_call); NOTE: that ncacn_np doesn't support async replies yet - implement an async version of echo_TestSleep - reenable the echo_TestSleep torture test (this need to be more strict when we have support for async ncacn_np) metze (This used to be commit f0a0dbeb25b034b1333078ca085999359f5f6209) --- source4/ntvfs/ipc/vfs_ipc.c | 49 ++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2a19de1ec0..402d1ead64 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -3,7 +3,7 @@ default IPC$ NTVFS backend Copyright (C) Andrew Tridgell 2003 - Copyright (C) Stefan (metze) Metzmacher 2004 + Copyright (C) Stefan (metze) Metzmacher 2004-2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -94,7 +94,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); /* setup the DCERPC server subsystem */ - status = dcesrv_init_context(private, &private->dcesrv); + status = dcesrv_init_ipc_context(private, &private->dcesrv); NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; @@ -106,13 +106,6 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs, struct smbsrv_tcon *tcon) { - struct ipc_private *private = ntvfs->private_data; - - /* close any pipes that are open. Discard any unread data */ - while (private->pipe_list) { - talloc_free(private->pipe_list); - } - return NT_STATUS_OK; } @@ -171,7 +164,6 @@ static int ipc_fd_destructor(void *ptr) struct pipe_state *p = ptr; idr_remove(p->private->idtree_fnum, p->fnum); DLIST_REMOVE(p->private->pipe_list, p); - talloc_free(p->dce_conn); return 0; } @@ -186,21 +178,21 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct pipe_state *p; NTSTATUS status; struct dcerpc_binding ep_description; - struct auth_session_info *session_info = NULL; struct ipc_private *private = ntvfs->private_data; int fnum; + struct server_connection *srv_conn; - p = talloc_p(req, struct pipe_state); - if (!p) { - return NT_STATUS_NO_MEMORY; + if (!req->session || !req->session->session_info) { + return NT_STATUS_ACCESS_DENIED; } + p = talloc(req, struct pipe_state); + NT_STATUS_HAVE_NO_MEMORY(p); + while (fname[0] == '\\') fname++; p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); - if (!p->pipe_name) { - return NT_STATUS_NO_MEMORY; - } + NT_STATUS_HAVE_NO_MEMORY(p->pipe_name); fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX); if (fnum == -1) { @@ -215,24 +207,23 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, endpoint. At this stage the pipe isn't bound, so we don't know what interface the user actually wants, just that they want one of the interfaces attached to this pipe endpoint. - - TODO: note that we aren't passing any credentials here. We - will need to do that once the credentials infrastructure is - finalised for Samba4 */ ep_description.transport = NCACN_NP; ep_description.endpoint = p->pipe_name; - /* tell the RPC layer the session_info */ - if (req->session) { - /* The session info is refcount-increased in the - dcesrv_endpoint_search_connect() function */ - session_info = req->session->session_info; - } + /* TOTO: pass in full server_connection in here */ + srv_conn = talloc_zero(p, struct server_connection); + NT_STATUS_HAVE_NO_MEMORY(srv_conn); + srv_conn->event.ctx = talloc_reference(srv_conn, req->smb_conn->connection->event.ctx); - status = dcesrv_endpoint_search_connect(private->dcesrv, + /* The session info is refcount-increased in the + * dcesrv_endpoint_search_connect() function + */ + status = dcesrv_endpoint_search_connect(private->dcesrv, + p, &ep_description, - session_info, + req->session->session_info, + srv_conn, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { idr_remove(private->idtree_fnum, p->fnum); -- cgit From 55d4d36993293fee914a009f1d8f05810e347f2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Jan 2005 00:54:57 +0000 Subject: r5102: This is a major simplification of the logic for controlling top level servers in smbd. The old code still contained a fairly bit of legacy from the time when smbd was only handling SMB connection. The new code gets rid of all of the smb_server specific code in smbd/, and creates a much simpler infrastructures for new server code. Major changes include: - simplified the process model code a lot. - got rid of the top level server and service structures completely. The top level context is now the event_context. This got rid of service.h and server.h completely (they were the most confusing parts of the old code) - added service_stream.[ch] for the helper functions that are specific to stream type services (services that handle streams, and use a logically separate process per connection) - got rid of the builtin idle_handler code in the service logic, as none of the servers were using it, and it can easily be handled by a server in future by adding its own timed_event to the event context. - fixed some major memory leaks in the rpc server code. - added registration of servers, rather than hard coding our list of possible servers. This allows for servers as modules in the future. - temporarily disabled the winbind code until I add the helper functions for that type of server - added error checking on service startup. If a configured server fails to startup then smbd doesn't startup. - cleaned up the command line handling in smbd, removing unused options (This used to be commit cf6a46c3cbde7b1eb1b86bd3882b953a2de3a42e) --- source4/ntvfs/ipc/vfs_ipc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 402d1ead64..04a1a06db3 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -180,7 +180,7 @@ 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 server_connection *srv_conn; + struct stream_connection *srv_conn = req->smb_conn->connection; if (!req->session || !req->session->session_info) { return NT_STATUS_ACCESS_DENIED; @@ -211,11 +211,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, ep_description.transport = NCACN_NP; ep_description.endpoint = p->pipe_name; - /* TOTO: pass in full server_connection in here */ - srv_conn = talloc_zero(p, struct server_connection); - NT_STATUS_HAVE_NO_MEMORY(srv_conn); - srv_conn->event.ctx = talloc_reference(srv_conn, req->smb_conn->connection->event.ctx); - /* The session info is refcount-increased in the * dcesrv_endpoint_search_connect() function */ -- cgit From 218f289ed75e9e10feadb92fbbb41e69025ab010 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 Feb 2005 11:35:38 +0000 Subject: r5501: check the return of talloc with the NT_STATUS_HAVE_NO_MEMORY() macro... metze (This used to be commit 9ec6c0e97765e60ef195296f17d6a27b5d0dcca9) --- source4/ntvfs/ipc/vfs_ipc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 04a1a06db3..abb4c51f65 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -80,7 +80,10 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct ipc_private *private; tcon->fs_type = talloc_strdup(tcon, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(tcon->fs_type); + tcon->dev_type = talloc_strdup(tcon, "IPC"); + NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); /* prepare the private state for this connection */ private = talloc(tcon, struct ipc_private); -- cgit From df643022136a4b229aca817f5b57f7302a97f852 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 19 Mar 2005 08:34:43 +0000 Subject: r5902: A rather large change... I wanted to add a simple 'workstation' argument to the DCERPC authenticated binding calls, but this patch kind of grew from there. With SCHANNEL, the 'workstation' name (the netbios name of the client) matters, as this is what ties the session between the NETLOGON ops and the SCHANNEL bind. This changes a lot of files, and these will again be changed when jelmer does the credentials work. I also correct some schannel IDL to distinguish between workstation names and account names. The distinction matters for domain trust accounts. Issues in handling this (issues with lifetime of talloc pointers) caused me to change the 'creds_CredentialsState' and 'struct dcerpc_binding' pointers to always be talloc()ed pointers. In the schannel DB, we now store both the domain and computername, and query on both. This should ensure we fault correctly when the domain is specified incorrectly in the SCHANNEL bind. In the RPC-SCHANNEL test, I finally fixed a bug that vl pointed out, where the comment claimed we re-used a connection, but in fact we made a new connection. This was achived by breaking apart some of the dcerpc_secondary_connection() logic. The addition of workstation handling was also propogated to NTLMSSP and GENSEC, for completeness. The RPC-SAMSYNC test has been cleaned up a little, using a loop over usernames/passwords rather than manually expanded tests. This will be expanded further (the code in #if 0 in this patch) to use a newly created user account for testing. In making this test pass test_rpc.sh, I found a bug in the RPC-ECHO server, caused by the removal of [ref] and the assoicated pointer from the IDL. This has been re-added, until the underlying pidl issues are solved. (This used to be commit 824289dcc20908ddec957a4a892a103eec2da9b9) --- source4/ntvfs/ipc/vfs_ipc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index abb4c51f65..68c59b7502 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -180,7 +180,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, { struct pipe_state *p; NTSTATUS status; - struct dcerpc_binding ep_description; + struct dcerpc_binding *ep_description; struct ipc_private *private = ntvfs->private_data; int fnum; struct stream_connection *srv_conn = req->smb_conn->connection; @@ -192,6 +192,9 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p = talloc(req, struct pipe_state); NT_STATUS_HAVE_NO_MEMORY(p); + ep_description = talloc(req, struct dcerpc_binding); + NT_STATUS_HAVE_NO_MEMORY(ep_description); + while (fname[0] == '\\') fname++; p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); @@ -211,15 +214,15 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, know what interface the user actually wants, just that they want one of the interfaces attached to this pipe endpoint. */ - ep_description.transport = NCACN_NP; - ep_description.endpoint = p->pipe_name; + ep_description->transport = NCACN_NP; + ep_description->endpoint = talloc_reference(ep_description, p->pipe_name); /* The session info is refcount-increased in the * dcesrv_endpoint_search_connect() function */ status = dcesrv_endpoint_search_connect(private->dcesrv, p, - &ep_description, + ep_description, req->session->session_info, srv_conn, &p->dce_conn); -- cgit From 8a300c9248cc956d2aaed59e89efc2535a9f60f5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 30 Jun 2005 17:10:03 +0000 Subject: r8021: we only need to return STATUS_BUFFER_OVERFLOW for the ipc_trans replies and not for the ipc_read() replies as here the client explicit says how much data it wants the write_fn() in dcesrv_output() now returns NTSTATUS and the ipc specific implementations are moved to the ntvfs_ipc module metze (This used to be commit fe483dcd874b7243d61e9623840c672b4ea06b2c) --- source4/ntvfs/ipc/vfs_ipc.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 68c59b7502..2c148fbd0c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -350,6 +350,18 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } +static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +{ + DATA_BLOB *blob = private_data; + + if (out->length < blob->length) { + blob->length = out->length; + } + memcpy(blob->data, out->data, blob->length); + *nwritten = blob->length; + return NT_STATUS_OK; +} + /* read from a file */ @@ -380,7 +392,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, } if (data.length != 0) { - status = dcesrv_output_blob(p->dce_conn, &data); + status = dcesrv_output(p->dce_conn, &data, ipc_readx_dcesrv_output); if (NT_STATUS_IS_ERR(status)) { return status; } @@ -604,6 +616,22 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } +static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +{ + NTSTATUS status = NT_STATUS_OK; + DATA_BLOB *blob = private_data; + + if (out->length > blob->length) { + status = STATUS_BUFFER_OVERFLOW; + } + + if (out->length < blob->length) { + blob->length = out->length; + } + memcpy(blob->data, out->data, blob->length); + *nwritten = blob->length; + return status; +} /* SMBtrans - handle a DCERPC command */ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, @@ -638,7 +666,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, async calls. Again, we only expect NT_STATUS_OK. If the call fails then the error is encoded at the dcerpc level */ - status = dcesrv_output_blob(p->dce_conn, &trans->out.data); + status = dcesrv_output(p->dce_conn, &trans->out.data, ipc_trans_dcesrv_output); if (NT_STATUS_IS_ERR(status)) { return status; } -- cgit From 4e2ac8b458181b0eaf858a30e98aa7109e80d9d2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 30 Jun 2005 19:25:55 +0000 Subject: r8024: avoid one memcpy in the ipc_trans dcesrv_output() callback we now can reference the DATA_BLOB that is used inside the dcesrv subsystem metze (This used to be commit 078f42bc3f74c66b69c7f76005812b221d691f7a) --- source4/ntvfs/ipc/vfs_ipc.c | 71 ++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 30 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2c148fbd0c..1be877d7ec 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -350,14 +350,14 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *output, size_t *nwritten) { DATA_BLOB *blob = private_data; - if (out->length < blob->length) { - blob->length = out->length; + if (output->length < blob->length) { + blob->length = output->length; } - memcpy(blob->data, out->data, blob->length); + memcpy(blob->data, output->data, blob->length); *nwritten = blob->length; return NT_STATUS_OK; } @@ -616,20 +616,33 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +struct ipctp_dcesrv_output { + struct smbsrv_request *req; + struct smb_trans2 *trans; +}; +static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *_output, size_t *nwritten) { NTSTATUS status = NT_STATUS_OK; - DATA_BLOB *blob = private_data; + DATA_BLOB *output; + struct ipctp_dcesrv_output *ipctp = private_data; + + /* + * do it the fast way without doing an extra memcpy() + * + * we need to reference the the DATA_BLOB itself, + * because out->data isn't always a valid talloc pointer + */ + output = talloc_reference(ipctp->req, _output); + NT_STATUS_HAVE_NO_MEMORY(output); - if (out->length > blob->length) { + if (output->length > ipctp->trans->in.max_data) { status = STATUS_BUFFER_OVERFLOW; } - if (out->length < blob->length) { - blob->length = out->length; - } - memcpy(blob->data, out->data, blob->length); - *nwritten = blob->length; + ipctp->trans->out.data.data = output->data; + ipctp->trans->out.data.length = MIN(ipctp->trans->in.max_data, output->length); + + *nwritten = ipctp->trans->out.data.length; return status; } @@ -638,38 +651,36 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipcp = ntvfs->private_data; + struct ipctp_dcesrv_output ipctp; NTSTATUS status; /* the fnum is in setup[1] */ - p = pipe_state_find(private, trans->in.setup[1]); - if (!p) { - return NT_STATUS_INVALID_HANDLE; - } + p = pipe_state_find(ipcp, trans->in.setup[1]); + if (!p) return NT_STATUS_INVALID_HANDLE; - trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); - if (!trans->out.data.data) { - return NT_STATUS_NO_MEMORY; - } + /* + * just to be sure we doesn't have something uninitialized + * the real work is done in the dcesrv_output() callback + */ + trans->out.data = data_blob(NULL, 0); /* pass the data to the dcerpc server. Note that we don't expect this to fail, and things like NDR faults are not reported at this stage. Those sorts of errors happen in the dcesrv_output stage */ status = dcesrv_input(p->dce_conn, &trans->in.data); - if (!NT_STATUS_IS_OK(status)) { - return status; - } + NT_STATUS_NOT_OK_RETURN(status); /* now ask the dcerpc system for some output. This doesn't yet handle - async calls. Again, we only expect NT_STATUS_OK. If the call fails then - the error is encoded at the dcerpc level + async calls. Again, we only expect NT_STATUS_OK or STATUS_BUFFER_OVERFLOW. + If the call fails then the error is encoded at the dcerpc level */ - status = dcesrv_output(p->dce_conn, &trans->out.data, ipc_trans_dcesrv_output); - if (NT_STATUS_IS_ERR(status)) { - return status; - } + ipctp.req = req; + ipctp.trans = trans; + status = dcesrv_output(p->dce_conn, &ipctp, ipc_trans_dcesrv_output); + NT_STATUS_IS_ERR_RETURN(status); trans->out.setup_count = 0; trans->out.setup = NULL; -- cgit From 8ab3f59a10d00357cb129a2051fd0f694b5c8081 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Jul 2005 06:05:49 +0000 Subject: r8036: revert rev 8023/8024 as they have a bugs. metze (This used to be commit 66d6b1d5783cba98f2f8e1c8eed1bdc26a5bad4f) --- source4/ntvfs/ipc/vfs_ipc.c | 71 +++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 1be877d7ec..2c148fbd0c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -350,14 +350,14 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *output, size_t *nwritten) +static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) { DATA_BLOB *blob = private_data; - if (output->length < blob->length) { - blob->length = output->length; + if (out->length < blob->length) { + blob->length = out->length; } - memcpy(blob->data, output->data, blob->length); + memcpy(blob->data, out->data, blob->length); *nwritten = blob->length; return NT_STATUS_OK; } @@ -616,33 +616,20 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -struct ipctp_dcesrv_output { - struct smbsrv_request *req; - struct smb_trans2 *trans; -}; -static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *_output, size_t *nwritten) +static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) { NTSTATUS status = NT_STATUS_OK; - DATA_BLOB *output; - struct ipctp_dcesrv_output *ipctp = private_data; - - /* - * do it the fast way without doing an extra memcpy() - * - * we need to reference the the DATA_BLOB itself, - * because out->data isn't always a valid talloc pointer - */ - output = talloc_reference(ipctp->req, _output); - NT_STATUS_HAVE_NO_MEMORY(output); + DATA_BLOB *blob = private_data; - if (output->length > ipctp->trans->in.max_data) { + if (out->length > blob->length) { status = STATUS_BUFFER_OVERFLOW; } - ipctp->trans->out.data.data = output->data; - ipctp->trans->out.data.length = MIN(ipctp->trans->in.max_data, output->length); - - *nwritten = ipctp->trans->out.data.length; + if (out->length < blob->length) { + blob->length = out->length; + } + memcpy(blob->data, out->data, blob->length); + *nwritten = blob->length; return status; } @@ -651,36 +638,38 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *ipcp = ntvfs->private_data; - struct ipctp_dcesrv_output ipctp; + struct ipc_private *private = ntvfs->private_data; NTSTATUS status; /* the fnum is in setup[1] */ - p = pipe_state_find(ipcp, trans->in.setup[1]); - if (!p) return NT_STATUS_INVALID_HANDLE; + p = pipe_state_find(private, trans->in.setup[1]); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } - /* - * just to be sure we doesn't have something uninitialized - * the real work is done in the dcesrv_output() callback - */ - trans->out.data = data_blob(NULL, 0); + trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); + if (!trans->out.data.data) { + return NT_STATUS_NO_MEMORY; + } /* pass the data to the dcerpc server. Note that we don't expect this to fail, and things like NDR faults are not reported at this stage. Those sorts of errors happen in the dcesrv_output stage */ status = dcesrv_input(p->dce_conn, &trans->in.data); - NT_STATUS_NOT_OK_RETURN(status); + if (!NT_STATUS_IS_OK(status)) { + return status; + } /* now ask the dcerpc system for some output. This doesn't yet handle - async calls. Again, we only expect NT_STATUS_OK or STATUS_BUFFER_OVERFLOW. - If the call fails then the error is encoded at the dcerpc level + async calls. Again, we only expect NT_STATUS_OK. If the call fails then + the error is encoded at the dcerpc level */ - ipctp.req = req; - ipctp.trans = trans; - status = dcesrv_output(p->dce_conn, &ipctp, ipc_trans_dcesrv_output); - NT_STATUS_IS_ERR_RETURN(status); + status = dcesrv_output(p->dce_conn, &trans->out.data, ipc_trans_dcesrv_output); + if (NT_STATUS_IS_ERR(status)) { + return status; + } trans->out.setup_count = 0; trans->out.setup = NULL; -- cgit From e987658582b4c726c461bfb0230ec2db53a032d2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 23 Aug 2005 13:03:39 +0000 Subject: r9517: fix compiler warning: status.v initialized variable used in line 375 tridge: what should be the correct error code? see rev 3239! metze (This used to be commit 27ec849718b97df2d6f30e2fbacaa0423e918862) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2c148fbd0c..aa0909ceb6 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -372,7 +372,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, DATA_BLOB data; uint16_t fnum; struct pipe_state *p; - NTSTATUS status; + NTSTATUS status = NT_STATUS_FOOBAR; if (rd->generic.level != RAW_READ_GENERIC) { return ntvfs_map_read(req, rd, ntvfs); -- cgit From 89e550ba34d1f00b576aae3d4683ca9ca36afe80 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 30 Aug 2005 12:51:05 +0000 Subject: r9794: r11627@blu: tridge | 2005-08-30 22:55:27 +1000 fill in correct error code for zero length and too large IPC reads (This used to be commit bf6558b8971ccda080d463753ddae977967e7093) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index aa0909ceb6..3f91323fe5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -372,7 +372,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, DATA_BLOB data; uint16_t fnum; struct pipe_state *p; - NTSTATUS status = NT_STATUS_FOOBAR; + NTSTATUS status = NT_STATUS_OK; if (rd->generic.level != RAW_READ_GENERIC) { return ntvfs_map_read(req, rd, ntvfs); @@ -388,7 +388,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, data.length = rd->readx.in.maxcnt; data.data = rd->readx.out.data; if (data.length > UINT16_MAX) { - data.length = 0; + data.length = UINT16_MAX; } if (data.length != 0) { -- cgit From 0a3c167f6bcf08b2204ca49831ca49eef73dcbf4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 22:51:30 +0000 Subject: r12528: Add seperate proto headers for ntvfs, tdr, smb_server and nbt_server. (This used to be commit 87f665a1d5ba74289974bf9d8f9441c162e6f1b1) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 3f91323fe5..3a643d7145 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -29,6 +29,7 @@ #include "system/filesys.h" #include "dlinklist.h" #include "smb_server/smb_server.h" +#include "ntvfs/ntvfs.h" #define IPC_BASE_FNUM 0x400 -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 3a643d7145..415d09a729 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -30,6 +30,7 @@ #include "dlinklist.h" #include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" +#include "rpc_server/dcerpc_server.h" #define IPC_BASE_FNUM 0x400 -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/ntvfs/ipc/vfs_ipc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 415d09a729..7eb9250eb2 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -26,7 +26,6 @@ #include "includes.h" -#include "system/filesys.h" #include "dlinklist.h" #include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" -- cgit From 5497dfe64ad810a2a3fb22da6869d311894bfed0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 25 Jan 2006 12:19:49 +0000 Subject: r13129: fix the memory hierachie metze (This used to be commit 19205b8d89d3d7e99a65938f59412e0c4e8ac5fe) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7eb9250eb2..dd7994c1fb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -87,7 +87,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(tcon->dev_type); /* prepare the private state for this connection */ - private = talloc(tcon, struct ipc_private); + private = talloc(ntvfs, struct ipc_private); NT_STATUS_HAVE_NO_MEMORY(private); ntvfs->private_data = private; -- cgit From ad6303f82fa862111c239b32b39f299e563a0802 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 28 Jan 2006 12:58:38 +0000 Subject: r13208: Clearly separate named pipes from the IPC$ NTVFS type. This allows the easy addition of additional named pipes and removes the circular dependencies between the CIFS, RPC and RAP servers. Simple tests for a custom named pipe included. (This used to be commit 898d15acbd18e3b302a856c847e08c22c5024792) --- source4/ntvfs/ipc/vfs_ipc.c | 243 ++++++++++++++++++++++---------------------- 1 file changed, 122 insertions(+), 121 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index dd7994c1fb..bde87684e1 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -4,6 +4,7 @@ Copyright (C) Andrew Tridgell 2003 Copyright (C) Stefan (metze) Metzmacher 2004-2005 + Copyright (C) Jelmer Vernooij 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +29,10 @@ #include "includes.h" #include "dlinklist.h" #include "smb_server/smb_server.h" +#include "ntvfs/ipc/ipc.h" #include "ntvfs/ntvfs.h" #include "rpc_server/dcerpc_server.h" +#include "smb_build.h" #define IPC_BASE_FNUM 0x400 @@ -46,8 +49,9 @@ struct ipc_private { struct pipe_state *next, *prev; struct ipc_private *private; const char *pipe_name; + const struct named_pipe_ops *ops; + void *private_data; uint16_t fnum; - struct dcesrv_connection *dce_conn; uint16_t ipc_state; /* we need to remember the session it was opened on, as it is illegal to operate on someone elses fnum */ @@ -76,7 +80,6 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, const char *sharename) { - NTSTATUS status; struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -97,10 +100,6 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, private->idtree_fnum = idr_init(private); NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); - /* setup the DCERPC server subsystem */ - status = dcesrv_init_ipc_context(private, &private->dcesrv); - NT_STATUS_NOT_OK_RETURN(status); - return NT_STATUS_OK; } @@ -171,6 +170,55 @@ static int ipc_fd_destructor(void *ptr) return 0; } +static struct named_pipe { + struct named_pipe *prev, *next; + const char *name; + const struct named_pipe_ops *ops; + void *context_data; +} *named_pipes = NULL; + +static NTSTATUS find_pipe_ops(const char *fname, const struct named_pipe_ops **ops, void **context_data) +{ + struct named_pipe *np; + + for (np = named_pipes; np; np = np->next) { + if (strcasecmp_m(np->name, fname) == 0) { + if (ops) *ops = np->ops; + if (context_data) *context_data = np->context_data; + return NT_STATUS_OK; + } + } + + return NT_STATUS_OBJECT_NAME_NOT_FOUND; +} + +NTSTATUS named_pipe_listen(const char *name, const struct named_pipe_ops *ops, void *context_data) +{ + NTSTATUS status; + struct named_pipe *np; + DEBUG(3, ("Registering named pipe `%s'\n", name)); + + status = find_pipe_ops(name, NULL, NULL); + if (NT_STATUS_IS_OK(status)) { + return NT_STATUS_OBJECT_NAME_COLLISION; + } + + if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + return status; + } + + np = talloc(talloc_autofree_context(), struct named_pipe); + np->name = talloc_strdup(np, name); + np->ops = ops; + np->context_data = context_data; + np->prev = np->next = NULL; + + DLIST_ADD(named_pipes, np); + + return NT_STATUS_OK; +} + + /* open a file backend - used for MSRPC pipes @@ -181,10 +229,9 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, { struct pipe_state *p; NTSTATUS status; - struct dcerpc_binding *ep_description; struct ipc_private *private = ntvfs->private_data; + void *context_data; int fnum; - struct stream_connection *srv_conn = req->smb_conn->connection; if (!req->session || !req->session->session_info) { return NT_STATUS_ACCESS_DENIED; @@ -193,14 +240,24 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p = talloc(req, struct pipe_state); NT_STATUS_HAVE_NO_MEMORY(p); - ep_description = talloc(req, struct dcerpc_binding); - NT_STATUS_HAVE_NO_MEMORY(ep_description); - while (fname[0] == '\\') fname++; - + p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); NT_STATUS_HAVE_NO_MEMORY(p->pipe_name); + status = find_pipe_ops(p->pipe_name, &p->ops, &context_data); + + /* FIXME: Perhaps fall back to opening /var/lib/samba/ipc/ ? */ + if (NT_STATUS_IS_ERR(status)) { + DEBUG(0, ("Unable to find pipe ops for `%s'\n", p->pipe_name)); + return status; + } + + status = p->ops->open(context_data, p->pipe_name, req->session->session_info, req->smb_conn->connection, p, &p->private_data); + if (NT_STATUS_IS_ERR(status)) { + return status; + } + fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX); if (fnum == -1) { return NT_STATUS_TOO_MANY_OPENED_FILES; @@ -209,29 +266,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p->fnum = fnum; p->ipc_state = 0x5ff; - /* - we're all set, now ask the dcerpc server subsystem to open the - endpoint. At this stage the pipe isn't bound, so we don't - know what interface the user actually wants, just that they want - one of the interfaces attached to this pipe endpoint. - */ - ep_description->transport = NCACN_NP; - ep_description->endpoint = talloc_reference(ep_description, p->pipe_name); - - /* The session info is refcount-increased in the - * dcesrv_endpoint_search_connect() function - */ - status = dcesrv_endpoint_search_connect(private->dcesrv, - p, - ep_description, - req->session->session_info, - srv_conn, - &p->dce_conn); - if (!NT_STATUS_IS_OK(status)) { - idr_remove(private->idtree_fnum, p->fnum); - return status; - } - DLIST_ADD(private->pipe_list, p); p->smbpid = req->smbpid; @@ -351,18 +385,6 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) -{ - DATA_BLOB *blob = private_data; - - if (out->length < blob->length) { - blob->length = out->length; - } - memcpy(blob->data, out->data, blob->length); - *nwritten = blob->length; - return NT_STATUS_OK; -} - /* read from a file */ @@ -393,7 +415,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, } if (data.length != 0) { - status = dcesrv_output(p->dce_conn, &data, ipc_readx_dcesrv_output); + status = p->ops->read(p->private_data, &data); if (NT_STATUS_IS_ERR(status)) { return status; } @@ -431,7 +453,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - status = dcesrv_input(p->dce_conn, &data); + status = p->ops->write(p->private_data, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -617,30 +639,12 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) -{ - NTSTATUS status = NT_STATUS_OK; - DATA_BLOB *blob = private_data; - - if (out->length > blob->length) { - status = STATUS_BUFFER_OVERFLOW; - } - - if (out->length < blob->length) { - blob->length = out->length; - } - memcpy(blob->data, out->data, blob->length); - *nwritten = blob->length; - return status; -} - -/* SMBtrans - handle a DCERPC command */ -static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_trans2 *trans) +/* SMBtrans - set named pipe state */ +static NTSTATUS ipc_np_set_nm_state(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_trans2 *trans) { - struct pipe_state *p; struct ipc_private *private = ntvfs->private_data; - NTSTATUS status; + struct pipe_state *p; /* the fnum is in setup[1] */ p = pipe_state_find(private, trans->in.setup[1]); @@ -648,43 +652,25 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); - if (!trans->out.data.data) { - return NT_STATUS_NO_MEMORY; - } - - /* pass the data to the dcerpc server. Note that we don't - expect this to fail, and things like NDR faults are not - reported at this stage. Those sorts of errors happen in the - dcesrv_output stage */ - status = dcesrv_input(p->dce_conn, &trans->in.data); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - /* - now ask the dcerpc system for some output. This doesn't yet handle - async calls. Again, we only expect NT_STATUS_OK. If the call fails then - the error is encoded at the dcerpc level - */ - status = dcesrv_output(p->dce_conn, &trans->out.data, ipc_trans_dcesrv_output); - if (NT_STATUS_IS_ERR(status)) { - return status; + if (trans->in.params.length != 2) { + return NT_STATUS_INVALID_PARAMETER; } + p->ipc_state = SVAL(trans->in.params.data, 0); trans->out.setup_count = 0; trans->out.setup = NULL; trans->out.params = data_blob(NULL, 0); + trans->out.data = data_blob(NULL, 0); - return status; + return NT_STATUS_OK; } - -/* SMBtrans - set named pipe state */ -static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, +/* SMBtrans - named pipe transaction */ +static NTSTATUS ipc_np_trans(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { struct ipc_private *private = ntvfs->private_data; + NTSTATUS status; struct pipe_state *p; /* the fnum is in setup[1] */ @@ -693,50 +679,55 @@ static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - if (trans->in.params.length != 2) { + if (trans->in.setup_count != 2) { return NT_STATUS_INVALID_PARAMETER; } - p->ipc_state = SVAL(trans->in.params.data, 0); + + trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); + if (!trans->out.data.data) { + return NT_STATUS_NO_MEMORY; + } + + status = p->ops->trans(p->private_data, &trans->in.data, &trans->out.data); + if (NT_STATUS_IS_ERR(status)) { + return status; + } trans->out.setup_count = 0; trans->out.setup = NULL; trans->out.params = data_blob(NULL, 0); - trans->out.data = data_blob(NULL, 0); return NT_STATUS_OK; } - /* SMBtrans - used to provide access to SMB pipes */ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { NTSTATUS status; - if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) - return ipc_rap_call(req, trans); - - if (trans->in.setup_count != 2) { - return NT_STATUS_INVALID_PARAMETER; - } - - switch (trans->in.setup[0]) { - case TRANSACT_SETNAMEDPIPEHANDLESTATE: - status = ipc_set_nm_pipe_state(ntvfs, req, trans); - break; - case TRANSACT_DCERPCCMD: - status = ipc_dcerpc_cmd(ntvfs, req, trans); - break; - default: - status = NT_STATUS_INVALID_PARAMETER; - break; + if (strequal(trans->in.trans_name, "\\PIPE\\")) { /* Named pipe */ + switch (trans->in.setup[0]) { + case NAMED_PIPE_SETHANDLESTATE: + status = ipc_np_set_nm_state(ntvfs, req, trans); + break; + case NAMED_PIPE_TRANSACT: + status = ipc_np_trans(ntvfs, req, trans); + break; + default: + status = NT_STATUS_INVALID_PARAMETER; + break; + } + } else if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) { /* RAP */ + status = ipc_rap_call(req, trans); + } else { + DEBUG(1, ("Unknown transaction name `%s'\n", trans->in.trans_name)); + status = NT_STATUS_NOT_SUPPORTED; } return status; } - - /* initialialise the IPC backend, registering ourselves with the ntvfs subsystem */ @@ -744,7 +735,9 @@ NTSTATUS ntvfs_ipc_init(void) { NTSTATUS ret; struct ntvfs_ops ops; - + init_module_fn static_init[] = STATIC_ntvfs_ipc_MODULES; + init_module_fn *shared_init; + ZERO_STRUCT(ops); /* fill in the name and type */ @@ -791,5 +784,13 @@ NTSTATUS ntvfs_ipc_init(void) return ret; } + /* load available named pipe backends */ + shared_init = load_samba_modules(NULL, "np"); + + run_init_functions(static_init); + run_init_functions(shared_init); + + talloc_free(shared_init); + return ret; } -- cgit From 713b296441ec8b1447a0bc451720a8b84fd7e1fc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 28 Jan 2006 20:08:03 +0000 Subject: r13210: Revert my named pipes patch until it passes not just 'make quicktest' but also 'make test' (This used to be commit e3d0676aee84e96e5c87bed4cd0cde75a4191953) --- source4/ntvfs/ipc/vfs_ipc.c | 243 ++++++++++++++++++++++---------------------- 1 file changed, 121 insertions(+), 122 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index bde87684e1..dd7994c1fb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -4,7 +4,6 @@ Copyright (C) Andrew Tridgell 2003 Copyright (C) Stefan (metze) Metzmacher 2004-2005 - Copyright (C) Jelmer Vernooij 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,10 +28,8 @@ #include "includes.h" #include "dlinklist.h" #include "smb_server/smb_server.h" -#include "ntvfs/ipc/ipc.h" #include "ntvfs/ntvfs.h" #include "rpc_server/dcerpc_server.h" -#include "smb_build.h" #define IPC_BASE_FNUM 0x400 @@ -49,9 +46,8 @@ struct ipc_private { struct pipe_state *next, *prev; struct ipc_private *private; const char *pipe_name; - const struct named_pipe_ops *ops; - void *private_data; uint16_t fnum; + struct dcesrv_connection *dce_conn; uint16_t ipc_state; /* we need to remember the session it was opened on, as it is illegal to operate on someone elses fnum */ @@ -80,6 +76,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, const char *sharename) { + NTSTATUS status; struct smbsrv_tcon *tcon = req->tcon; struct ipc_private *private; @@ -100,6 +97,10 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, private->idtree_fnum = idr_init(private); NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); + /* setup the DCERPC server subsystem */ + status = dcesrv_init_ipc_context(private, &private->dcesrv); + NT_STATUS_NOT_OK_RETURN(status); + return NT_STATUS_OK; } @@ -170,55 +171,6 @@ static int ipc_fd_destructor(void *ptr) return 0; } -static struct named_pipe { - struct named_pipe *prev, *next; - const char *name; - const struct named_pipe_ops *ops; - void *context_data; -} *named_pipes = NULL; - -static NTSTATUS find_pipe_ops(const char *fname, const struct named_pipe_ops **ops, void **context_data) -{ - struct named_pipe *np; - - for (np = named_pipes; np; np = np->next) { - if (strcasecmp_m(np->name, fname) == 0) { - if (ops) *ops = np->ops; - if (context_data) *context_data = np->context_data; - return NT_STATUS_OK; - } - } - - return NT_STATUS_OBJECT_NAME_NOT_FOUND; -} - -NTSTATUS named_pipe_listen(const char *name, const struct named_pipe_ops *ops, void *context_data) -{ - NTSTATUS status; - struct named_pipe *np; - DEBUG(3, ("Registering named pipe `%s'\n", name)); - - status = find_pipe_ops(name, NULL, NULL); - if (NT_STATUS_IS_OK(status)) { - return NT_STATUS_OBJECT_NAME_COLLISION; - } - - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - return status; - } - - np = talloc(talloc_autofree_context(), struct named_pipe); - np->name = talloc_strdup(np, name); - np->ops = ops; - np->context_data = context_data; - np->prev = np->next = NULL; - - DLIST_ADD(named_pipes, np); - - return NT_STATUS_OK; -} - - /* open a file backend - used for MSRPC pipes @@ -229,9 +181,10 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, { struct pipe_state *p; NTSTATUS status; + struct dcerpc_binding *ep_description; struct ipc_private *private = ntvfs->private_data; - void *context_data; int fnum; + struct stream_connection *srv_conn = req->smb_conn->connection; if (!req->session || !req->session->session_info) { return NT_STATUS_ACCESS_DENIED; @@ -240,24 +193,14 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p = talloc(req, struct pipe_state); NT_STATUS_HAVE_NO_MEMORY(p); + ep_description = talloc(req, struct dcerpc_binding); + NT_STATUS_HAVE_NO_MEMORY(ep_description); + while (fname[0] == '\\') fname++; - + p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); NT_STATUS_HAVE_NO_MEMORY(p->pipe_name); - status = find_pipe_ops(p->pipe_name, &p->ops, &context_data); - - /* FIXME: Perhaps fall back to opening /var/lib/samba/ipc/ ? */ - if (NT_STATUS_IS_ERR(status)) { - DEBUG(0, ("Unable to find pipe ops for `%s'\n", p->pipe_name)); - return status; - } - - status = p->ops->open(context_data, p->pipe_name, req->session->session_info, req->smb_conn->connection, p, &p->private_data); - if (NT_STATUS_IS_ERR(status)) { - return status; - } - fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX); if (fnum == -1) { return NT_STATUS_TOO_MANY_OPENED_FILES; @@ -266,6 +209,29 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p->fnum = fnum; p->ipc_state = 0x5ff; + /* + we're all set, now ask the dcerpc server subsystem to open the + endpoint. At this stage the pipe isn't bound, so we don't + know what interface the user actually wants, just that they want + one of the interfaces attached to this pipe endpoint. + */ + ep_description->transport = NCACN_NP; + ep_description->endpoint = talloc_reference(ep_description, p->pipe_name); + + /* The session info is refcount-increased in the + * dcesrv_endpoint_search_connect() function + */ + status = dcesrv_endpoint_search_connect(private->dcesrv, + p, + ep_description, + req->session->session_info, + srv_conn, + &p->dce_conn); + if (!NT_STATUS_IS_OK(status)) { + idr_remove(private->idtree_fnum, p->fnum); + return status; + } + DLIST_ADD(private->pipe_list, p); p->smbpid = req->smbpid; @@ -385,6 +351,18 @@ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } +static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +{ + DATA_BLOB *blob = private_data; + + if (out->length < blob->length) { + blob->length = out->length; + } + memcpy(blob->data, out->data, blob->length); + *nwritten = blob->length; + return NT_STATUS_OK; +} + /* read from a file */ @@ -415,7 +393,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, } if (data.length != 0) { - status = p->ops->read(p->private_data, &data); + status = dcesrv_output(p->dce_conn, &data, ipc_readx_dcesrv_output); if (NT_STATUS_IS_ERR(status)) { return status; } @@ -453,7 +431,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - status = p->ops->write(p->private_data, &data); + status = dcesrv_input(p->dce_conn, &data); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -639,12 +617,30 @@ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } -/* SMBtrans - set named pipe state */ -static NTSTATUS ipc_np_set_nm_state(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_trans2 *trans) +static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size_t *nwritten) +{ + NTSTATUS status = NT_STATUS_OK; + DATA_BLOB *blob = private_data; + + if (out->length > blob->length) { + status = STATUS_BUFFER_OVERFLOW; + } + + if (out->length < blob->length) { + blob->length = out->length; + } + memcpy(blob->data, out->data, blob->length); + *nwritten = blob->length; + return status; +} + +/* SMBtrans - handle a DCERPC command */ +static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, + struct smbsrv_request *req, struct smb_trans2 *trans) { - struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; + struct ipc_private *private = ntvfs->private_data; + NTSTATUS status; /* the fnum is in setup[1] */ p = pipe_state_find(private, trans->in.setup[1]); @@ -652,25 +648,43 @@ static NTSTATUS ipc_np_set_nm_state(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - if (trans->in.params.length != 2) { - return NT_STATUS_INVALID_PARAMETER; + trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); + if (!trans->out.data.data) { + return NT_STATUS_NO_MEMORY; + } + + /* pass the data to the dcerpc server. Note that we don't + expect this to fail, and things like NDR faults are not + reported at this stage. Those sorts of errors happen in the + dcesrv_output stage */ + status = dcesrv_input(p->dce_conn, &trans->in.data); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* + now ask the dcerpc system for some output. This doesn't yet handle + async calls. Again, we only expect NT_STATUS_OK. If the call fails then + the error is encoded at the dcerpc level + */ + status = dcesrv_output(p->dce_conn, &trans->out.data, ipc_trans_dcesrv_output); + if (NT_STATUS_IS_ERR(status)) { + return status; } - p->ipc_state = SVAL(trans->in.params.data, 0); trans->out.setup_count = 0; trans->out.setup = NULL; trans->out.params = data_blob(NULL, 0); - trans->out.data = data_blob(NULL, 0); - return NT_STATUS_OK; + return status; } -/* SMBtrans - named pipe transaction */ -static NTSTATUS ipc_np_trans(struct ntvfs_module_context *ntvfs, + +/* SMBtrans - set named pipe state */ +static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { struct ipc_private *private = ntvfs->private_data; - NTSTATUS status; struct pipe_state *p; /* the fnum is in setup[1] */ @@ -679,55 +693,50 @@ static NTSTATUS ipc_np_trans(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_HANDLE; } - if (trans->in.setup_count != 2) { + if (trans->in.params.length != 2) { return NT_STATUS_INVALID_PARAMETER; } - - trans->out.data = data_blob_talloc(req, NULL, trans->in.max_data); - if (!trans->out.data.data) { - return NT_STATUS_NO_MEMORY; - } - - status = p->ops->trans(p->private_data, &trans->in.data, &trans->out.data); - if (NT_STATUS_IS_ERR(status)) { - return status; - } + p->ipc_state = SVAL(trans->in.params.data, 0); trans->out.setup_count = 0; trans->out.setup = NULL; trans->out.params = data_blob(NULL, 0); + trans->out.data = data_blob(NULL, 0); return NT_STATUS_OK; } + /* SMBtrans - used to provide access to SMB pipes */ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, struct smbsrv_request *req, struct smb_trans2 *trans) { NTSTATUS status; - if (strequal(trans->in.trans_name, "\\PIPE\\")) { /* Named pipe */ - switch (trans->in.setup[0]) { - case NAMED_PIPE_SETHANDLESTATE: - status = ipc_np_set_nm_state(ntvfs, req, trans); - break; - case NAMED_PIPE_TRANSACT: - status = ipc_np_trans(ntvfs, req, trans); - break; - default: - status = NT_STATUS_INVALID_PARAMETER; - break; - } - } else if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) { /* RAP */ - status = ipc_rap_call(req, trans); - } else { - DEBUG(1, ("Unknown transaction name `%s'\n", trans->in.trans_name)); - status = NT_STATUS_NOT_SUPPORTED; + if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) + return ipc_rap_call(req, trans); + + if (trans->in.setup_count != 2) { + return NT_STATUS_INVALID_PARAMETER; + } + + switch (trans->in.setup[0]) { + case TRANSACT_SETNAMEDPIPEHANDLESTATE: + status = ipc_set_nm_pipe_state(ntvfs, req, trans); + break; + case TRANSACT_DCERPCCMD: + status = ipc_dcerpc_cmd(ntvfs, req, trans); + break; + default: + status = NT_STATUS_INVALID_PARAMETER; + break; } return status; } + + /* initialialise the IPC backend, registering ourselves with the ntvfs subsystem */ @@ -735,9 +744,7 @@ NTSTATUS ntvfs_ipc_init(void) { NTSTATUS ret; struct ntvfs_ops ops; - init_module_fn static_init[] = STATIC_ntvfs_ipc_MODULES; - init_module_fn *shared_init; - + ZERO_STRUCT(ops); /* fill in the name and type */ @@ -784,13 +791,5 @@ NTSTATUS ntvfs_ipc_init(void) return ret; } - /* load available named pipe backends */ - shared_init = load_samba_modules(NULL, "np"); - - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); - return ret; } -- cgit From ba564a901e519b0f2cf2b7651bd260f618506b5c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Mar 2006 23:28:18 +0000 Subject: r13903: Don't generate prototypes for modules and binaries in include/proto.h by default. (This used to be commit c80a8f1102caf744b66c13bebde38fba74983dc4) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index dd7994c1fb..d5259bc9a6 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -29,6 +29,7 @@ #include "dlinklist.h" #include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" +#include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" #define IPC_BASE_FNUM 0x400 -- cgit From 45c92c9cf08210e1d5792e2d8db93912727c3dba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 7 Mar 2006 11:02:47 +0000 Subject: r13923: make the state_flags per dcesrv_connection this will may help with a generic named pipe solution metze (This used to be commit c6fa9bd15cdb096c3dfc7a4109d9298933981255) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index d5259bc9a6..ea4955d84e 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -227,6 +227,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, ep_description, req->session->session_info, srv_conn, + 0, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { idr_remove(private->idtree_fnum, p->fnum); -- cgit From 86497db6113c4ec3210d671c3fcf957d1026098c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 14:31:17 +0000 Subject: r14157: - pass a struct ntvfs_request to the ntvfs layer (for now we just do #define ntvfs_request smbsrv_request, but it's the first step...) - rename ntvfs_openfile() -> ntvfs_open() - fix the talloc hierachie in some places in the ntvfs_map_*() code metze (This used to be commit ed9ed1f48f602354810937c0b0de850b44322191) --- source4/ntvfs/ipc/vfs_ipc.c | 79 ++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index ea4955d84e..36f0c9b82c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -75,7 +75,7 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t connect to a share - always works */ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, const char *sharename) + struct ntvfs_request *req, const char *sharename) { NTSTATUS status; struct smbsrv_tcon *tcon = req->tcon; @@ -108,8 +108,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, /* disconnect from a share */ -static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs, - struct smbsrv_tcon *tcon) +static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs) { return NT_STATUS_OK; } @@ -118,7 +117,7 @@ static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs, delete a file */ static NTSTATUS ipc_unlink(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_unlink *unl) + struct ntvfs_request *req, struct smb_unlink *unl) { return NT_STATUS_ACCESS_DENIED; } @@ -128,7 +127,7 @@ static NTSTATUS ipc_unlink(struct ntvfs_module_context *ntvfs, ioctl interface - we don't do any */ static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_ioctl *io) + struct ntvfs_request *req, union smb_ioctl *io) { return NT_STATUS_ACCESS_DENIED; } @@ -137,7 +136,7 @@ static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, check if a directory exists */ static NTSTATUS ipc_chkpath(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_chkpath *cp) + struct ntvfs_request *req, struct smb_chkpath *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -146,7 +145,7 @@ static NTSTATUS ipc_chkpath(struct ntvfs_module_context *ntvfs, return info on a pathname */ static NTSTATUS ipc_qpathinfo(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_fileinfo *info) + struct ntvfs_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -155,7 +154,7 @@ static NTSTATUS ipc_qpathinfo(struct ntvfs_module_context *ntvfs, set info on a pathname */ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_setfileinfo *st) + struct ntvfs_request *req, union smb_setfileinfo *st) { return NT_STATUS_ACCESS_DENIED; } @@ -177,7 +176,7 @@ static int ipc_fd_destructor(void *ptr) open a file backend - used for MSRPC pipes */ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, const char *fname, + struct ntvfs_request *req, const char *fname, struct pipe_state **ps) { struct pipe_state *p; @@ -253,7 +252,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, open a file with ntcreatex - used for MSRPC pipes */ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_open *oi) + struct ntvfs_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; @@ -275,7 +274,7 @@ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, open a file with openx - used for MSRPC pipes */ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_open *oi) + struct ntvfs_request *req, union smb_open *oi) { struct pipe_state *p; NTSTATUS status; @@ -298,7 +297,7 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, open a file - used for MSRPC pipes */ static NTSTATUS ipc_open(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_open *oi) + struct ntvfs_request *req, union smb_open *oi) { NTSTATUS status; @@ -321,7 +320,7 @@ static NTSTATUS ipc_open(struct ntvfs_module_context *ntvfs, create a directory */ static NTSTATUS ipc_mkdir(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_mkdir *md) + struct ntvfs_request *req, union smb_mkdir *md) { return NT_STATUS_ACCESS_DENIED; } @@ -330,7 +329,7 @@ static NTSTATUS ipc_mkdir(struct ntvfs_module_context *ntvfs, remove a directory */ static NTSTATUS ipc_rmdir(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_rmdir *rd) + struct ntvfs_request *req, struct smb_rmdir *rd) { return NT_STATUS_ACCESS_DENIED; } @@ -339,7 +338,7 @@ static NTSTATUS ipc_rmdir(struct ntvfs_module_context *ntvfs, rename a set of files */ static NTSTATUS ipc_rename(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_rename *ren) + struct ntvfs_request *req, union smb_rename *ren) { return NT_STATUS_ACCESS_DENIED; } @@ -348,7 +347,7 @@ static NTSTATUS ipc_rename(struct ntvfs_module_context *ntvfs, copy a set of files */ static NTSTATUS ipc_copy(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_copy *cp) + struct ntvfs_request *req, struct smb_copy *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -369,7 +368,7 @@ static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size read from a file */ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_read *rd) + struct ntvfs_request *req, union smb_read *rd) { struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; @@ -378,7 +377,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, NTSTATUS status = NT_STATUS_OK; if (rd->generic.level != RAW_READ_GENERIC) { - return ntvfs_map_read(req, rd, ntvfs); + return ntvfs_map_read(ntvfs, req, rd); } fnum = rd->readx.in.fnum; @@ -412,7 +411,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, write to a file */ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_write *wr) + struct ntvfs_request *req, union smb_write *wr) { struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; @@ -421,7 +420,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, NTSTATUS status; if (wr->generic.level != RAW_WRITE_GENERIC) { - return ntvfs_map_write(req, wr, ntvfs); + return ntvfs_map_write(ntvfs, req, wr); } fnum = wr->writex.in.fnum; @@ -448,7 +447,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, seek in a file */ static NTSTATUS ipc_seek(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_seek *io) + struct ntvfs_request *req, struct smb_seek *io) { return NT_STATUS_ACCESS_DENIED; } @@ -457,7 +456,7 @@ static NTSTATUS ipc_seek(struct ntvfs_module_context *ntvfs, flush a file */ static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_flush *io) + struct ntvfs_request *req, struct smb_flush *io) { return NT_STATUS_ACCESS_DENIED; } @@ -466,13 +465,13 @@ static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, close a file */ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_close *io) + struct ntvfs_request *req, union smb_close *io) { struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { - return ntvfs_map_close(req, io, ntvfs); + return ntvfs_map_close(ntvfs, req, io); } p = pipe_state_find(private, io->close.in.fnum); @@ -489,7 +488,7 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, exit - closing files */ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req) + struct ntvfs_request *req) { struct ipc_private *private = ntvfs->private_data; struct pipe_state *p, *next; @@ -508,7 +507,7 @@ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, logoff - closing files open by the user */ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req) + struct ntvfs_request *req) { struct ipc_private *private = ntvfs->private_data; struct pipe_state *p, *next; @@ -527,7 +526,7 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, setup for an async call */ static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, + struct ntvfs_request *req, void *private) { return NT_STATUS_OK; @@ -537,7 +536,7 @@ static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, cancel an async call */ static NTSTATUS ipc_cancel(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req) + struct ntvfs_request *req) { return NT_STATUS_UNSUCCESSFUL; } @@ -546,7 +545,7 @@ static NTSTATUS ipc_cancel(struct ntvfs_module_context *ntvfs, lock a byte range */ static NTSTATUS ipc_lock(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_lock *lck) + struct ntvfs_request *req, union smb_lock *lck) { return NT_STATUS_ACCESS_DENIED; } @@ -555,7 +554,7 @@ static NTSTATUS ipc_lock(struct ntvfs_module_context *ntvfs, set info on a open file */ static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_setfileinfo *info) + struct ntvfs_request *req, union smb_setfileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -564,7 +563,7 @@ static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, query info on a open file */ static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_fileinfo *info) + struct ntvfs_request *req, union smb_fileinfo *info) { return NT_STATUS_ACCESS_DENIED; } @@ -574,7 +573,7 @@ static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, return filesystem info */ static NTSTATUS ipc_fsinfo(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_fsinfo *fs) + struct ntvfs_request *req, union smb_fsinfo *fs) { return NT_STATUS_ACCESS_DENIED; } @@ -583,7 +582,7 @@ static NTSTATUS ipc_fsinfo(struct ntvfs_module_context *ntvfs, return print queue info */ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_lpq *lpq) + struct ntvfs_request *req, union smb_lpq *lpq) { return NT_STATUS_ACCESS_DENIED; } @@ -592,7 +591,7 @@ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs, list files in a directory matching a wildcard pattern */ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_search_first *io, + struct ntvfs_request *req, union smb_search_first *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -603,7 +602,7 @@ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, continue listing files in a directory */ static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_search_next *io, + struct ntvfs_request *req, union smb_search_next *io, void *search_private, BOOL (*callback)(void *, union smb_search_data *)) { @@ -614,7 +613,7 @@ static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs, end listing files in a directory */ static NTSTATUS ipc_search_close(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, union smb_search_close *io) + struct ntvfs_request *req, union smb_search_close *io) { return NT_STATUS_ACCESS_DENIED; } @@ -638,7 +637,7 @@ static NTSTATUS ipc_trans_dcesrv_output(void *private_data, DATA_BLOB *out, size /* SMBtrans - handle a DCERPC command */ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_trans2 *trans) + struct ntvfs_request *req, struct smb_trans2 *trans) { struct pipe_state *p; struct ipc_private *private = ntvfs->private_data; @@ -684,7 +683,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, /* SMBtrans - set named pipe state */ static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_trans2 *trans) + struct ntvfs_request *req, struct smb_trans2 *trans) { struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; @@ -711,7 +710,7 @@ static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, /* SMBtrans - used to provide access to SMB pipes */ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, - struct smbsrv_request *req, struct smb_trans2 *trans) + struct ntvfs_request *req, struct smb_trans2 *trans) { NTSTATUS status; @@ -760,7 +759,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.chkpath = ipc_chkpath; ops.qpathinfo = ipc_qpathinfo; ops.setpathinfo = ipc_setpathinfo; - ops.openfile = ipc_open; + ops.open = ipc_open; ops.mkdir = ipc_mkdir; ops.rmdir = ipc_rmdir; ops.rename = ipc_rename; -- cgit From 307e43bb5628e8b53a930c2928279af994281ba5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 20:49:20 +0000 Subject: r14173: change smb interface structures to always use a union smb_file, to abtract - const char *path fot qpathinfo and setpathinfo - uint16_t fnum for SMB - smb2_handle handle for SMB2 the idea is to later add a struct ntvfs_handle *ntvfs so that the ntvfs subsystem don't need to know the difference between SMB and SMB2 metze (This used to be commit 2ef3f5970901b5accdb50f0d0115b5d46b0c788f) --- source4/ntvfs/ipc/vfs_ipc.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 36f0c9b82c..2df7ac61ab 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -117,7 +117,8 @@ static NTSTATUS ipc_disconnect(struct ntvfs_module_context *ntvfs) delete a file */ static NTSTATUS ipc_unlink(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, struct smb_unlink *unl) + struct ntvfs_request *req, + union smb_unlink *unl) { return NT_STATUS_ACCESS_DENIED; } @@ -136,7 +137,8 @@ static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, check if a directory exists */ static NTSTATUS ipc_chkpath(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, struct smb_chkpath *cp) + struct ntvfs_request *req, + union smb_chkpath *cp) { return NT_STATUS_ACCESS_DENIED; } @@ -263,7 +265,7 @@ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->ntcreatex.out); - oi->ntcreatex.out.fnum = p->fnum; + oi->ntcreatex.file.fnum = p->fnum; oi->ntcreatex.out.ipc_state = p->ipc_state; oi->ntcreatex.out.file_type = FILE_TYPE_MESSAGE_MODE_PIPE; @@ -286,7 +288,7 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->openx.out); - oi->openx.out.fnum = p->fnum; + oi->openx.file.fnum = p->fnum; oi->openx.out.ftype = 2; oi->openx.out.devstate = p->ipc_state; @@ -380,7 +382,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(ntvfs, req, rd); } - fnum = rd->readx.in.fnum; + fnum = rd->readx.file.fnum; p = pipe_state_find(private, fnum); if (!p) { @@ -423,7 +425,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return ntvfs_map_write(ntvfs, req, wr); } - fnum = wr->writex.in.fnum; + fnum = wr->writex.file.fnum; data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; @@ -447,7 +449,8 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, seek in a file */ static NTSTATUS ipc_seek(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, struct smb_seek *io) + struct ntvfs_request *req, + union smb_seek *io) { return NT_STATUS_ACCESS_DENIED; } @@ -456,7 +459,8 @@ static NTSTATUS ipc_seek(struct ntvfs_module_context *ntvfs, flush a file */ static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, struct smb_flush *io) + struct ntvfs_request *req, + union smb_flush *io) { return NT_STATUS_ACCESS_DENIED; } @@ -474,7 +478,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.fnum); + p = pipe_state_find(private, io->close.file.fnum); if (!p) { return NT_STATUS_INVALID_HANDLE; } -- cgit From a1b295ed4823ce8d06f830b8db9a5d965c934b54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 22:48:25 +0000 Subject: r14256: - rename smb_file -> smb_handle - move it into the in/out substructs again - allow file.path only on smb_fileinfo/smb_setfileinfo metze (This used to be commit be6d5298a2cdb7e7c61d70471bad445645af5963) --- source4/ntvfs/ipc/vfs_ipc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2df7ac61ab..b652b0f530 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -265,7 +265,7 @@ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->ntcreatex.out); - oi->ntcreatex.file.fnum = p->fnum; + oi->ntcreatex.out.file.fnum = p->fnum; oi->ntcreatex.out.ipc_state = p->ipc_state; oi->ntcreatex.out.file_type = FILE_TYPE_MESSAGE_MODE_PIPE; @@ -288,9 +288,9 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->openx.out); - oi->openx.file.fnum = p->fnum; - oi->openx.out.ftype = 2; - oi->openx.out.devstate = p->ipc_state; + oi->openx.out.file.fnum = p->fnum; + oi->openx.out.ftype = 2; + oi->openx.out.devstate = p->ipc_state; return status; } @@ -382,7 +382,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(ntvfs, req, rd); } - fnum = rd->readx.file.fnum; + fnum = rd->readx.in.file.fnum; p = pipe_state_find(private, fnum); if (!p) { @@ -425,7 +425,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return ntvfs_map_write(ntvfs, req, wr); } - fnum = wr->writex.file.fnum; + fnum = wr->writex.in.file.fnum; data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; @@ -478,7 +478,7 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, return ntvfs_map_close(ntvfs, req, io); } - p = pipe_state_find(private, io->close.file.fnum); + p = pipe_state_find(private, io->close.in.file.fnum); if (!p) { return NT_STATUS_INVALID_HANDLE; } -- cgit From e3f2414cf9e582a4e4deecc662b64a7bb2679a34 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 15:03:25 +0000 Subject: r14380: Reduce the size of structs.h (This used to be commit 1a16a6f1dfa66499af43a6b88b3ea69a6a75f1fe) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b652b0f530..ad5c9594d5 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -29,6 +29,7 @@ #include "dlinklist.h" #include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" +#include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" -- cgit From 2e7df84576d26bc37eb87b7e3c79fcb3fb358d68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Mar 2006 17:28:46 +0000 Subject: r14456: don't access the smbsrv_tcon inside the ntvfs modules metze (This used to be commit 5709c1c4e1a561dd9af98cfefbbbdac9b18765b7) --- source4/ntvfs/ipc/vfs_ipc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') 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); -- cgit From a949db7c6d4bd35df59ba066111e6566172d4814 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Mar 2006 18:46:49 +0000 Subject: r14486: remove the need of a stream_connection on a dcesrv_connection, and let the transport set callbacks for getting the own and peer socket_address metze (This used to be commit 56fac3ddbbeecb834e5c7a439df344e11fe12a7b) --- source4/ntvfs/ipc/vfs_ipc.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7a572268d4..24ee1451d6 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -32,6 +32,7 @@ #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 @@ -41,6 +42,8 @@ struct ipc_private { struct idr_context *idtree_fnum; + struct stream_connection *stream_conn; + struct dcesrv_context *dcesrv; /* a list of open pipes */ @@ -95,6 +98,8 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *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); @@ -173,6 +178,19 @@ static int ipc_fd_destructor(void *ptr) return 0; } +static struct socket_address *ipc_get_my_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) +{ + struct ipc_private *private = dce_conn->transport.private_data; + + return socket_get_my_addr(private->stream_conn->socket, 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); +} /* open a file backend - used for MSRPC pipes @@ -227,7 +245,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p, ep_description, req->session->session_info, - srv_conn, + srv_conn->event.ctx, 0, &p->dce_conn); if (!NT_STATUS_IS_OK(status)) { @@ -235,6 +253,11 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, return status; } + p->dce_conn->transport.private_data = private; + p->dce_conn->transport.report_output_data = NULL; + p->dce_conn->transport.get_my_addr = ipc_get_my_addr; + p->dce_conn->transport.get_peer_addr = ipc_get_peer_addr; + DLIST_ADD(private->pipe_list, p); p->smbpid = req->smbpid; -- cgit From d3087451c4ec25171ba956fe2cd4e1d0f64f7edc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Mar 2006 18:54:19 +0000 Subject: 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) --- source4/ntvfs/ipc/vfs_ipc.c | 58 +++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') 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; } -- cgit From ad06a8bd651e3a8b598c92a356ac1ce4117ae72e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 26 Mar 2006 01:23:40 +0000 Subject: r14736: - the ntvfs subsystem should not know about smb_server.h - the process module subsystem should not know about smb_server.h - the smb_server module should not know about process models metze (This used to be commit bac95bb8f4ad35a31ee666f5916ff9b2f292d964) --- source4/ntvfs/ipc/vfs_ipc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 7b9433bcff..b6b931eccd 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -27,7 +27,6 @@ #include "includes.h" #include "dlinklist.h" -#include "smb_server/smb_server.h" #include "ntvfs/ntvfs.h" #include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" -- cgit From f380d365eaad89db2c46331a3fa2d5d8600aeba1 Mon Sep 17 00:00:00 2001 From: James Peach Date: Sun, 23 Apr 2006 23:44:14 +0000 Subject: r15185: Force all NTVFS modules to provide a critical sizes structure so the version information can be checked when modules are registered. (This used to be commit 95eb55806339fc5409c0adf137ebd5bffd7098ac) --- source4/ntvfs/ipc/vfs_ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b6b931eccd..6ef380c4eb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -777,6 +777,7 @@ NTSTATUS ntvfs_ipc_init(void) { NTSTATUS ret; struct ntvfs_ops ops; + NTVFS_CURRENT_CRITICAL_SIZES(vers); ZERO_STRUCT(ops); @@ -817,7 +818,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.cancel = ipc_cancel; /* register ourselves with the NTVFS subsystem. */ - ret = ntvfs_register(&ops); + ret = ntvfs_register(&ops, &vers); if (!NT_STATUS_IS_OK(ret)) { DEBUG(0,("Failed to register IPC backend!\n")); -- cgit From 6ab33938d5239e8688440f65e802f627622d301b Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 24 Apr 2006 00:16:51 +0000 Subject: r15186: Introduce ISDOT and ISDOTDOT macros for testing whether a filename is "." for "..". These express the intention better that strcmp or strequal and improve searchability via cscope/ctags. (This used to be commit 7e4ad7e8e5ec266b969e3075c4ad7f021571f24e) --- source4/ntvfs/ipc/vfs_ipc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 6ef380c4eb..b6b931eccd 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -777,7 +777,6 @@ NTSTATUS ntvfs_ipc_init(void) { NTSTATUS ret; struct ntvfs_ops ops; - NTVFS_CURRENT_CRITICAL_SIZES(vers); ZERO_STRUCT(ops); @@ -818,7 +817,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.cancel = ipc_cancel; /* register ourselves with the NTVFS subsystem. */ - ret = ntvfs_register(&ops, &vers); + ret = ntvfs_register(&ops); if (!NT_STATUS_IS_OK(ret)) { DEBUG(0,("Failed to register IPC backend!\n")); -- cgit From 7baa8a13aa751e2a1de287d43de0884ea638f04e Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 24 Apr 2006 01:26:31 +0000 Subject: r15188: Restore svn rev. 15183, 15184 and 15185, which I inadvertantly clobbered in r15186. I don't think I should be allowed to use quilt and svn at the same time any more :( (This used to be commit e0ca5ead27743c84f5d9310a05d6d718862ead1d) --- source4/ntvfs/ipc/vfs_ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b6b931eccd..6ef380c4eb 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -777,6 +777,7 @@ NTSTATUS ntvfs_ipc_init(void) { NTSTATUS ret; struct ntvfs_ops ops; + NTVFS_CURRENT_CRITICAL_SIZES(vers); ZERO_STRUCT(ops); @@ -817,7 +818,7 @@ NTSTATUS ntvfs_ipc_init(void) ops.cancel = ipc_cancel; /* register ourselves with the NTVFS subsystem. */ - ret = ntvfs_register(&ops); + ret = ntvfs_register(&ops, &vers); if (!NT_STATUS_IS_OK(ret)) { DEBUG(0,("Failed to register IPC backend!\n")); -- cgit From 9ef33f5f5c786b83311ca088357fb2f0aa72fc9e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 08:15:22 +0000 Subject: r15734: This is a major change to the NTVFS subsystem: - to use a struct ntvfs_handle instead of a uint16_t fnum. (to make it independend from the frontend protocol) - the allocation of handles now is provided by the frontend (smbsrv_*) via callbacks and not by each backend module - this also makes sure that file handles are only passed to the ntvfs subsystem when the tcon and session matches, so modules can rely on this and need to check this. - this allows multiple modules in the ntvfs module chain to allocate file handles. This can be used for virtual files like "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"... - also this will make SMB2 with 128 bit file handles possible metze (This used to be commit 287fc1c22d670f6e568014b420f7f4cb31dc7958) --- source4/ntvfs/ipc/vfs_ipc.c | 106 ++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 59 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 6ef380c4eb..fdad41145b 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -32,16 +32,12 @@ #include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" -#define IPC_BASE_FNUM 0x400 - /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open pipes */ struct ipc_private { struct ntvfs_module_context *ntvfs; - struct idr_context *idtree_fnum; - struct dcesrv_context *dcesrv; /* a list of open pipes */ @@ -49,41 +45,43 @@ struct ipc_private { struct pipe_state *next, *prev; struct ipc_private *private; const char *pipe_name; - uint16_t fnum; + struct ntvfs_handle *handle; struct dcesrv_connection *dce_conn; 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 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 + find a open pipe give a file handle */ -static struct pipe_state *pipe_state_find(struct ipc_private *private, uint16_t fnum, - struct auth_session_info *session_info) +static struct pipe_state *pipe_state_find(struct ipc_private *private, struct ntvfs_handle *handle) { struct pipe_state *s; void *p; - p = idr_find(private->idtree_fnum, fnum); + p = ntvfs_handle_get_backend_data(handle, private->ntvfs); if (!p) return NULL; s = talloc_get_type(p, struct pipe_state); - - if (s->session_info != session_info) { - return NULL; - } + if (!s) return NULL; return s; } +/* + find a open pipe give a wire fnum +*/ +static struct pipe_state *pipe_state_find_key(struct ipc_private *private, struct ntvfs_request *req, const DATA_BLOB *key) +{ + struct ntvfs_handle *h; + + h = ntvfs_handle_search_by_wire_key(private->ntvfs, req, key); + if (!h) return NULL; + + return pipe_state_find(private, h); +} + /* connect to a share - always works @@ -109,9 +107,6 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, private->ntvfs = ntvfs; private->pipe_list = NULL; - private->idtree_fnum = idr_init(private); - NT_STATUS_HAVE_NO_MEMORY(private->idtree_fnum); - /* setup the DCERPC server subsystem */ status = dcesrv_init_ipc_context(private, &private->dcesrv); NT_STATUS_NOT_OK_RETURN(status); @@ -182,7 +177,6 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, static int ipc_fd_destructor(void *ptr) { struct pipe_state *p = ptr; - idr_remove(p->private->idtree_fnum, p->fnum); DLIST_REMOVE(p->private->pipe_list, p); return 0; } @@ -212,9 +206,12 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, NTSTATUS status; struct dcerpc_binding *ep_description; struct ipc_private *private = ntvfs->private_data; - int fnum; + struct ntvfs_handle *h; + + status = ntvfs_handle_new(ntvfs, req, &h); + NT_STATUS_NOT_OK_RETURN(status); - p = talloc(req, struct pipe_state); + p = talloc(h, struct pipe_state); NT_STATUS_HAVE_NO_MEMORY(p); ep_description = talloc(req, struct dcerpc_binding); @@ -225,12 +222,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, p->pipe_name = talloc_asprintf(p, "\\pipe\\%s", fname); NT_STATUS_HAVE_NO_MEMORY(p->pipe_name); - fnum = idr_get_new_above(private->idtree_fnum, p, IPC_BASE_FNUM, UINT16_MAX); - if (fnum == -1) { - return NT_STATUS_TOO_MANY_OPENED_FILES; - } - - p->fnum = fnum; + p->handle = h; p->ipc_state = 0x5ff; /* @@ -248,14 +240,11 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, status = dcesrv_endpoint_search_connect(private->dcesrv, p, ep_description, - req->session_info, + h->session_info, ntvfs->ctx->event_ctx, 0, &p->dce_conn); - if (!NT_STATUS_IS_OK(status)) { - idr_remove(private->idtree_fnum, p->fnum); - return status; - } + NT_STATUS_NOT_OK_RETURN(status); p->dce_conn->transport.private_data = private; p->dce_conn->transport.report_output_data = NULL; @@ -264,16 +253,14 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, DLIST_ADD(private->pipe_list, p); - p->smbpid = req->smbpid; - p->session_info = req->session_info; p->private = private; - *ps = p; - - talloc_steal(private, p); - talloc_set_destructor(p, ipc_fd_destructor); + status = ntvfs_handle_set_backend_data(h, private->ntvfs, p); + NT_STATUS_NOT_OK_RETURN(status); + + *ps = p; return NT_STATUS_OK; } @@ -292,7 +279,7 @@ static NTSTATUS ipc_open_ntcreatex(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->ntcreatex.out); - oi->ntcreatex.out.file.fnum = p->fnum; + oi->ntcreatex.out.file.ntvfs= p->handle; oi->ntcreatex.out.ipc_state = p->ipc_state; oi->ntcreatex.out.file_type = FILE_TYPE_MESSAGE_MODE_PIPE; @@ -315,7 +302,7 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, } ZERO_STRUCT(oi->openx.out); - oi->openx.out.file.fnum = p->fnum; + oi->openx.out.file.ntvfs= p->handle; oi->openx.out.ftype = 2; oi->openx.out.devstate = p->ipc_state; @@ -401,7 +388,6 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, { struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; - uint16_t fnum; struct pipe_state *p; NTSTATUS status = NT_STATUS_OK; @@ -409,9 +395,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(ntvfs, req, rd); } - fnum = rd->readx.in.file.fnum; - - p = pipe_state_find(private, fnum, req->session_info); + p = pipe_state_find(private, rd->readx.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -444,7 +428,6 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, { struct ipc_private *private = ntvfs->private_data; DATA_BLOB data; - uint16_t fnum; struct pipe_state *p; NTSTATUS status; @@ -452,11 +435,10 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, return ntvfs_map_write(ntvfs, req, wr); } - fnum = wr->writex.in.file.fnum; data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; - p = pipe_state_find(private, fnum, req->session_info); + p = pipe_state_find(private, wr->writex.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -505,7 +487,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, req->session_info); + p = pipe_state_find(private, io->close.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -526,8 +508,8 @@ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, for (p=private->pipe_list; p; p=next) { next = p->next; - if (p->session_info == req->session_info && - p->smbpid == req->smbpid) { + if (p->handle->session_info == req->session_info && + p->handle->smbpid == req->smbpid) { talloc_free(p); } } @@ -546,7 +528,7 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, for (p=private->pipe_list; p; p=next) { next = p->next; - if (p->session_info == req->session_info) { + if (p->handle->session_info == req->session_info) { talloc_free(p); } } @@ -674,9 +656,12 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct pipe_state *p; struct ipc_private *private = ntvfs->private_data; NTSTATUS status; + DATA_BLOB fnum_key; /* the fnum is in setup[1] */ - p = pipe_state_find(private, trans->in.setup[1], req->session_info); + fnum_key = data_blob_const(&trans->in.setup[1], sizeof(trans->in.setup[1])); + + p = pipe_state_find_key(private, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -715,13 +700,16 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, /* SMBtrans - set named pipe state */ static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, struct smb_trans2 *trans) + struct ntvfs_request *req, struct smb_trans2 *trans) { struct ipc_private *private = ntvfs->private_data; struct pipe_state *p; + DATA_BLOB fnum_key; /* the fnum is in setup[1] */ - p = pipe_state_find(private, trans->in.setup[1], req->session_info); + fnum_key = data_blob_const(&trans->in.setup[1], sizeof(trans->in.setup[1])); + + p = pipe_state_find_key(private, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } -- cgit From e941cc3003f84de4d7846c4f19ce5d006e9f8e98 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 21 May 2006 11:39:50 +0000 Subject: r15772: pass the messaging context and server_id to the dcerpc server subsystem metze (This used to be commit fb1debf219089188d1a8233ab3ff4ff314f7df0b) --- source4/ntvfs/ipc/vfs_ipc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index fdad41145b..2e7c538c3f 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -242,6 +242,8 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, ep_description, h->session_info, ntvfs->ctx->event_ctx, + ntvfs->ctx->msg_ctx, + ntvfs->ctx->server_id, 0, &p->dce_conn); NT_STATUS_NOT_OK_RETURN(status); -- cgit From 971d30bb201f5c3faff5f575d26882eb79f7955a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 May 2006 07:34:11 +0000 Subject: r15854: more talloc_set_destructor() typesafe fixes (This used to be commit 61c6100617589ac6df4f527877241464cacbf8b3) --- source4/ntvfs/ipc/vfs_ipc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 2e7c538c3f..03e026e423 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -174,9 +174,8 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, /* destroy a open pipe structure */ -static int ipc_fd_destructor(void *ptr) +static int ipc_fd_destructor(struct pipe_state *p) { - struct pipe_state *p = ptr; DLIST_REMOVE(p->private->pipe_list, p); return 0; } -- cgit From f719eb9598d4d82d5fec2d13b67f7a5b2e86e4df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 May 2006 04:46:38 +0000 Subject: r15880: the ntvfs_handle changes broke rpc on big-endian boxes, as the uint16_t fnum was being byte order converted twice in the ipc server. Metze, can you have a look at this? This change does make rpc work again, but perhaps you might like to approach it differently (This used to be commit 50246e6282087fdf7050ea052ad516dc620d6c7e) --- source4/ntvfs/ipc/vfs_ipc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 03e026e423..31233968e7 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -658,9 +658,11 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct ipc_private *private = ntvfs->private_data; NTSTATUS status; DATA_BLOB fnum_key; + uint16_t fnum; - /* the fnum is in setup[1] */ - fnum_key = data_blob_const(&trans->in.setup[1], sizeof(trans->in.setup[1])); + /* the fnum is in setup[1], a 16 bit value */ + SSVAL(&fnum, 0, trans->in.setup[1]); + fnum_key = data_blob_const(&fnum, 2); p = pipe_state_find_key(private, req, &fnum_key); if (!p) { -- cgit From b0bcd8a2010c8426f45a3d3c1f9911754f9e2936 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 30 May 2006 20:23:55 +0000 Subject: r15970: add a more verbose comment to tridge's fix for bigendian hosts. tridge: I'm fine with this fix metze (This used to be commit f38b042ded6ec9b243c15d7710261708f208d289) --- source4/ntvfs/ipc/vfs_ipc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 31233968e7..e93e32f4e4 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -660,7 +660,12 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, DATA_BLOB fnum_key; uint16_t fnum; - /* the fnum is in setup[1], a 16 bit value */ + /* + * the fnum is in setup[1], a 16 bit value + * the setup[*] values are already in host byteorder + * but ntvfs_handle_search_by_wire_key() expects + * network byteorder + */ SSVAL(&fnum, 0, trans->in.setup[1]); fnum_key = data_blob_const(&fnum, 2); -- cgit From 810df68c2372dfd311865d4a652ad9b16f394796 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 9 Jul 2006 09:56:13 +0000 Subject: r16890: implement DCERPC over SMB2 in the IPC backend metze (This used to be commit 5338699d0cff5da9fe7f9cd622764ea5a6b0d96b) --- source4/ntvfs/ipc/vfs_ipc.c | 105 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 10 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index e93e32f4e4..a0104cae4d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -31,6 +31,7 @@ #include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" +#include "libcli/raw/ioctl.h" /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open @@ -132,16 +133,6 @@ static NTSTATUS ipc_unlink(struct ntvfs_module_context *ntvfs, return NT_STATUS_ACCESS_DENIED; } - -/* - ioctl interface - we don't do any -*/ -static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, - struct ntvfs_request *req, union smb_ioctl *io) -{ - return NT_STATUS_ACCESS_DENIED; -} - /* check if a directory exists */ @@ -310,6 +301,34 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs, return status; } +/* + open a file with SMB2 Create - used for MSRPC pipes +*/ +static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_open *oi) +{ + struct pipe_state *p; + NTSTATUS status; + + status = ipc_open_generic(ntvfs, req, oi->smb2.in.fname, &p); + NT_STATUS_NOT_OK_RETURN(status); + + oi->smb2.out.file.ntvfs = p->handle; + oi->smb2.out.oplock_flags = oi->smb2.in.oplock_flags; + oi->smb2.out.create_action = NTCREATEX_ACTION_EXISTED; + oi->smb2.out.create_time = 0; + oi->smb2.out.access_time = 0; + oi->smb2.out.write_time = 0; + oi->smb2.out.change_time = 0; + oi->smb2.out.alloc_size = 4096; + oi->smb2.out.size = 0; + oi->smb2.out.file_attr = FILE_ATTRIBUTE_NORMAL; + oi->smb2.out._pad = 0; + oi->smb2.out.blob = data_blob(NULL, 0); + + return status; +} + /* open a file - used for MSRPC pipes */ @@ -325,6 +344,9 @@ static NTSTATUS ipc_open(struct ntvfs_module_context *ntvfs, case RAW_OPEN_OPENX: status = ipc_open_openx(ntvfs, req, oi); break; + case RAW_OPEN_SMB2: + status = ipc_open_smb2(ntvfs, req, oi); + break; default: status = NT_STATUS_NOT_SUPPORTED; break; @@ -764,6 +786,69 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, return status; } +static NTSTATUS ipc_ioctl_smb2(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_ioctl *io) +{ + struct pipe_state *p; + struct ipc_private *private = ntvfs->private_data; + NTSTATUS status; + + switch (io->smb2.in.function) { + case FSCTL_NAMED_PIPE_READ_WRITE: + break; + + default: + return NT_STATUS_FS_DRIVER_REQUIRED; + } + + p = pipe_state_find(private, io->smb2.in.file.ntvfs); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + + io->smb2.out.out = data_blob_talloc(req, NULL, io->smb2.in.max_response_size); + NT_STATUS_HAVE_NO_MEMORY(io->smb2.out.out.data); + + /* pass the data to the dcerpc server. Note that we don't + expect this to fail, and things like NDR faults are not + reported at this stage. Those sorts of errors happen in the + dcesrv_output stage */ + status = dcesrv_input(p->dce_conn, &io->smb2.in.out); + NT_STATUS_NOT_OK_RETURN(status); + + /* + now ask the dcerpc system for some output. This doesn't yet handle + async calls. Again, we only expect NT_STATUS_OK. If the call fails then + the error is encoded at the dcerpc level + */ + status = dcesrv_output(p->dce_conn, &io->smb2.out.out, ipc_trans_dcesrv_output); + NT_STATUS_IS_ERR_RETURN(status); + + io->smb2.out._pad = 0; + io->smb2.out.function = io->smb2.in.function; + io->smb2.out.unknown2 = 0; + io->smb2.out.unknown3 = 0; + io->smb2.out.in = io->smb2.in.out; + + return status; +} + +/* + ioctl interface +*/ +static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, union smb_ioctl *io) +{ + switch (io->generic.level) { + case RAW_IOCTL_SMB2: + return ipc_ioctl_smb2(ntvfs, req, io); + + default: + return NT_STATUS_ACCESS_DENIED; + } + + return NT_STATUS_ACCESS_DENIED; +} /* -- cgit From 5468516f9af10cb3c67bc93c610c22b5383e20db Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 14:01:53 +0000 Subject: r16918: the SMB2 Ioctls are sometimes called with a wildcard handle the operation doesn't need a valid file handle in that case metze (This used to be commit d41a83d55945b07020349339888f3a34ac4eff4e) --- source4/ntvfs/ipc/vfs_ipc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index a0104cae4d..cc8b4af285 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -843,6 +843,9 @@ static NTSTATUS ipc_ioctl(struct ntvfs_module_context *ntvfs, case RAW_IOCTL_SMB2: return ipc_ioctl_smb2(ntvfs, req, io); + case RAW_IOCTL_SMB2_NO_HANDLE: + return NT_STATUS_FS_DRIVER_REQUIRED; + default: return NT_STATUS_ACCESS_DENIED; } -- cgit From 0329d755a7611ba3897fc1ee9bdce410cc33d7f8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 30 Aug 2006 11:29:34 +0000 Subject: r17930: Merge noinclude branch: * Move dlinklist.h, smb.h to subsystem-specific directories * Clean up ads.h and move what is left of it to dsdb/ (only place where it's used) (This used to be commit f7afa1cb77f3cfa7020b57de12e6003db7cfcc42) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index cc8b4af285..bb80963287 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -26,7 +26,7 @@ #include "includes.h" -#include "dlinklist.h" +#include "lib/util/dlinklist.h" #include "ntvfs/ntvfs.h" #include "libcli/rap/rap.h" #include "ntvfs/ipc/proto.h" -- cgit From 3a88c56346929695cc4b2ecc22e20aee51b493d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 15 May 2007 01:21:20 +0000 Subject: r22874: Expand the RPC-QFILEINFO-IPC test, and add a server implementation to match. This should help with Vista joins. Andrew Bartlett (This used to be commit 8f85fb37862044d4b618e4184274bc67432af73b) --- source4/ntvfs/ipc/vfs_ipc.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index bb80963287..20b70415aa 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -149,7 +149,14 @@ static NTSTATUS ipc_chkpath(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - return NT_STATUS_ACCESS_DENIED; + switch (info->generic.level) { + case RAW_FILEINFO_GENERIC: + return NT_STATUS_INVALID_DEVICE_REQUEST; + case RAW_FILEINFO_GETATTR: + return NT_STATUS_ACCESS_DENIED; + default: + return ntvfs_map_qpathinfo(ntvfs, req, info); + } } /* @@ -602,6 +609,39 @@ static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { + struct ipc_private *private = ntvfs->private_data; + switch (info->generic.level) { + case RAW_FILEINFO_GENERIC: + { + struct pipe_state *p; + p = pipe_state_find(private, info->generic.in.file.ntvfs); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } + ZERO_STRUCT(info->generic.out); + info->generic.out.attrib = FILE_ATTRIBUTE_NORMAL; + info->generic.out.fname.s = strrchr(p->pipe_name, '\\'); + info->generic.out.alloc_size = 4096; + info->generic.out.nlink = 1; + /* What the heck? Match Win2k3: IPC$ pipes are delete pending */ + info->generic.out.delete_pending = 1; + return NT_STATUS_OK; + } + case RAW_FILEINFO_ALT_NAME_INFO: + case RAW_FILEINFO_ALT_NAME_INFORMATION: + case RAW_FILEINFO_STREAM_INFO: + case RAW_FILEINFO_STREAM_INFORMATION: + case RAW_FILEINFO_COMPRESSION_INFO: + case RAW_FILEINFO_COMPRESSION_INFORMATION: + case RAW_FILEINFO_NETWORK_OPEN_INFORMATION: + case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION: + return NT_STATUS_INVALID_PARAMETER; + case RAW_FILEINFO_ALL_EAS: + return NT_STATUS_ACCESS_DENIED; + default: + return ntvfs_map_qfileinfo(ntvfs, req, info); + } + return NT_STATUS_ACCESS_DENIED; } -- cgit From 4febada51fca5953b84b71b71c9aa0a430c4ee3d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 15 May 2007 06:51:18 +0000 Subject: r22882: It seems entirly reasonable to follow metze's suggestion and check for a valid file handle first. Andrew Bartlett (This used to be commit 3947db3dcbfe97e9ccb9b9bd2b3a69cf7683af9f) --- source4/ntvfs/ipc/vfs_ipc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 20b70415aa..70dd3e3561 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -610,14 +610,13 @@ static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { struct ipc_private *private = ntvfs->private_data; + struct pipe_state *p = pipe_state_find(private, info->generic.in.file.ntvfs); + if (!p) { + return NT_STATUS_INVALID_HANDLE; + } switch (info->generic.level) { case RAW_FILEINFO_GENERIC: { - struct pipe_state *p; - p = pipe_state_find(private, info->generic.in.file.ntvfs); - if (!p) { - return NT_STATUS_INVALID_HANDLE; - } ZERO_STRUCT(info->generic.out); info->generic.out.attrib = FILE_ATTRIBUTE_NORMAL; info->generic.out.fname.s = strrchr(p->pipe_name, '\\'); -- cgit From 42c1ef4025186066660b1bb187d063e07bb493ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 May 2007 09:25:58 +0000 Subject: r23067: use 'const union smb_search_data *file' also in the server code to get rid of compiler warnings in the cifs backend metze (This used to be commit 34ef07b1f5acdad27edd80de8de4c6de7f879f9b) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 70dd3e3561..f05c3c29e3 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -669,7 +669,7 @@ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_first *io, void *search_private, - BOOL (*callback)(void *, union smb_search_data *)) + BOOL (*callback)(void *, const union smb_search_data *)) { return NT_STATUS_ACCESS_DENIED; } @@ -680,7 +680,7 @@ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_next *io, void *search_private, - BOOL (*callback)(void *, union smb_search_data *)) + BOOL (*callback)(void *, const union smb_search_data *)) { return NT_STATUS_ACCESS_DENIED; } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/ntvfs/ipc/vfs_ipc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index f05c3c29e3..aeb99e50b0 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* this implements the IPC$ backend, called by the NTVFS subsystem to -- cgit From bd750a77c086da01a389f567b99cdbb7bf2bd7d9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 30 Jul 2007 09:04:28 +0000 Subject: r24075: As suggested by metze, match the behaviour of ntvfs_posix, and remove the backend data (effectivly closing the handle) when we close an IPC FD. This should fix #4821. Andrew Bartlett (This used to be commit efaf91b9d53c1d9b882c53e069e8e7c15394e0f3) --- source4/ntvfs/ipc/vfs_ipc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index aeb99e50b0..fbac82a305 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -174,6 +174,7 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, static int ipc_fd_destructor(struct pipe_state *p) { DLIST_REMOVE(p->private->pipe_list, p); + ntvfs_handle_remove_backend_data(p->handle, p->private->ntvfs); return 0; } -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index fbac82a305..fc3c74ca6c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -669,7 +669,7 @@ static NTSTATUS ipc_lpq(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_first *io, void *search_private, - BOOL (*callback)(void *, const union smb_search_data *)) + bool (*callback)(void *, const union smb_search_data *)) { return NT_STATUS_ACCESS_DENIED; } @@ -680,7 +680,7 @@ static NTSTATUS ipc_search_first(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_search_next(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_next *io, void *search_private, - BOOL (*callback)(void *, const union smb_search_data *)) + bool (*callback)(void *, const union smb_search_data *)) { return NT_STATUS_ACCESS_DENIED; } -- cgit From 57f20ccd242e45ff91850341594aa040d113c19e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 20:05:00 +0100 Subject: r26296: Store loadparm context in DCE/RPC server context. (This used to be commit fc1f4d2d65d4c983cba5421e7ffb64dd75482860) --- source4/ntvfs/ipc/vfs_ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index fc3c74ca6c..4a5ddd7a9c 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -31,6 +31,7 @@ #include "ntvfs/ipc/proto.h" #include "rpc_server/dcerpc_server.h" #include "libcli/raw/ioctl.h" +#include "param/param.h" /* this is the private structure used to keep the state of an open ipc$ connection. It needs to keep information about all open @@ -108,7 +109,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, private->pipe_list = NULL; /* setup the DCERPC server subsystem */ - status = dcesrv_init_ipc_context(private, &private->dcesrv); + status = dcesrv_init_ipc_context(private, global_loadparm, &private->dcesrv); NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; -- cgit From a72c5053c587f0ed6113ef514fe3739cb81e7abf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:43 +0100 Subject: r26353: Remove use of global_loadparm. (This used to be commit 17637e4490e42db6cdef619286c4d5a0982e9d1a) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 4a5ddd7a9c..b69fb98c5d 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -109,7 +109,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, private->pipe_list = NULL; /* setup the DCERPC server subsystem */ - status = dcesrv_init_ipc_context(private, global_loadparm, &private->dcesrv); + status = dcesrv_init_ipc_context(private, ntvfs->ctx->lp_ctx, &private->dcesrv); NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; -- cgit From df408d056ec03f2abe08ce0ea487e1875b90e7bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Jan 2008 19:03:43 -0600 Subject: r26672: Janitorial: Remove uses of global_loadparm. (This used to be commit 18cd08623eaad7d2cd63b82ea5275d4dfd21cf00) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index b69fb98c5d..81cd984f0b 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -805,7 +805,7 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, NTSTATUS status; if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) - return ipc_rap_call(req, trans); + return ipc_rap_call(req, ntvfs->ctx->lp_ctx, trans); if (trans->in.setup_count != 2) { return NT_STATUS_INVALID_PARAMETER; -- cgit From 88d2e0522737fb8856fb0f52c2af8a2f56130f19 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 15:05:44 +1100 Subject: updated SMB2 create operation to match WSPP. Adding some defined for various new create options (This used to be commit d037dc23ced3df6bce98cbf4810fb5f1247336bd) --- source4/ntvfs/ipc/vfs_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 81cd984f0b..92f0eadae1 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -322,7 +322,7 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs, NT_STATUS_NOT_OK_RETURN(status); oi->smb2.out.file.ntvfs = p->handle; - oi->smb2.out.oplock_flags = oi->smb2.in.oplock_flags; + oi->smb2.out.oplock_level = oi->smb2.in.oplock_level; oi->smb2.out.create_action = NTCREATEX_ACTION_EXISTED; oi->smb2.out.create_time = 0; oi->smb2.out.access_time = 0; @@ -331,7 +331,7 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs, oi->smb2.out.alloc_size = 4096; oi->smb2.out.size = 0; oi->smb2.out.file_attr = FILE_ATTRIBUTE_NORMAL; - oi->smb2.out._pad = 0; + oi->smb2.out.reserved2 = 0; oi->smb2.out.blob = data_blob(NULL, 0); return status; -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 92f0eadae1..ea7b54ae6a 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -805,7 +805,7 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs, NTSTATUS status; if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN")) - return ipc_rap_call(req, ntvfs->ctx->lp_ctx, trans); + return ipc_rap_call(req, ntvfs->ctx->event_ctx, ntvfs->ctx->lp_ctx, trans); if (trans->in.setup_count != 2) { return NT_STATUS_INVALID_PARAMETER; -- cgit From 6b707263058ec69f12a6235890005a226c8671de Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 May 2008 16:28:37 +1000 Subject: implement the documented SMB2 create blobs in the server Not all of them are honoured yet, but they are all parsed and the ones that have SMB equivalents are honoured (This used to be commit 9fc70e2ed6a54f6d9a0530f4d37c0f8acadb6778) --- source4/ntvfs/ipc/vfs_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/ntvfs/ipc/vfs_ipc.c') diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index ea7b54ae6a..8ac7ac7d03 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -321,6 +321,7 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs, status = ipc_open_generic(ntvfs, req, oi->smb2.in.fname, &p); NT_STATUS_NOT_OK_RETURN(status); + ZERO_STRUCT(oi->smb2.out); oi->smb2.out.file.ntvfs = p->handle; oi->smb2.out.oplock_level = oi->smb2.in.oplock_level; oi->smb2.out.create_action = NTCREATEX_ACTION_EXISTED; @@ -332,7 +333,6 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs, oi->smb2.out.size = 0; oi->smb2.out.file_attr = FILE_ATTRIBUTE_NORMAL; oi->smb2.out.reserved2 = 0; - oi->smb2.out.blob = data_blob(NULL, 0); return status; } -- cgit