busctl: do not print hint about -M if -M is already used

(Or when -H is used, since -H and -M are incompatible.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-11-04 10:41:47 +01:00
parent 237fbb6719
commit fb293b3c0f
3 changed files with 7 additions and 5 deletions

View File

@@ -125,7 +125,7 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
}
}
if (r < 0)
return bus_log_address_error(r);
return bus_log_address_error(r, arg_transport);
r = sd_bus_start(bus);
if (r < 0)

View File

@@ -34,10 +34,12 @@ static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_
return 1;
}
int bus_log_address_error(int r) {
int bus_log_address_error(int r, BusTransport transport) {
bool hint = transport == BUS_TRANSPORT_LOCAL && r == -ENOMEDIUM;
return log_error_errno(r,
r == -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");
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) {

View File

@@ -39,7 +39,7 @@ 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);
int bus_log_address_error(int r);
int bus_log_address_error(int r, BusTransport transport);
int bus_log_connect_error(int r);
#define bus_log_parse_error(r) \