Merge pull request #34245 from bluca/logind_drop_weak_delay_inhibitor

logind: drop new delay-weak inhibitor
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-10-29 17:13:11 +01:00
committed by GitHub
10 changed files with 40 additions and 38 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ static int help(void) {
" handle-lid-switch\n"
" --who=STRING A descriptive string who is inhibiting\n"
" --why=STRING A descriptive string why is being inhibited\n"
" --mode=MODE One of block, block-weak, delay, or delay-weak\n"
" --mode=MODE One of block, block-weak, or delay\n"
" --list List active inhibitors\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
+1 -1
View File
@@ -3640,7 +3640,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
"Invalid mode specification %s", mode);
/* Delay is only supported for shutdown/sleep */
if (IN_SET(mm, INHIBIT_DELAY, INHIBIT_DELAY_WEAK) && (w & ~(INHIBIT_SHUTDOWN|INHIBIT_SLEEP)))
if (mm == INHIBIT_DELAY && (w & ~(INHIBIT_SHUTDOWN|INHIBIT_SLEEP)))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Delay inhibitors only supported for shutdown and sleep");
+3 -4
View File
@@ -371,7 +371,7 @@ InhibitWhat manager_inhibit_what(Manager *m, bool block) {
HASHMAP_FOREACH(i, m->inhibitors)
if (i->started &&
((!block && IN_SET(i->mode, INHIBIT_DELAY, INHIBIT_DELAY_WEAK)) ||
((!block && i->mode == INHIBIT_DELAY) ||
(block && IN_SET(i->mode, INHIBIT_BLOCK, INHIBIT_BLOCK_WEAK))))
what |= i->what;
@@ -424,13 +424,13 @@ bool manager_is_inhibited(
continue;
if ((block && !IN_SET(i->mode, INHIBIT_BLOCK, INHIBIT_BLOCK_WEAK)) ||
(!block && !IN_SET(i->mode, INHIBIT_DELAY, INHIBIT_DELAY_WEAK)))
(!block && i->mode != INHIBIT_DELAY))
continue;
if (ignore_inactive && pidref_is_active_session(m, &i->pid) <= 0)
continue;
if (IN_SET(i->mode, INHIBIT_BLOCK_WEAK, INHIBIT_DELAY_WEAK) && ignore_uid && i->uid == uid)
if (i->mode == INHIBIT_BLOCK_WEAK && ignore_uid && i->uid == uid)
continue;
if (!inhibited ||
@@ -531,7 +531,6 @@ static const char* const inhibit_mode_table[_INHIBIT_MODE_MAX] = {
[INHIBIT_BLOCK] = "block",
[INHIBIT_BLOCK_WEAK] = "block-weak",
[INHIBIT_DELAY] = "delay",
[INHIBIT_DELAY_WEAK] = "delay-weak"
};
DEFINE_STRING_TABLE_LOOKUP(inhibit_mode, InhibitMode);
-1
View File
@@ -22,7 +22,6 @@ typedef enum InhibitMode {
INHIBIT_BLOCK,
INHIBIT_BLOCK_WEAK,
INHIBIT_DELAY,
INHIBIT_DELAY_WEAK,
_INHIBIT_MODE_MAX,
_INHIBIT_MODE_INVALID = -EINVAL,
} InhibitMode;
+4
View File
@@ -204,6 +204,10 @@ int logind_check_inhibitors(enum action a) {
if (r < 0)
return bus_log_parse_error(r);
/* root respects inhibitors since v257 but keeps ignoring sessions by default */
if (arg_check_inhibitors < 0 && c == 0 && geteuid() == 0)
return 0;
/* Check for current sessions */
sd_get_sessions(&sessions);
STRV_FOREACH(s, sessions) {