From 027276e2561004e743b8886048553ea68aa9dfb0 Mon Sep 17 00:00:00 2001 From: Sam Liddicott Date: Fri, 7 Nov 2008 15:39:58 +0000 Subject: [PATCH] Prepare rpclite to use session ntioctl handle. Add helper functions so rpclite mechanisms can stop using a specific file handle for the rpclite ntioctl transport --- source4/ntvfs/proxy/vfs_proxy.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/source4/ntvfs/proxy/vfs_proxy.c b/source4/ntvfs/proxy/vfs_proxy.c index 72f73384ebe..26ce4f881b5 100644 --- a/source4/ntvfs/proxy/vfs_proxy.c +++ b/source4/ntvfs/proxy/vfs_proxy.c @@ -114,6 +114,16 @@ struct async_rpclite_send { #define SETUP_PID private->tree->session->pid = req->smbpid +#define RPCLITE_SETUP_FILE_HERE(f, h) do { \ + if ((h = ntvfs_find_handle(private->ntvfs, req, r->in.fnum)) && \ + (f = ntvfs_handle_get_backend_data(h, ntvfs))) { \ + r->in.fnum = f->fnum; \ + } else { \ + r->out.result = NT_STATUS_INVALID_HANDLE; \ + return NT_STATUS_OK; \ + } \ +} while (0) + #define SETUP_FILE_HERE(f) do { \ f = ntvfs_handle_get_backend_data(io->generic.in.file.ntvfs, ntvfs); \ if (!f) return NT_STATUS_INVALID_HANDLE; \ @@ -226,6 +236,27 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin } /* + get file handle from clients fnum, (from ntvfs/ipc/vfs_ipc.c at metze suggestion) +*/ +static struct ntvfs_handle *ntvfs_find_handle(struct ntvfs_module_context *ntvfs, + struct ntvfs_request *req, + uint16_t fnum) +{ + DATA_BLOB key; + uint16_t _fnum; + + /* + * the fnum is already in host byteorder + * but ntvfs_handle_search_by_wire_key() expects + * network byteorder + */ + SSVAL(&_fnum, 0, fnum); + key = data_blob_const(&_fnum, 2); + + return ntvfs_handle_search_by_wire_key(ntvfs, req, &key); +} + +/* connect to a share - used when a tree_connect operation comes in. */ static NTSTATUS proxy_connect(struct ntvfs_module_context *ntvfs, -- 2.11.4.GIT