]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamed: convert to the new scheme and add --bus-introspect
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 Apr 2020 12:08:16 +0000 (14:08 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 5 May 2020 20:36:54 +0000 (22:36 +0200)
src/hostname/hostnamed.c

index 535c800bebc01c21792e69eb787bd854fe1a3679..701041c12adbcf16be7e47832d6e6c9c974b35f7 100644 (file)
@@ -740,6 +740,12 @@ static const sd_bus_vtable hostname_vtable[] = {
         SD_BUS_VTABLE_END,
 };
 
+static const BusObjectImplementation manager_object = {
+        "/org/freedesktop/hostname1",
+        "org.freedesktop.hostname1",
+        .vtables = BUS_VTABLES(hostname_vtable),
+};
+
 static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
         _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
         int r;
@@ -752,9 +758,9 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
         if (r < 0)
                 return log_error_errno(r, "Failed to get system bus connection: %m");
 
-        r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", hostname_vtable, c);
+        r = bus_add_implementation(bus, &manager_object, c);
         if (r < 0)
-                return log_error_errno(r, "Failed to register object: %m");
+                return r;
 
         r = bus_log_control_api_register(bus);
         if (r < 0)
@@ -783,7 +789,8 @@ static int run(int argc, char *argv[]) {
 
         r = service_parse_argv("systemd-hostnamed.service",
                                "Manage the system hostname and related metadata.",
-                               NULL,
+                               BUS_IMPLEMENTATIONS(&manager_object,
+                                                   &log_control_object),
                                argc, argv);
         if (r <= 0)
                 return r;