logind: rename EnableWallMessages= configuration knob to WallMessages= (#37553)

We generally frown on config options that are called
EnableXYZ=/DisableXYZ=, hence drop this here too. Note that the original
sin was that the pre-existing D-Bus property already used the prefix.
But given that D-Bus properties are substantially more low-level (i.e.
developer focused) than the config knobs, let's bite the bullet and
name the configuration option cleanly, even if the dbus property carries
the damn prefix.

The knob was added post v257, hence this is not a compat break.

Follow-up for: 130698dc20
This commit is contained in:
Lennart Poettering
2025-05-21 19:47:57 +02:00
committed by GitHub
parent 3c70cbae0f
commit dfc9fd0147
7 changed files with 17 additions and 14 deletions

View File

@@ -411,13 +411,16 @@
</varlistentry>
<varlistentry>
<term><varname>EnableWallMessages=</varname></term>
<term><varname>WallMessages=</varname></term>
<listitem>
<!-- NB: the configuration file setting lacks the "Enable" prefix that the dbus property has. It
was a mistake to have that prefix, as we generally frown on useless Enable/Disables prefix of
configuration knobs. -->
<para>
Controls whether
<citerefentry><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry>
messages should be sent to the terminals of all currently logged in users upon shutdown or
<citerefentry><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry> messages
should be sent to the terminals of all currently logged in users upon shutdown or
reboot. Defaults to <literal>yes</literal>, and can be changed at runtime via the DBus
<literal>EnableWallMessages</literal> and <literal>WallMessagePrefix</literal> properties.
</para>

View File

@@ -42,7 +42,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->wall_messages = true;
m->handle_action_sleep_mask = HANDLE_ACTION_SLEEP_MASK_DEFAULT;

View File

@@ -2595,7 +2595,7 @@ static int update_schedule_file(Manager *m) {
(void) fchmod(fileno(f), 0644);
serialize_usec(f, "USEC", m->scheduled_shutdown_timeout);
serialize_item_format(f, "WARN_WALL", "%s", one_zero(m->enable_wall_messages));
serialize_item_format(f, "WARN_WALL", "%s", one_zero(m->wall_messages));
serialize_item_format(f, "MODE", "%s", handle_action_to_string(m->scheduled_shutdown_action));
serialize_item_format(f, "UID", UID_FMT, m->scheduled_shutdown_uid);
@@ -2747,7 +2747,7 @@ void manager_load_scheduled_shutdown(Manager *m) {
if (r < 0)
log_debug_errno(r, "Failed to parse enabling wall messages");
else
m->enable_wall_messages = r;
m->wall_messages = r;
}
if (wall_message) {
@@ -2876,7 +2876,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (m->enable_wall_messages) {
if (m->wall_messages) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
const char *tty = NULL;
uid_t uid = 0;
@@ -3745,7 +3745,7 @@ static int method_set_wall_message(
/* Short-circuit the operation if the desired state is already in place, to
* avoid an unnecessary polkit permission check. */
if (streq_ptr(m->wall_message, empty_to_null(wall_message)) &&
m->enable_wall_messages == enable_wall_messages)
m->wall_messages == enable_wall_messages)
goto done;
r = bus_verify_polkit_async(
@@ -3763,7 +3763,7 @@ static int method_set_wall_message(
if (r < 0)
return log_oom();
m->enable_wall_messages = enable_wall_messages;
m->wall_messages = enable_wall_messages;
done:
return sd_bus_reply_method_return(message, NULL);
@@ -3902,7 +3902,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
static const sd_bus_vtable manager_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_WRITABLE_PROPERTY("EnableWallMessages", "b", bus_property_get_bool, bus_property_set_bool, offsetof(Manager, enable_wall_messages), 0),
SD_BUS_WRITABLE_PROPERTY("EnableWallMessages", "b", bus_property_get_bool, bus_property_set_bool, offsetof(Manager, wall_messages), 0),
SD_BUS_WRITABLE_PROPERTY("WallMessage", "s", NULL, NULL, offsetof(Manager, wall_message), 0),
SD_BUS_PROPERTY("NAutoVTs", "u", NULL, offsetof(Manager, n_autovts), SD_BUS_VTABLE_PROPERTY_CONST),

View File

@@ -56,4 +56,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)
Login.WallMessages, config_parse_bool, 0, offsetof(Manager, wall_messages)

View File

@@ -81,7 +81,7 @@ static int warn_wall(Manager *m, usec_t n) {
LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN_SCHEDULED_STR),
username ? "OPERATOR=%s" : NULL, username);
if (m->enable_wall_messages)
if (m->wall_messages)
(void) wall(l, username, m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
return 1;

View File

@@ -52,4 +52,4 @@
#SessionsMax=8192
#StopIdleSessionSec=infinity
#DesignatedMaintenanceTime=
#EnableWallMessages=yes
#WallMessages=yes

View File

@@ -71,7 +71,7 @@ typedef struct Manager {
bool unlink_nologin;
char *wall_message;
bool enable_wall_messages;
bool wall_messages;
sd_event_source *wall_message_timeout_source;
bool shutdown_dry_run;