run: ignore bus connection error in acquiring invocation ID (#37763)

This introduce bus_error_is_connection(), and use it where applicable.
Then, this makes connection errors in acquiring invocation ID by
systemd-run handled gracefully, like we already do other places.

Fixes #37675.
This commit is contained in:
Yu Watanabe
2025-06-07 01:55:21 +09:00
committed by GitHub
6 changed files with 27 additions and 27 deletions
+7
View File
@@ -212,6 +212,13 @@ bool bus_error_is_unknown_service(const sd_bus_error *error) {
BUS_ERROR_NO_SUCH_UNIT);
}
bool bus_error_is_connection(const sd_bus_error *error) {
return sd_bus_error_has_names(error,
SD_BUS_ERROR_NO_REPLY,
SD_BUS_ERROR_DISCONNECTED,
SD_BUS_ERROR_TIMED_OUT);
}
int bus_check_peercred(sd_bus *c) {
struct ucred ucred;
int fd, r;
+2
View File
@@ -22,7 +22,9 @@ typedef bool (*check_idle_t)(void *userdata);
int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout, check_idle_t check_idle, void *userdata);
int bus_name_has_owner(sd_bus *c, const char *name, sd_bus_error *error);
bool bus_error_is_unknown_service(const sd_bus_error *error);
bool bus_error_is_connection(const sd_bus_error *error);
int bus_check_peercred(sd_bus *c);