From 340d9b71f9e75d634389104da5949ba59669ede2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 13 Dec 2003 02:20:40 +0000 Subject: added a basic dcerpc endpoint mapper to Samba4. Currently only implements the epm_Lookup() call, I'll add the other important calls soon. I was rather pleased to find that epm_Lookup() worked first time, which is particularly surprising given its complexity. This required quite a bit of new infrastructure: * a generic way of handling dcerpc policy handles in the rpc server * added type checked varients of talloc. These are much less error prone. I'd like to move to using these for nearly all uses of talloc. * added more dcerpc fault handling code, and translation from NTSTATUS to a dcerpc fault code * added data_blob_talloc_zero() for allocating an initially zero blob * added a endpoint enumeration hook in the dcerpc endpoint server operations (This used to be commit 3f85f9b782dc17417baf1ca557fcae22f5b6a83a) --- source4/rpc_server/handles.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 source4/rpc_server/handles.c (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c new file mode 100644 index 0000000000..16e4175184 --- /dev/null +++ b/source4/rpc_server/handles.c @@ -0,0 +1,92 @@ +/* + Unix SMB/CIFS implementation. + + server side dcerpc handle code + + 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. +*/ + +#include "includes.h" + +/* + allocate a new rpc handle +*/ +struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, + uint8 handle_type) +{ + TALLOC_CTX *mem_ctx; + struct dcesrv_handle *h; + + mem_ctx = talloc_init("rpc handle type %d\n", handle_type); + if (!mem_ctx) { + return NULL; + } + h = talloc(mem_ctx, sizeof(*h)); + if (!h) { + talloc_destroy(mem_ctx); + return NULL; + } + h->mem_ctx = mem_ctx; + h->data = NULL; + + memset(h->wire_handle.data, 'H', sizeof(h->wire_handle.data)); + strncpy(h->wire_handle.data, dce->ndr->name, 11); + h->wire_handle.data[11] = handle_type; + + /* TODO: check for wraparound here */ + SIVAL(&h->wire_handle.data, 12, random()); + SIVAL(&h->wire_handle.data, 16, dce->next_handle); + dce->next_handle++; + + DLIST_ADD(dce->handles, h); + + return h; +} + +/* + destroy a rpc handle +*/ +void dcesrv_handle_destroy(struct dcesrv_state *dce, + struct dcesrv_handle *h) +{ + DLIST_REMOVE(dce->handles, h); + talloc_destroy(h->mem_ctx); +} + + +/* + find an internal handle given a wire handle. If the wire handle is NULL then + allocate a new handle +*/ +struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_state *dce, + struct policy_handle *p, + uint8 handle_type) +{ + struct dcesrv_handle *h; + + if (all_zero(p->data, sizeof(p->data))) { + return dcesrv_handle_new(dce, handle_type); + } + + for (h=dce->handles; h; h=h->next) { + if (memcmp(h->wire_handle.data, p->data, sizeof(p->data)) == 0) { + return h; + } + } + + return NULL; +} -- cgit From da86d3af3126413e59798bcfb0705c307bc730cb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 13 Dec 2003 03:23:41 +0000 Subject: added the epm_Map() call. the RPC-EPMAPPER torture test now passes (This used to be commit fbdcf9ef548aefb1233cbb22a60bff3eacba996f) --- source4/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 16e4175184..6b7d422267 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -49,8 +49,8 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, /* TODO: check for wraparound here */ SIVAL(&h->wire_handle.data, 12, random()); - SIVAL(&h->wire_handle.data, 16, dce->next_handle); dce->next_handle++; + SIVAL(&h->wire_handle.data, 16, dce->next_handle); DLIST_ADD(dce->handles, h); -- cgit From 6f12e4ace1609fbf00d42226134b1dbb259f38bc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 09:50:49 +0000 Subject: it turns out that a wire policy handle isn't a blob either, its a uint32 followed by a GUID. I needed to fix this to support running in mixed-mode rpc (where smbtorture is bigendian and w2k3 is little-endian). Otherwise when you send back a policy handle the server doesn't recognise it. (This used to be commit 9b1c76a8e9e953e051072441f8938ee17a674d35) --- source4/rpc_server/handles.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 6b7d422267..df7745f6da 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -43,15 +43,9 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, h->mem_ctx = mem_ctx; h->data = NULL; - memset(h->wire_handle.data, 'H', sizeof(h->wire_handle.data)); - strncpy(h->wire_handle.data, dce->ndr->name, 11); - h->wire_handle.data[11] = handle_type; + h->wire_handle.handle_type = handle_type; + uuid_generate_random(&h->wire_handle.uuid); - /* TODO: check for wraparound here */ - SIVAL(&h->wire_handle.data, 12, random()); - dce->next_handle++; - SIVAL(&h->wire_handle.data, 16, dce->next_handle); - DLIST_ADD(dce->handles, h); return h; @@ -78,12 +72,18 @@ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_state *dce, { struct dcesrv_handle *h; - if (all_zero(p->data, sizeof(p->data))) { + if (p->handle_type == 0 && uuid_all_zero(&p->uuid)) { return dcesrv_handle_new(dce, handle_type); } for (h=dce->handles; h; h=h->next) { - if (memcmp(h->wire_handle.data, p->data, sizeof(p->data)) == 0) { + if (h->wire_handle.handle_type == p->handle_type && + uuid_equal(&p->uuid, &h->wire_handle.uuid)) { + if (p->handle_type != handle_type) { + DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n", + p->handle_type, handle_type)); + return NULL; + } return h; } } -- cgit From db22c0c5f94ecc12339efbd3950fe1c5648fde76 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 19 Dec 2003 03:59:27 +0000 Subject: added a bunch of alias functions in samr.idl based on work by Kai. (This used to be commit f740b02ac36780740700909da2bcdf672cb146cb) --- source4/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index df7745f6da..26d7552afb 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -72,7 +72,7 @@ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_state *dce, { struct dcesrv_handle *h; - if (p->handle_type == 0 && uuid_all_zero(&p->uuid)) { + if (policy_handle_empty(p)) { return dcesrv_handle_new(dce, handle_type); } -- 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/rpc_server/handles.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 26d7552afb..043318c075 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -25,7 +25,7 @@ /* allocate a new rpc handle */ -struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, +struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, uint8 handle_type) { TALLOC_CTX *mem_ctx; @@ -46,7 +46,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, h->wire_handle.handle_type = handle_type; uuid_generate_random(&h->wire_handle.uuid); - DLIST_ADD(dce->handles, h); + DLIST_ADD(dce_conn->handles, h); return h; } @@ -54,10 +54,10 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_state *dce, /* destroy a rpc handle */ -void dcesrv_handle_destroy(struct dcesrv_state *dce, +void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn, struct dcesrv_handle *h) { - DLIST_REMOVE(dce->handles, h); + DLIST_REMOVE(dce_conn->handles, h); talloc_destroy(h->mem_ctx); } @@ -66,17 +66,17 @@ void dcesrv_handle_destroy(struct dcesrv_state *dce, find an internal handle given a wire handle. If the wire handle is NULL then allocate a new handle */ -struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_state *dce, +struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, struct policy_handle *p, uint8 handle_type) { struct dcesrv_handle *h; if (policy_handle_empty(p)) { - return dcesrv_handle_new(dce, handle_type); + return dcesrv_handle_new(dce_conn, handle_type); } - for (h=dce->handles; h; h=h->next) { + for (h=dce_conn->handles; h; h=h->next) { if (h->wire_handle.handle_type == p->handle_type && uuid_equal(&p->uuid, &h->wire_handle.uuid)) { if (p->handle_type != handle_type) { -- cgit From b96025eb15e3648e77e0e6aa343e23ca2f1156da Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Apr 2004 20:44:33 +0000 Subject: r61: - Implement first call in the winreg rpc server - Add some initial implementation of the ldb backend - More checks in the winreg torture test (This used to be commit ae2b63b6f1821bc4f693cb8e2a5f78718c483c24) --- source4/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 043318c075..611dc42f76 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -32,7 +32,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, struct dcesrv_handle *h; mem_ctx = talloc_init("rpc handle type %d\n", handle_type); - if (!mem_ctx) { +if (!mem_ctx) { return NULL; } h = talloc(mem_ctx, sizeof(*h)); -- cgit From f9235e0964d921cc1df7b4c4b7ab91a1c1ab4d54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 5 Apr 2004 22:34:24 +0000 Subject: r62: Fix the build (This used to be commit 1396db85372af1824592ef66f963603e3f35803c) --- source4/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 611dc42f76..043318c075 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -32,7 +32,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, struct dcesrv_handle *h; mem_ctx = talloc_init("rpc handle type %d\n", handle_type); -if (!mem_ctx) { + if (!mem_ctx) { return NULL; } h = talloc(mem_ctx, sizeof(*h)); -- cgit From 1c5de896bc0aa58c4463dca3675b299c2555fddf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 6 Apr 2004 08:07:07 +0000 Subject: r67: added a destroy hook in the policy handle -> wire handle code to allow backends to cleanup handle data (This used to be commit af0c21c1e175ca2ebb687dc6dff83da919280271) --- source4/rpc_server/handles.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 043318c075..df6abd65a5 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -42,6 +42,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, } h->mem_ctx = mem_ctx; h->data = NULL; + h->destroy = NULL; h->wire_handle.handle_type = handle_type; uuid_generate_random(&h->wire_handle.uuid); @@ -57,6 +58,9 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn, struct dcesrv_handle *h) { + if (h->destroy) { + h->destroy(dce_conn, h); + } DLIST_REMOVE(dce_conn->handles, h); talloc_destroy(h->mem_ctx); } -- cgit From 6cc392bff3dfe0b6b17ddb89e21bc2cdf1b51c92 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Apr 2004 07:12:10 +0000 Subject: r374: allow for a policy_handle fetch using a handle type of DCESRV_HANDLE_ANY. This is needed for operations like samr_Close() that take any handle type. (This used to be commit 6fbbfc4462388c4c86f9f0ddd3cdd99225512ef2) --- source4/rpc_server/handles.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index df6abd65a5..21030b4755 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -83,7 +83,8 @@ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, for (h=dce_conn->handles; h; h=h->next) { if (h->wire_handle.handle_type == p->handle_type && uuid_equal(&p->uuid, &h->wire_handle.uuid)) { - if (p->handle_type != handle_type) { + if (handle_type != DCESRV_HANDLE_ANY && + p->handle_type != handle_type) { DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n", p->handle_type, handle_type)); return NULL; -- cgit From fcd718c7d8a6850ae8719f23ed044b06b57501cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:50:17 +0000 Subject: r890: convert samba4 to use [u]int8_t instead of [u]int8 metze (This used to be commit 2986c5f08c8f0c26a2ea7b6ce20aae025183109f) --- source4/rpc_server/handles.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 21030b4755..4cddfc896d 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -26,7 +26,7 @@ allocate a new rpc handle */ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, - uint8 handle_type) + uint8_t handle_type) { TALLOC_CTX *mem_ctx; struct dcesrv_handle *h; @@ -72,7 +72,7 @@ void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn, */ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, struct policy_handle *p, - uint8 handle_type) + uint8_t handle_type) { struct dcesrv_handle *h; -- 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/rpc_server/handles.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 4cddfc896d..87749b27a1 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -28,19 +28,12 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, uint8_t handle_type) { - TALLOC_CTX *mem_ctx; struct dcesrv_handle *h; - mem_ctx = talloc_init("rpc handle type %d\n", handle_type); - if (!mem_ctx) { - return NULL; - } - h = talloc(mem_ctx, sizeof(*h)); + h = talloc_p(dce_conn, struct dcesrv_handle); if (!h) { - talloc_destroy(mem_ctx); return NULL; } - h->mem_ctx = mem_ctx; h->data = NULL; h->destroy = NULL; @@ -62,7 +55,7 @@ void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn, h->destroy(dce_conn, h); } DLIST_REMOVE(dce_conn->handles, h); - talloc_destroy(h->mem_ctx); + talloc_free(h); } -- 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/rpc_server/handles.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 87749b27a1..2b070f6bdb 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "dlinklist.h" /* allocate a new rpc handle -- cgit From c051779a0a34a9c40a5425fb1eb821983b8dc852 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 07:42:47 +0000 Subject: r3468: split out dcerpc_server.h (This used to be commit 729e0026e4408f74f140375537d4fe48c1fc3242) --- source4/rpc_server/handles.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 2b070f6bdb..34ed42799f 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -22,6 +22,7 @@ #include "includes.h" #include "dlinklist.h" +#include "rpc_server/dcerpc_server.h" /* allocate a new rpc handle -- cgit From e90061865467600a9d8a34f92e60a296cbf19234 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Nov 2004 20:03:46 +0000 Subject: r3972: use GUID_* naming context and move GUID_* functions to one place metze (This used to be commit 523e6acf4fec5d4946fa7c0c89f40d7d712c9f3a) --- source4/rpc_server/handles.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 34ed42799f..41169aa25d 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -40,7 +40,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, h->destroy = NULL; h->wire_handle.handle_type = handle_type; - uuid_generate_random(&h->wire_handle.uuid); + h->wire_handle.uuid = GUID_random(); DLIST_ADD(dce_conn->handles, h); @@ -77,7 +77,7 @@ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, for (h=dce_conn->handles; h; h=h->next) { if (h->wire_handle.handle_type == p->handle_type && - uuid_equal(&p->uuid, &h->wire_handle.uuid)) { + GUID_equal(&p->uuid, &h->wire_handle.uuid)) { if (handle_type != DCESRV_HANDLE_ANY && p->handle_type != handle_type) { DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n", -- cgit From 577218b2aded7adb367f3f33bcc5560f3d4c0ec2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Jan 2005 12:15:26 +0000 Subject: r4640: first stage in the server side support for multiple context_ids on one pipe this stage does the following: - simplifies the dcerpc_handle handling, and all the callers of it - split out the context_id depenent state into a linked list of established contexts - fixed some talloc handling in several rpc servers that i noticed while doing the above (This used to be commit fde042b3fc609c94e2c7eedcdd72ecdf489cf63b) --- source4/rpc_server/handles.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 41169aa25d..df9213bfd3 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -24,58 +24,62 @@ #include "dlinklist.h" #include "rpc_server/dcerpc_server.h" +/* + destroy a rpc handle +*/ +static int dcesrv_handle_destructor(void *ptr) +{ + struct dcesrv_handle *h = ptr; + if (h->destroy) { + h->destroy(h->context, h); + } + DLIST_REMOVE(h->context->handles, h); + talloc_free(h); + return 0; +} + + /* allocate a new rpc handle */ -struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn, +struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *context, uint8_t handle_type) { struct dcesrv_handle *h; - h = talloc_p(dce_conn, struct dcesrv_handle); + h = talloc_p(context, struct dcesrv_handle); if (!h) { return NULL; } h->data = NULL; h->destroy = NULL; + h->context = context; h->wire_handle.handle_type = handle_type; h->wire_handle.uuid = GUID_random(); - DLIST_ADD(dce_conn->handles, h); + DLIST_ADD(context->handles, h); - return h; -} + talloc_set_destructor(h, dcesrv_handle_destructor); -/* - destroy a rpc handle -*/ -void dcesrv_handle_destroy(struct dcesrv_connection *dce_conn, - struct dcesrv_handle *h) -{ - if (h->destroy) { - h->destroy(dce_conn, h); - } - DLIST_REMOVE(dce_conn->handles, h); - talloc_free(h); + return h; } - /* find an internal handle given a wire handle. If the wire handle is NULL then allocate a new handle */ -struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection *dce_conn, +struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection_context *context, struct policy_handle *p, uint8_t handle_type) { struct dcesrv_handle *h; if (policy_handle_empty(p)) { - return dcesrv_handle_new(dce_conn, handle_type); + return dcesrv_handle_new(context, handle_type); } - for (h=dce_conn->handles; h; h=h->next) { + for (h=context->handles; h; h=h->next) { if (h->wire_handle.handle_type == p->handle_type && GUID_equal(&p->uuid, &h->wire_handle.uuid)) { if (handle_type != DCESRV_HANDLE_ANY && -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index df9213bfd3..b203f45e4e 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -47,7 +47,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *contex { struct dcesrv_handle *h; - h = talloc_p(context, struct dcesrv_handle); + h = talloc(context, struct dcesrv_handle); if (!h) { return NULL; } -- cgit From 32e6cf5e3f70bc9d41588ae8ad0b1f90c7a02651 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 4 Apr 2005 14:58:52 +0000 Subject: r6192: remove handle->destroy function pointer, this should be done by talloc destructors now metze (This used to be commit 862226f557dddf989cbbdbfd5aa2bf6f2312fdf0) --- source4/rpc_server/handles.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index b203f45e4e..3cc9e8a425 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -30,9 +30,6 @@ static int dcesrv_handle_destructor(void *ptr) { struct dcesrv_handle *h = ptr; - if (h->destroy) { - h->destroy(h->context, h); - } DLIST_REMOVE(h->context->handles, h); talloc_free(h); return 0; @@ -52,7 +49,6 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *contex return NULL; } h->data = NULL; - h->destroy = NULL; h->context = context; h->wire_handle.handle_type = handle_type; -- cgit From 5c3a1d76ffc7b9e41846f7eaf6039f58184737a0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 18:11:15 +0000 Subject: r15379: Fix shared library build's unresolved dependencies (This used to be commit 0fafa2e59566f8f892d7dfd7dd33d0100b96a780) --- source4/rpc_server/handles.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 3cc9e8a425..6a7bf88310 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -39,7 +39,7 @@ static int dcesrv_handle_destructor(void *ptr) /* allocate a new rpc handle */ -struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *context, +_PUBLIC_ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *context, uint8_t handle_type) { struct dcesrv_handle *h; @@ -65,7 +65,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_context *contex find an internal handle given a wire handle. If the wire handle is NULL then allocate a new handle */ -struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection_context *context, +_PUBLIC_ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection_context *context, struct policy_handle *p, uint8_t handle_type) { -- cgit From 92acfc07998da1546182579ad12a063f025c9286 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 May 2006 07:35:06 +0000 Subject: r15855: more talloc_set_destructor() typesafe fixes. nearly done ... (This used to be commit 396d82a231b6e3a91178db08b706626d4d4b420c) --- source4/rpc_server/handles.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 6a7bf88310..c86550aa72 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -27,9 +27,8 @@ /* destroy a rpc handle */ -static int dcesrv_handle_destructor(void *ptr) +static int dcesrv_handle_destructor(struct dcesrv_handle *h) { - struct dcesrv_handle *h = ptr; DLIST_REMOVE(h->context->handles, h); talloc_free(h); return 0; -- 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/rpc_server/handles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index c86550aa72..4d1f2ab1ad 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -21,7 +21,7 @@ */ #include "includes.h" -#include "dlinklist.h" +#include "lib/util/dlinklist.h" #include "rpc_server/dcerpc_server.h" /* -- 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/rpc_server/handles.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 4d1f2ab1ad..03c9055e84 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.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 . */ #include "includes.h" -- cgit From b409d4120f9ae451f93a2322267c0f346531d9f3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Aug 2007 15:16:40 +0000 Subject: r24667: Finally merge the registry improvements that Wilco Baan Hofman and I have been working on for at least half a year now. Contains the following improvements: * proper layering (finally!) for the registry library. Distinction is now made between 'real' backends (local, remote, wine, etc) and the low-level hive backends (regf, creg, ldb, ...) that are only used by the local registry backend * tests for all important hive and registry operations * re-enable RPC-WINREG tests (still needs more work though, as some return values aren't checked yet) * write support for REGF files * dir backend now supports setting/reading values, creating keys * support for storing security descriptors * remove CREG backend as it was incomplete, didn't match the data model and wasn't used at all anyway * support for parsing ADM files as used by the policy editor (see lib/policy) * support for parsing PREG files (format used by .POL files) * new streaming interface for registry diffs (improves speed and memory usage for regdiff/regpatch significantly) ... and fixes a large number of bugs in the registry code (This used to be commit 7a1eec6358bc863dfc671c542b7185d3e39d7b5a) --- source4/rpc_server/handles.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/rpc_server/handles.c') diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 03c9055e84..47174b6eeb 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -59,11 +59,12 @@ _PUBLIC_ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection_contex return h; } -/* +/** find an internal handle given a wire handle. If the wire handle is NULL then allocate a new handle */ -_PUBLIC_ struct dcesrv_handle *dcesrv_handle_fetch(struct dcesrv_connection_context *context, +_PUBLIC_ struct dcesrv_handle *dcesrv_handle_fetch( + struct dcesrv_connection_context *context, struct policy_handle *p, uint8_t handle_type) { -- cgit