importd,logind: add --bus-introspect= option

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-04-28 17:55:34 +02:00
parent 1e9bc92dba
commit d4cc0edfce
9 changed files with 24 additions and 2 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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[]);

View file

@ -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;