]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamectl: convert more hostname1 calls to BusLocator
authorDavid Tardon <dtardon@redhat.com>
Tue, 23 May 2023 18:40:47 +0000 (20:40 +0200)
committerDavid Tardon <dtardon@redhat.com>
Wed, 24 May 2023 06:33:22 +0000 (08:33 +0200)
src/hostname/hostnamectl.c

index a0e949d82c7d9d4142c3172aa073749ed6a17f6a..8d3cca5c6215c495dee77f765140f48660ab8dc9 100644 (file)
@@ -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));