72 lines
3.1 KiB
Diff
72 lines
3.1 KiB
Diff
From 4389fea50bbb0810ed9193522c487257ca0b5d2d Mon Sep 17 00:00:00 2001
|
|
From: Daan De Meyer <daan.j.demeyer@gmail.com>
|
|
Date: Tue, 8 Oct 2024 16:28:25 +0200
|
|
Subject: [PATCH] core: Log in more scenarios about which process initiated an
|
|
operation
|
|
|
|
Exit/Reboot/Poweroff and similar operations are invasive enough that
|
|
logging about who initiated them is very useful to debug issues.
|
|
|
|
(cherry picked from commit acb0f501f4291efce82bcf89d4ad92b6a895f4fa)
|
|
(cherry picked from commit 814be7116dda14074749253d94b83387ceff0ff1)
|
|
(cherry picked from commit 4ce745446386bae450114c6fc2278577a7cf46f4)
|
|
|
|
Conflict:the current code does not have the method_soft_reboot function, so the related code is not combined
|
|
Reference:https://github.com/systemd/systemd/commit/acb0f501f4291efce82bcf89d4ad92b6a895f4fa
|
|
---
|
|
src/core/dbus-manager.c | 12 ++++++++++++
|
|
1 file changed, 12 insertions(+)
|
|
|
|
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
index 90c1daf995..856dd3b5dc 100644
|
|
--- a/src/core/dbus-manager.c
|
|
+++ b/src/core/dbus-manager.c
|
|
@@ -1706,6 +1706,8 @@ static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *er
|
|
if (r < 0)
|
|
return r;
|
|
|
|
+ log_caller(message, m, "Exit");
|
|
+
|
|
/* Exit() (in contrast to SetExitCode()) is actually allowed even if
|
|
* we are running on the host. It will fall back on reboot() in
|
|
* systemd-shutdown if it cannot do the exit() because it isn't a
|
|
@@ -1730,6 +1732,8 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
"Reboot is only supported for system managers.");
|
|
|
|
+ log_caller(message, m, "Reboot");
|
|
+
|
|
m->objective = MANAGER_REBOOT;
|
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
|
@@ -1792,6 +1798,8 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
"Powering off is only supported for system managers.");
|
|
|
|
+ log_caller(message, m, "Poweroff");
|
|
+
|
|
m->objective = MANAGER_POWEROFF;
|
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
|
@@ -1811,6 +1819,8 @@ static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *er
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
"Halt is only supported for system managers.");
|
|
|
|
+ log_caller(message, m, "Halt");
|
|
+
|
|
m->objective = MANAGER_HALT;
|
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
|
@@ -1830,6 +1840,8 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
"KExec is only supported for system managers.");
|
|
|
|
+ log_caller(message, m, "Kexec");
|
|
+
|
|
m->objective = MANAGER_KEXEC;
|
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
|
--
|
|
2.33.0
|
|
|