summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-10-05 11:45:41 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-02-02 12:44:20 +0100
commit6747b89b3ce0e234c6129696825c59b68cada8cd (patch)
tree21f4f20ec8930d7e87026cc785a79c6b7d8a550f /source3
parentc31ee9a152d64c8236cc20af1a78ac0feb999f81 (diff)
downloadsamba-6747b89b3ce0e234c6129696825c59b68cada8cd.tar.gz
samba-6747b89b3ce0e234c6129696825c59b68cada8cd.tar.bz2
samba-6747b89b3ce0e234c6129696825c59b68cada8cd.zip
s3-epmapper: Added epm_Delete function.
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_epmapper.c94
1 files changed, 87 insertions, 7 deletions
diff --git a/source3/rpc_server/srv_epmapper.c b/source3/rpc_server/srv_epmapper.c
index 4629ec352e..cbaaad1c5b 100644
--- a/source3/rpc_server/srv_epmapper.c
+++ b/source3/rpc_server/srv_epmapper.c
@@ -78,6 +78,20 @@ static const struct dcesrv_iface *find_interface(const struct dcesrv_endpoint *e
return NULL;
}
+static struct dcesrv_iface_list *find_interface_list(const struct dcesrv_endpoint *endpoint,
+ const struct dcesrv_iface *iface)
+{
+ struct dcesrv_iface_list *iflist;
+
+ for (iflist = endpoint->iface_list; iflist; iflist = iflist->next) {
+ if (interface_match(iflist->iface, iface)) {
+ return iflist;
+ }
+ }
+
+ return NULL;
+}
+
/*
* Check if two endpoints match.
*/
@@ -271,17 +285,83 @@ done:
/*
- epm_Delete
-*/
+ * epm_Delete
+ *
+ * Delete the specified entries from an endpoint map.
+ */
error_status_t _epm_Delete(struct pipes_struct *p,
- struct epm_Delete *r)
+ struct epm_Delete *r)
{
- /* Check if we have a priviledged pipe/handle */
+ TALLOC_CTX *tmp_ctx;
+ error_status_t rc;
+ NTSTATUS status;
+ uint32_t i;
- /* Delete the entry */
+ DEBUG(3, ("_epm_Delete: Trying to delete %u entries.\n",
+ r->in.num_ents));
- p->rng_fault_state = true;
- return EPMAPPER_STATUS_CANT_PERFORM_OP;
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
+ return EPMAPPER_STATUS_NO_MEMORY;
+ }
+
+ /* TODO Check if we have a priviledged pipe/handle */
+
+ for (i = 0; i < r->in.num_ents; i++) {
+ struct dcerpc_binding *b = NULL;
+ struct dcesrv_endpoint *ep;
+ struct dcesrv_iface iface;
+ struct dcesrv_iface_list *iflist;
+
+ status = dcerpc_binding_from_tower(tmp_ctx,
+ &r->in.entries[i].tower->tower,
+ &b);
+ if (!NT_STATUS_IS_OK(status)) {
+ rc = EPMAPPER_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ DEBUG(3, ("_epm_Delete: Deleting transport '%s' for '%s'\n",
+ derpc_transport_string_by_transport(b->transport),
+ r->in.entries[i].annotation));
+
+ ep = find_endpoint(endpoint_table, b);
+ if (ep == NULL) {
+ rc = EPMAPPER_STATUS_OK;
+ goto done;
+ }
+
+ iface.name = r->in.entries[i].annotation;
+ iface.syntax_id = b->object;
+
+ iflist = find_interface_list(ep, &iface);
+ if (iflist == NULL) {
+ DEBUG(0, ("_epm_Delete: No interfaces left, delete endpoint\n"));
+ DLIST_REMOVE(endpoint_table, ep);
+ talloc_free(ep);
+
+ rc = EPMAPPER_STATUS_OK;
+ goto done;
+ }
+
+ DLIST_REMOVE(ep->iface_list, iflist);
+
+ if (ep->iface_list == NULL) {
+ DEBUG(0, ("_epm_Delete: No interfaces left, delete endpoint\n"));
+ DLIST_REMOVE(endpoint_table, ep);
+ talloc_free(ep);
+
+ rc = EPMAPPER_STATUS_OK;
+ goto done;
+ }
+
+ }
+
+ rc = EPMAPPER_STATUS_OK;
+done:
+ talloc_free(tmp_ctx);
+
+ return rc;
}