summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-05-23 09:46:04 +0200
committerLuca Boccassi <bluca@debian.org>2024-06-12 00:17:38 +0200
commitec8bbd8adb9463471803aadd9a8ba2a326d7a49d (patch)
tree6afe19876525da59f131e668b2f17a66db589479 /src
parenthostnamed: don't allow hostnamed to exit on idle if varlink connections are s... (diff)
downloadsystemd-ec8bbd8adb9463471803aadd9a8ba2a326d7a49d.tar.xz
systemd-ec8bbd8adb9463471803aadd9a8ba2a326d7a49d.zip
tree-wide: never consider service idle if polkit authentication is still pending
Let's be correct on this.
Diffstat (limited to 'src')
-rw-r--r--src/import/importd.c5
-rw-r--r--src/locale/localed.c14
-rw-r--r--src/machine/machined.c5
-rw-r--r--src/portable/portabled.c5
-rw-r--r--src/timedate/timedated.c14
5 files changed, 36 insertions, 7 deletions
diff --git a/src/import/importd.c b/src/import/importd.c
index 3bfa3cdd75..2ecffdec4e 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -1728,9 +1728,10 @@ static int manager_add_bus_objects(Manager *m) {
}
static bool manager_check_idle(void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
- return hashmap_isempty(m->transfers);
+ return hashmap_isempty(m->transfers) &&
+ hashmap_isempty(m->polkit_registry);
}
static void manager_parse_env(Manager *m) {
diff --git a/src/locale/localed.c b/src/locale/localed.c
index c0d104578d..062744519d 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -622,6 +622,12 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
return 0;
}
+static bool context_check_idle(void *userdata) {
+ Context *c = ASSERT_PTR(userdata);
+
+ return hashmap_isempty(c->polkit_registry);
+}
+
static int run(int argc, char *argv[]) {
_cleanup_(context_clear) Context context = {};
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
@@ -662,7 +668,13 @@ static int run(int argc, char *argv[]) {
if (r < 0)
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
- r = bus_event_loop_with_idle(event, bus, "org.freedesktop.locale1", DEFAULT_EXIT_USEC, NULL, NULL);
+ r = bus_event_loop_with_idle(
+ event,
+ bus,
+ "org.freedesktop.locale1",
+ DEFAULT_EXIT_USEC,
+ context_check_idle,
+ &context);
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");
diff --git a/src/machine/machined.c b/src/machine/machined.c
index d7087e4672..398375bc5e 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -311,7 +311,7 @@ static int manager_startup(Manager *m) {
}
static bool check_idle(void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
if (m->operations)
return false;
@@ -322,6 +322,9 @@ static bool check_idle(void *userdata) {
if (varlink_server_current_connections(m->varlink_machine_server) > 0)
return false;
+ if (!hashmap_isempty(m->polkit_registry))
+ return false;
+
manager_gc(m, true);
return hashmap_isempty(m->machines);
diff --git a/src/portable/portabled.c b/src/portable/portabled.c
index d46ac018a3..0286bf59e7 100644
--- a/src/portable/portabled.c
+++ b/src/portable/portabled.c
@@ -117,9 +117,10 @@ static int manager_startup(Manager *m) {
}
static bool check_idle(void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
- return !m->operations;
+ return !m->operations &&
+ hashmap_isempty(m->polkit_registry);
}
static int run(int argc, char *argv[]) {
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index e3b4367ec0..b4cc5f9dd5 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -1118,6 +1118,12 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
return 0;
}
+static bool context_check_idle(void *userdata) {
+ Context *c = ASSERT_PTR(userdata);
+
+ return hashmap_isempty(c->polkit_registry);
+}
+
static int run(int argc, char *argv[]) {
_cleanup_(context_clear) Context context = {};
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
@@ -1164,7 +1170,13 @@ static int run(int argc, char *argv[]) {
if (r < 0)
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
- r = bus_event_loop_with_idle(event, bus, "org.freedesktop.timedate1", DEFAULT_EXIT_USEC, NULL, NULL);
+ r = bus_event_loop_with_idle(
+ event,
+ bus,
+ "org.freedesktop.timedate1",
+ DEFAULT_EXIT_USEC,
+ context_check_idle,
+ &context);
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");