From 971fb3b0bc5c4cf22517894de50fee7279a48770 Mon Sep 17 00:00:00 2001 From: Nick Rosbrook Date: Mon, 24 Mar 2025 09:06:33 -0400 Subject: [PATCH] polkit: use -EBUSY to indicate shortcut after error or denial Commit 536c18e5c3 ("bus-polkit: shortcut auth. after first denial") added logic to async_polkit_query_check_action() that returns -EALREADY when a failure or denial decision was made for a previous action. Tweak this to return -EBUSY instead of -EALREADY. This hopefully makes the intent of the error more clear. EALREADY suggests that the request is OK, but polkit is processing something else, and we should come back later. EBUSY suggests that polkit is busy or unusable, hence the request cannot be processed, and we should go away. --- src/login/logind-dbus.c | 8 ++++---- src/shared/bus-polkit.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b0b7cf6cc01..ed0db4a2ffc 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2207,10 +2207,10 @@ static int verify_shutdown_creds( &m->polkit_registry, error); if (r < 0) { - /* If we get -EALREADY, it means a polkit decision was made, but not for + /* If we get -EBUSY, it means a polkit decision was made, but not for * this action in particular. Assuming we are blocked on inhibitors, * ignore that error and allow the decision to be revealed below. */ - if (blocked && r == -EALREADY) + if (blocked && r == -EBUSY) error_or_denial = true; else return r; @@ -3817,10 +3817,10 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error &m->polkit_registry, error); if (r < 0) { - /* If we get -EALREADY, it means a polkit decision was made, but not for + /* If we get -EBUSY, it means a polkit decision was made, but not for * this action in particular. Assuming there are more actions requested, * ignore that error and allow the decision to be revealed later. */ - if ((~v & w) && r == -EALREADY) + if ((~v & w) && r == -EBUSY) error_or_denial = true; else return r; diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c index 2e275f9da27..9cd0d6c677e 100644 --- a/src/shared/bus-polkit.c +++ b/src/shared/bus-polkit.c @@ -440,7 +440,7 @@ static int async_polkit_query_check_action( /* Also deny if we've got an auth. failure for a previous action */ if (q->denied_action || q->error_action) - return -EALREADY; + return -EBUSY; return 0; /* no reply yet */ } -- 2.47.3