Skip to content

Commit

Permalink
MONITOR: Set destructor for the right connection
Browse files Browse the repository at this point in the history
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: #6897
  • Loading branch information
aplopez committed Oct 7, 2024
1 parent e4f4eec commit 2dd9c12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
#include <sys/prctl.h>

#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 <systemd/sd-daemon.h>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2dd9c12

Please sign in to comment.