From 130698dc20df9438c3f5b79ddf2c1a1b16c3f8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=A4rdeman?= Date: Thu, 21 Nov 2024 20:24:06 +0100 Subject: [PATCH] logind: allow wall messages to be controlled via config file Right now, the sending of wall messages on reboot/shutdown/etc can be controlled via DBus properties. This patch adds support for changing the default via the logind.conf file as well. Note that the DBus setting is lost if logind is restarted or reloaded, but it was already the case before this patch that the setting is lost upon restart. --- man/logind.conf.xml | 15 +++++++++++++++ src/login/logind-core.c | 1 + src/login/logind-gperf.gperf | 1 + src/login/logind.c | 1 - src/login/logind.conf.in | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/man/logind.conf.xml b/man/logind.conf.xml index 66240b58fe..da41d56e7f 100644 --- a/man/logind.conf.xml +++ b/man/logind.conf.xml @@ -409,6 +409,21 @@ + + + EnableWallMessages= + + + + Controls whether + wall1 + messages should be sent to the terminals of all currently logged in users upon shutdown or + reboot. Defaults to yes, and can be changed at runtime via the DBus + EnableWallMessages and WallMessagePrefix properties. + + + + diff --git a/src/login/logind-core.c b/src/login/logind-core.c index a1c0069f69..719aeef017 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -39,6 +39,7 @@ void manager_reset_config(Manager *m) { m->remove_ipc = true; m->inhibit_delay_max = 5 * USEC_PER_SEC; m->user_stop_delay = 10 * USEC_PER_SEC; + m->enable_wall_messages = true; m->handle_action_sleep_mask = HANDLE_ACTION_SLEEP_MASK_DEFAULT; diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf index ce5af2ccfa..e7f39fed2a 100644 --- a/src/login/logind-gperf.gperf +++ b/src/login/logind-gperf.gperf @@ -54,3 +54,4 @@ Login.SessionsMax, config_parse_uint64, 0, offse Login.DesignatedMaintenanceTime, config_parse_calendar, 0, offsetof(Manager, maintenance_time) Login.UserTasksMax, config_parse_compat_user_tasks_max, 0, 0 Login.StopIdleSessionSec, config_parse_sec_fix_0, 0, offsetof(Manager, stop_idle_session_usec) +Login.EnableWallMessages, config_parse_bool, 0, offsetof(Manager, enable_wall_messages) diff --git a/src/login/logind.c b/src/login/logind.c index 8dc1781edf..186778677b 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -64,7 +64,6 @@ static int manager_new(Manager **ret) { *m = (Manager) { .console_active_fd = -EBADF, .reserve_vt_fd = -EBADF, - .enable_wall_messages = true, .idle_action_not_before_usec = now(CLOCK_MONOTONIC), .scheduled_shutdown_action = _HANDLE_ACTION_INVALID, diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in index 2e06b9a050..8adf4393c7 100644 --- a/src/login/logind.conf.in +++ b/src/login/logind.conf.in @@ -52,3 +52,4 @@ #SessionsMax=8192 #StopIdleSessionSec=infinity #DesignatedMaintenanceTime= +#EnableWallMessages=yes