"Failed to set bus address: %m");
}
-int bus_log_connect_error(int r, BusTransport transport, RuntimeScope scope) {
+int bus_log_connect_full(int log_level, int r, BusTransport transport, RuntimeScope scope) {
bool hint_vars = transport == BUS_TRANSPORT_LOCAL && r == -ENOMEDIUM,
hint_addr = transport == BUS_TRANSPORT_LOCAL && ERRNO_IS_PRIVILEGE(r);
- return log_error_errno(r,
- hint_vars ? "Failed to connect to %s scope bus via %s transport: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" :
- hint_addr ? "Failed to connect to %s scope bus via %s transport: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user)" :
- "Failed to connect to %s scope bus via %s transport: %m", runtime_scope_to_string(scope), bus_transport_to_string(transport));
+ return log_full_errno(log_level, r,
+ hint_vars ? "Failed to connect to %s scope bus via %s transport: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" :
+ hint_addr ? "Failed to connect to %s scope bus via %s transport: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user)" :
+ "Failed to connect to %s scope bus via %s transport: %m", runtime_scope_to_string(scope), bus_transport_to_string(transport));
}
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name) {
int bus_connect_transport_systemd(BusTransport transport, const char *host, RuntimeScope runtime_scope, sd_bus **bus);
int bus_log_address_error(int r, BusTransport transport);
-int bus_log_connect_error(int r, BusTransport transport, RuntimeScope scope);
+int bus_log_connect_full(int log_level, int r, BusTransport transport, RuntimeScope scope);
+static inline int bus_log_connect_error(int r, BusTransport transport, RuntimeScope scope) {
+ return bus_log_connect_full(LOG_ERR, r, transport, scope);
+}
#define bus_log_parse_error(r) \
log_error_errno(r, "Failed to parse bus message: %m")
if (!actions[a])
return -EINVAL;
- r = acquire_bus(BUS_FULL, &bus);
+ r = acquire_bus_full(BUS_FULL, /* graceful = */ true, &bus);
if (r < 0)
return r;
if (arg_transport != BUS_TRANSPORT_LOCAL)
return 0;
- r = acquire_bus(BUS_FULL, &bus);
+ r = acquire_bus_full(BUS_FULL, /* graceful = */ true, &bus);
if (r == -ECONNREFUSED && geteuid() == 0)
return 0; /* When D-Bus is not running, allow root to force a shutdown. E.g. when running at
* the emergency console. */
static sd_bus *buses[_BUS_FOCUS_MAX] = {};
-int acquire_bus(BusFocus focus, sd_bus **ret) {
+int acquire_bus_full(BusFocus focus, bool graceful, sd_bus **ret) {
int r;
assert(focus < _BUS_FOCUS_MAX);
else
r = bus_connect_transport(arg_transport, arg_host, arg_runtime_scope, &buses[focus]);
if (r < 0)
- return bus_log_connect_error(r, arg_transport, arg_runtime_scope);
+ return bus_log_connect_full(graceful && focus == BUS_FULL && r == -ECONNREFUSED ? LOG_DEBUG : LOG_ERR,
+ r, arg_transport, arg_runtime_scope);
(void) sd_bus_set_allow_interactive_authorization(buses[focus], arg_ask_password);
}
_BUS_FOCUS_MAX
} BusFocus;
-int acquire_bus(BusFocus focus, sd_bus **ret);
+int acquire_bus_full(BusFocus focus, bool graceful, sd_bus **ret);
+static inline int acquire_bus(BusFocus focus, sd_bus **ret) {
+ return acquire_bus_full(focus, false, ret);
+}
void release_busses(void);
void ask_password_agent_open_maybe(void);