64 lines
2.5 KiB
Diff
64 lines
2.5 KiB
Diff
From 9524c2fd43aa3b76719cc21eb7093a5b90997fd9 Mon Sep 17 00:00:00 2001
|
|
From: Luca Boccassi <bluca@debian.org>
|
|
Date: Mon, 12 Dec 2022 15:34:43 +0000
|
|
Subject: [PATCH] manager: log unit/pid of sender when Reload() is called
|
|
|
|
Reloading is a heavy-weight operation, and currently it is not
|
|
possible to figure out who/what requested it, even at debug level
|
|
logging.
|
|
Check the sender of the D-Bus message and print it out at info level.
|
|
|
|
Conflict:code context adaptation
|
|
Reference:https://github.com/systemd/systemd/commit/9524c2fd43aa3b76719cc21eb7093a5b90997fd9
|
|
---
|
|
src/core/dbus-manager.c | 26 ++++++++++++++++++++++++++
|
|
1 file changed, 26 insertions(+)
|
|
|
|
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
index 8d7b1f60da..5c8a7d410f 100644
|
|
--- a/src/core/dbus-manager.c
|
|
+++ b/src/core/dbus-manager.c
|
|
@@ -1451,6 +1451,29 @@ int verify_run_space_and_log(const char *message) {
|
|
return 0;
|
|
}
|
|
|
|
+static void log_reload_caller(sd_bus_message *message, Manager *manager) {
|
|
+ _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
|
|
+ const char *comm = NULL;
|
|
+ Unit *caller;
|
|
+ pid_t pid;
|
|
+
|
|
+ assert(message);
|
|
+ assert(manager);
|
|
+
|
|
+ if (sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID|SD_BUS_CREDS_AUGMENT|SD_BUS_CREDS_COMM, &creds) < 0)
|
|
+ return;
|
|
+
|
|
+ /* We need at least the PID, otherwise there's nothing to log, the rest is optional */
|
|
+ if (sd_bus_creds_get_pid(creds, &pid) < 0)
|
|
+ return;
|
|
+
|
|
+ (void) sd_bus_creds_get_comm(creds, &comm);
|
|
+ caller = manager_get_unit_by_pid(manager, pid);
|
|
+
|
|
+ log_info("Reloading requested from client PID " PID_FMT " ('%s') (from unit '%s')...",
|
|
+ pid, strna(comm), strna(caller ? caller->id : NULL));
|
|
+}
|
|
+
|
|
static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
|
Manager *m = userdata;
|
|
int r;
|
|
@@ -1471,6 +1494,9 @@ static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *
|
|
if (r == 0)
|
|
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
|
|
|
|
+ /* Write a log message noting the unit or process who requested the Reload() */
|
|
+ log_reload_caller(message, m);
|
|
+
|
|
/* Instead of sending the reply back right away, we just
|
|
* remember that we need to and then send it after the reload
|
|
* is finished. That way the caller knows when the reload
|
|
--
|
|
2.33.0
|
|
|