summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-06-30 12:13:49 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2022-06-30 19:28:41 +0100
commit907506695549c689710cd267583f6fd439711dcf (patch)
treefaaf1ba736fdd578d8e76d404ac13b026e223f08 /src/login/logind-dbus.c
parentf63d1b0efa64fe716c2855a0410ac47ad67f7dec (diff)
downloadsystemd-907506695549c689710cd267583f6fd439711dcf.tar.gz
logind: log wall messages to the journal
Currently kde installs a fake utmp session to listen for this. This provides an alternative mechanism as discussed in #23574. Example with 'shutdown 6 -r' and shutdown -c': PRIORITY=6 SYSLOG_FACILITY=4 SYSLOG_IDENTIFIER=systemd-logind ... CODE_FILE=src/login/logind-utmp.c CODE_LINE=90 CODE_FUNC=warn_wall MESSAGE_ID=9e7066279dc8403da79ce4b1a69064b2 OPERATOR=root MESSAGE=The system will reboot at Thu 2022-06-30 12:16:43 CEST! ACTION=reboot PRIORITY=5 SYSLOG_FACILITY=4 SYSLOG_IDENTIFIER=systemd-logind ... OPERATOR=root CODE_FILE=src/login/logind-dbus.c CODE_LINE=2407 CODE_FUNC=method_cancel_scheduled_shutdown MESSAGE=System shutdown has been cancelled MESSAGE_ID=249f6fb9e6e2428c96f3f0875681ffa3 ACTION=reboot
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 031b96e9f1..a426842bbb 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2347,7 +2347,6 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
if (m->enable_wall_messages) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
- _cleanup_free_ char *username = NULL;
const char *tty = NULL;
uid_t uid = 0;
@@ -2357,7 +2356,14 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
(void) sd_bus_creds_get_tty(creds, &tty);
}
- username = uid_to_name(uid);
+ _cleanup_free_ char *username = uid_to_name(uid);
+
+ log_struct(LOG_INFO,
+ LOG_MESSAGE("System shutdown has been cancelled"),
+ "ACTION=%s", handle_action_to_string(a->handle),
+ "MESSAGE_ID=" SD_MESSAGE_LOGIND_SHUTDOWN_CANCELED_STR,
+ username ? "OPERATOR=%s" : NULL, username);
+
utmp_wall("System shutdown has been cancelled",
username, tty, logind_wall_tty_filter, m);
}