mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
systemctl: downgrade log level of ECONNREFUSED from system dbus.service
To suppress log message when 'systemctl poweroff' or friends invoked in rescue shell, which does not have dbus.service.
This commit is contained in:
parent
77064620d7
commit
c577fe65f3
@ -51,14 +51,14 @@ int bus_log_address_error(int r, BusTransport transport) {
|
||||
"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) {
|
||||
|
@ -48,7 +48,10 @@ int bus_connect_transport(BusTransport transport, const char *host, RuntimeScope
|
||||
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")
|
||||
|
@ -66,7 +66,7 @@ int logind_reboot(enum action a) {
|
||||
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;
|
||||
|
||||
@ -151,7 +151,7 @@ int logind_check_inhibitors(enum action a) {
|
||||
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. */
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
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);
|
||||
@ -54,7 +54,8 @@ int acquire_bus(BusFocus focus, sd_bus **ret) {
|
||||
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);
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ typedef enum BusFocus {
|
||||
_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);
|
||||
|
Loading…
Reference in New Issue
Block a user