mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
login: do not issue wall messages on local terminals for suspend and hibernate
Fixes: #23520 [zjs: I added the comment and tweaked the patch a bit. The call to reset_scheduled_shutdown() is moved down a bit to allow the callback to have access to information about the operation being cancelled. This all happens within the same function, so there should be no observable change in behaviour.]
This commit is contained in:
parent
51a2b575d7
commit
ea74f39c24
@ -2342,8 +2342,6 @@ 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 */
|
||||
|
||||
reset_scheduled_shutdown(m);
|
||||
|
||||
if (m->enable_wall_messages) {
|
||||
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
|
||||
_cleanup_free_ char *username = NULL;
|
||||
@ -2361,6 +2359,8 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
|
||||
username, tty, logind_wall_tty_filter, m);
|
||||
}
|
||||
|
||||
reset_scheduled_shutdown(m);
|
||||
|
||||
return sd_bus_reply_method_return(message, "b", true);
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,22 @@ _const_ static usec_t when_wall(usec_t n, usec_t elapse) {
|
||||
bool logind_wall_tty_filter(const char *tty, bool is_local, void *userdata) {
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
|
||||
assert(m->scheduled_shutdown_action);
|
||||
|
||||
const char *p = path_startswith(tty, "/dev/");
|
||||
if (!p)
|
||||
return true;
|
||||
|
||||
/* Do not write to local pseudo-terminals */
|
||||
if (startswith(p, "pts/") && is_local)
|
||||
/* Do not send information about events which do not destroy local sessions to local terminals. We
|
||||
* can assume that if the system enters sleep or hibernation, this will be visible in an obvious way
|
||||
* for any local user. And once the systems exits sleep or hibernation, the notication would be just
|
||||
* noise, in particular for auto-suspend. */
|
||||
if (is_local &&
|
||||
IN_SET(m->scheduled_shutdown_action->handle,
|
||||
HANDLE_SUSPEND,
|
||||
HANDLE_HIBERNATE,
|
||||
HANDLE_HYBRID_SLEEP,
|
||||
HANDLE_SUSPEND_THEN_HIBERNATE))
|
||||
return false;
|
||||
|
||||
return !streq_ptr(p, m->scheduled_shutdown_tty);
|
||||
|
Loading…
x
Reference in New Issue
Block a user