summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@samba.org>2020-06-26 17:20:32 +0200
committerAndrew Bartlett <abartlet@samba.org>2021-04-07 09:18:30 +0000
commitaac8be5419fdd5e222263e3558d556c1d1dc4cef (patch)
treee4c01cc4911dabed083a848e59f55eff2a4f9ef6 /source3
parentf5178ef11e675b07ff49c8f1e0b1e193fc0babb2 (diff)
downloadsamba-aac8be5419fdd5e222263e3558d556c1d1dc4cef.tar.gz
s3: rpc_server: Store new association groups in the id tree
Right now a new association group is created for each connection assigning the legacy 0x53F0 id, but it is not stored anywhere. When a second client request to join an association group by its id it is not found and a new one is created with the same ID. In practise, it means the association groups are not working even in the same server process. This commit stores the created association group in the idtree, but to make use of it assigns a random id instead of the historical 0x53F0. The test assoc_group_ok2 was wrongly passing before this change because the same id 0x53F0 was assigned to all association groups. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/rpc_server.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index 35cc1de9081..b96bd90daf0 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -612,8 +612,19 @@ void dcesrv_log_successful_authz(
TALLOC_FREE(frame);
}
-static NTSTATUS dcesrv_assoc_group_new(struct dcesrv_call_state *call,
- uint32_t assoc_group_id)
+static int dcesrv_assoc_group_destructor(struct dcesrv_assoc_group *assoc_group)
+{
+ int ret;
+ ret = idr_remove(assoc_group->dce_ctx->assoc_groups_idr,
+ assoc_group->id);
+ if (ret != 0) {
+ DBG_ERR("Failed to remove assoc_group 0x%08x\n",
+ assoc_group->id);
+ }
+ return 0;
+}
+
+static NTSTATUS dcesrv_assoc_group_new(struct dcesrv_call_state *call)
{
struct dcesrv_connection *conn = call->conn;
struct dcesrv_context *dce_ctx = conn->dce_ctx;
@@ -621,18 +632,30 @@ static NTSTATUS dcesrv_assoc_group_new(struct dcesrv_call_state *call,
enum dcerpc_transport_t transport =
dcerpc_binding_get_transport(endpoint->ep_description);
struct dcesrv_assoc_group *assoc_group = NULL;
+ int id;
assoc_group = talloc_zero(conn, struct dcesrv_assoc_group);
if (assoc_group == NULL) {
return NT_STATUS_NO_MEMORY;
}
+ id = idr_get_new_random(dce_ctx->assoc_groups_idr,
+ assoc_group,
+ UINT16_MAX);
+ if (id == -1) {
+ TALLOC_FREE(assoc_group);
+ DBG_ERR("Out of association groups!\n");
+ return NT_STATUS_RPC_OUT_OF_RESOURCES;
+ }
+
assoc_group->transport = transport;
- assoc_group->id = assoc_group_id;
+ assoc_group->id = id;
assoc_group->dce_ctx = dce_ctx;
call->conn->assoc_group = assoc_group;
+ talloc_set_destructor(assoc_group, dcesrv_assoc_group_destructor);
+
return NT_STATUS_OK;
}
@@ -658,7 +681,7 @@ static NTSTATUS dcesrv_assoc_group_reference(struct dcesrv_call_state *call,
DBG_NOTICE("Failed to find assoc_group 0x%08x in this "
"server process, creating a new one\n",
assoc_group_id);
- return dcesrv_assoc_group_new(call, assoc_group_id);
+ return dcesrv_assoc_group_new(call);
}
assoc_group = talloc_get_type_abort(id_ptr, struct dcesrv_assoc_group);
@@ -691,7 +714,7 @@ NTSTATUS dcesrv_assoc_group_find(
}
/* If not requested by client create a new association group */
- return dcesrv_assoc_group_new(call, 0x53F0);
+ return dcesrv_assoc_group_new(call);
}
void dcesrv_transport_terminate_connection(struct dcesrv_connection *dce_conn,