From: David Tardon Date: Tue, 23 May 2023 18:40:47 +0000 (+0200) Subject: hostnamectl: convert more hostname1 calls to BusLocator X-Git-Tag: v254-rc1~397^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d14bd34f2568ec9ceec4515dc59a175a6b8c4d54;p=thirdparty%2Fsystemd.git hostnamectl: convert more hostname1 calls to BusLocator --- diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index a0e949d82c7..8d3cca5c621 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -15,6 +15,7 @@ #include "build.h" #include "bus-common-errors.h" #include "bus-error.h" +#include "bus-locator.h" #include "bus-map-properties.h" #include "format-table.h" #include "hostname-setup.h" @@ -298,13 +299,7 @@ static int get_one_name(sd_bus *bus, const char* attr, char **ret) { /* This obtains one string property, and copy it if 'ret' is set, or print it otherwise. */ - r = sd_bus_get_property( - bus, - "org.freedesktop.hostname1", - "/org/freedesktop/hostname1", - "org.freedesktop.hostname1", - attr, - &error, &reply, "s"); + r = bus_get_property(bus, bus_hostname, attr, &error, &reply, "s"); if (r < 0) return log_error_errno(r, "Could not get property: %s", bus_error_message(&error, r)); @@ -408,15 +403,7 @@ static int show_status(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; const char *text = NULL; - r = sd_bus_call_method( - bus, - "org.freedesktop.hostname1", - "/org/freedesktop/hostname1", - "org.freedesktop.hostname1", - "Describe", - &error, - &reply, - NULL); + r = bus_call_method(bus, bus_hostname, "Describe", &error, &reply, NULL); if (r < 0) return log_error_errno(r, "Could not get description: %s", bus_error_message(&error, r)); @@ -448,14 +435,7 @@ static int set_simple_string_internal(sd_bus *bus, sd_bus_error *error, const ch if (!error) error = &e; - r = sd_bus_call_method( - bus, - "org.freedesktop.hostname1", - "/org/freedesktop/hostname1", - "org.freedesktop.hostname1", - method, - error, NULL, - "sb", value, arg_ask_password); + r = bus_call_method(bus, bus_hostname, method, error, NULL, "sb", value, arg_ask_password); if (r < 0) return log_error_errno(r, "Could not set %s: %s", target, bus_error_message(error, r));