From d4cc0edfced262b34be4e113bd527e651f1f0024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 28 Apr 2020 17:55:34 +0200 Subject: [PATCH] importd,logind: add --bus-introspect= option --- src/hostname/hostnamed.c | 1 + src/import/importd.c | 2 ++ src/locale/localed.c | 1 + src/login/logind.c | 2 ++ src/machine/machined.c | 1 + src/resolve/resolved.c | 1 + src/shared/service-util.c | 14 ++++++++++++-- src/shared/service-util.h | 3 +++ src/timedate/timedated.c | 1 + 9 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index b2b5299b32..535c800beb 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -783,6 +783,7 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-hostnamed.service", "Manage the system hostname and related metadata.", + NULL, argc, argv); if (r <= 0) return r; diff --git a/src/import/importd.c b/src/import/importd.c index 398b2964b0..9408edece1 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -1376,6 +1376,8 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-importd.service", "VM and container image import and export service.", + BUS_IMPLEMENTATIONS(&manager_object, + &log_control_object), argc, argv); if (r <= 0) return r; diff --git a/src/locale/localed.c b/src/locale/localed.c index a0fcadcc91..ef73448854 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -757,6 +757,7 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-localed.service", "Manage system locale settings and key mappings.", + NULL, argc, argv); if (r <= 0) return r; diff --git a/src/login/logind.c b/src/login/logind.c index 1bf1f21f00..d748e8f4b8 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1180,6 +1180,8 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-logind.service", "Manager for user logins and devices and privileged operations.", + BUS_IMPLEMENTATIONS(&manager_object, + &log_control_object), argc, argv); if (r <= 0) return r; diff --git a/src/machine/machined.c b/src/machine/machined.c index 191031e2aa..5a24f6ccc8 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -360,6 +360,7 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-machined.service", "Manage registrations of local VMs and containers.", + NULL, argc, argv); if (r <= 0) return r; diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c index 73da508d7a..6f2b4c114e 100644 --- a/src/resolve/resolved.c +++ b/src/resolve/resolved.c @@ -28,6 +28,7 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-resolved.service", "Provide name resolution with caching using DNS, mDNS, LLMNR.", + NULL, argc, argv); if (r <= 0) return r; diff --git a/src/shared/service-util.c b/src/shared/service-util.c index 7fea74d2d9..c9b684fc05 100644 --- a/src/shared/service-util.c +++ b/src/shared/service-util.c @@ -9,7 +9,7 @@ #include "terminal-util.h" #include "util.h" -static int help(const char *program_path, const char *service, const char *description) { +static int help(const char *program_path, const char *service, const char *description, bool bus_introspect) { _cleanup_free_ char *link = NULL; int r; @@ -23,6 +23,7 @@ static int help(const char *program_path, const char *service, const char *descr "%sOptions%s:\n" " -h --help Show this help\n" " --version Show package version\n" + " --bus-introspect=PATH Write D-Bus XML introspection data\n" "\nSee the %s for details.\n" , program_path , ansi_highlight(), description, ansi_normal() @@ -36,15 +37,18 @@ static int help(const char *program_path, const char *service, const char *descr int service_parse_argv( const char *service, const char *description, + const BusObjectImplementation* const* bus_objects, int argc, char *argv[]) { enum { ARG_VERSION = 0x100, + ARG_BUS_INTROSPECT, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, + { "bus-introspect", required_argument, NULL, ARG_BUS_INTROSPECT }, {} }; @@ -57,11 +61,17 @@ int service_parse_argv( switch(c) { case 'h': - return help(argv[0], service, description); + return help(argv[0], service, description, bus_objects); case ARG_VERSION: return version(); + case ARG_BUS_INTROSPECT: + return bus_introspect_implementations( + stdout, + optarg, + bus_objects); + case '?': return -EINVAL; diff --git a/src/shared/service-util.h b/src/shared/service-util.h index f4868184f4..76bff61d58 100644 --- a/src/shared/service-util.h +++ b/src/shared/service-util.h @@ -1,7 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once +#include "bus-util.h" + int service_parse_argv( const char *service, const char *description, + const BusObjectImplementation* const* bus_objects, int argc, char *argv[]); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 6dac0bafff..7f2e3019d4 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -1129,6 +1129,7 @@ static int run(int argc, char *argv[]) { r = service_parse_argv("systemd-timedated.service", "Manage the system clock and timezone and NTP enablement.", + NULL, argc, argv); if (r <= 0) return r;