From 2dd9c1219a622b8bd6247e0eb0063d69d4e7e77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20L=C3=B3pez?= Date: Mon, 7 Oct 2024 13:36:36 +0200 Subject: [PATCH] MONITOR: Set destructor for the right connection When the monitor receives a `sssd.monitor.RegisterService` D-Bus method, it is received on the listening connection and not on the client's connection. Because of this, the destructor is set for to the listening connection (taken from the sbus_request) and instead of the client connection. The client connection can be retrieved searching it by the sender's name in the `sbus_server` accessible from the `mt_ctx`, to set the destructor to the correct connection in the function `monitor_sbus_RegisterService()`. Resolves: https://github.com/SSSD/sssd/issues/6897 --- src/monitor/monitor.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 6366c0dee12..1c20bba3499 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -37,10 +37,12 @@ #include #include "util/sss_ini.h" +#include "util/sss_ptr_hash.h" #include "confdb/confdb.h" #include "confdb/confdb_setup.h" #include "db/sysdb.h" #include "sss_iface/sss_iface_async.h" +#include "sbus/sbus_private.h" #ifdef HAVE_SYSTEMD #include @@ -261,7 +263,12 @@ monitor_sbus_RegisterService(TALLOC_CTX *mem_ctx, } /* Fill in svc structure with connection data */ - svc->conn = sbus_req->conn; + svc->conn = sss_ptr_hash_lookup(mt_ctx->sbus_server->names, sbus_req->sender->name, struct sbus_connection); + if (svc->conn == NULL) { + /* Can this even happen? + * Let's stay on the safe side by falling back to the old behavior. */ + svc->conn = sbus_req->conn; + } /* For {dbus,socket}-activated services we will have to unregister then * when the sbus_connection is freed. That's the reason we have to