Merge pull request #21229 from keszybz/improve-m-hint
Improve hint to use -M in various tools
This commit is contained in:
@@ -34,6 +34,24 @@ static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bus_log_address_error(int r, BusTransport transport) {
|
||||
bool hint = transport == BUS_TRANSPORT_LOCAL && r == -ENOMEDIUM;
|
||||
|
||||
return log_error_errno(r,
|
||||
hint ? "Failed to set bus address: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" :
|
||||
"Failed to set bus address: %m");
|
||||
}
|
||||
|
||||
int bus_log_connect_error(int r, BusTransport transport) {
|
||||
bool hint_vars = transport == BUS_TRANSPORT_LOCAL && r == -ENOMEDIUM,
|
||||
hint_addr = transport == BUS_TRANSPORT_LOCAL && ERRNO_IS_PRIVILEGE(r);
|
||||
|
||||
return log_error_errno(r,
|
||||
r == hint_vars ? "Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" :
|
||||
r == hint_addr ? "Failed to connect to bus: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user)" :
|
||||
"Failed to connect to bus: %m");
|
||||
}
|
||||
|
||||
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name) {
|
||||
const char *match;
|
||||
const char *unique;
|
||||
|
||||
+2
-16
@@ -39,22 +39,8 @@ int bus_connect_user_systemd(sd_bus **_bus);
|
||||
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||
|
||||
#define bus_log_address_error(r) \
|
||||
({ \
|
||||
int _k = (r); \
|
||||
log_error_errno(_k, \
|
||||
_k == -ENOMEDIUM ? "Failed to set bus address: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" : \
|
||||
"Failed to set bus address: %m"); \
|
||||
})
|
||||
|
||||
#define bus_log_connect_error(r) \
|
||||
({ \
|
||||
int _k = (r); \
|
||||
log_error_errno(_k, \
|
||||
_k == -ENOMEDIUM ? "Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)" : \
|
||||
ERRNO_IS_PRIVILEGE(_k) ? "Failed to connect to bus: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user)" : \
|
||||
"Failed to connect to bus: %m"); \
|
||||
})
|
||||
int bus_log_address_error(int r, BusTransport transport);
|
||||
int bus_log_connect_error(int r, BusTransport transport);
|
||||
|
||||
#define bus_log_parse_error(r) \
|
||||
log_error_errno(r, "Failed to parse bus message: %m")
|
||||
|
||||
@@ -447,7 +447,7 @@ int show_cgroup_get_path_and_warn(
|
||||
|
||||
r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r);
|
||||
return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
|
||||
|
||||
r = show_cgroup_get_unit_path_and_warn(bus, unit, &root);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user