From: Zbigniew Jędrzejewski-Szmek Date: Thu, 23 Apr 2020 08:19:46 +0000 (+0200) Subject: logind,importd,hostnamed,localed,timedated,machined,resolved: add option parsing... X-Git-Tag: v246-rc1~433^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc021a5bbf1b00a3ac21845f3102f1a6379a9357;p=thirdparty%2Fsystemd.git logind,importd,hostnamed,localed,timedated,machined,resolved: add option parsing stubs --help and --version are implemented in the usual style. help() prints full path, since the program is not expected to be in $PATH. --- diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index ad6577c37e6..b2b5299b325 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -26,6 +26,7 @@ #include "parse-util.h" #include "path-util.h" #include "selinux-util.h" +#include "service-util.h" #include "signal-util.h" #include "strv.h" #include "user-util.h" @@ -780,14 +781,15 @@ static int run(int argc, char *argv[]) { log_setup_service(); + r = service_parse_argv("systemd-hostnamed.service", + "Manage the system hostname and related metadata.", + argc, argv); + if (r <= 0) + return r; + umask(0022); mac_selinux_init(); - if (argc != 1) { - log_error("This program takes no arguments."); - return -EINVAL; - } - assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); r = sd_event_default(&event); diff --git a/src/import/importd.c b/src/import/importd.c index 2e5c1c26420..ea16c9bec41 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -22,6 +22,7 @@ #include "path-util.h" #include "process-util.h" #include "signal-util.h" +#include "service-util.h" #include "socket-util.h" #include "stat-util.h" #include "string-table.h" @@ -1374,12 +1375,13 @@ static int run(int argc, char *argv[]) { log_setup_service(); - umask(0022); + r = service_parse_argv("systemd-importd.service", + "VM and container image import and export service.", + argc, argv); + if (r <= 0) + return r; - if (argc != 1) { - log_error("This program takes no arguments."); - return -EINVAL; - } + umask(0022); assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0); diff --git a/src/locale/localed.c b/src/locale/localed.c index 7315d93a982..a0fcadcc914 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -25,6 +25,7 @@ #include "missing_capability.h" #include "path-util.h" #include "selinux-util.h" +#include "service-util.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" @@ -754,12 +755,15 @@ static int run(int argc, char *argv[]) { log_setup_service(); + r = service_parse_argv("systemd-localed.service", + "Manage system locale settings and key mappings.", + argc, argv); + if (r <= 0) + return r; + umask(0022); mac_selinux_init(); - if (argc != 1) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments."); - assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0); r = sd_event_default(&event); diff --git a/src/login/logind.c b/src/login/logind.c index 75958189ac8..4678b22bea1 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -27,6 +27,7 @@ #include "parse-util.h" #include "process-util.h" #include "selinux-util.h" +#include "service-util.h" #include "signal-util.h" #include "strv.h" #include "terminal-util.h" @@ -1201,12 +1202,13 @@ static int run(int argc, char *argv[]) { log_set_facility(LOG_AUTH); log_setup_service(); - umask(0022); + r = service_parse_argv("systemd-logind.service", + "Manager for user logins and devices and privileged operations.", + argc, argv); + if (r <= 0) + return r; - if (argc != 1) { - log_error("This program takes no arguments."); - return -EINVAL; - } + umask(0022); r = mac_selinux_init(); if (r < 0) diff --git a/src/machine/machined.c b/src/machine/machined.c index a93bfc42be2..191031e2aab 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -22,6 +22,7 @@ #include "machined.h" #include "main-func.h" #include "process-util.h" +#include "service-util.h" #include "signal-util.h" #include "special.h" @@ -357,12 +358,13 @@ static int run(int argc, char *argv[]) { log_set_facility(LOG_AUTH); log_setup_service(); - umask(0022); + r = service_parse_argv("systemd-machined.service", + "Manage registrations of local VMs and containers.", + argc, argv); + if (r <= 0) + return r; - if (argc != 1) { - log_error("This program takes no arguments."); - return -EINVAL; - } + umask(0022); /* Always create the directories people can create inotify watches in. Note that some applications might check * for the existence of /run/systemd/machines/ to determine whether machined is available, so please always diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c index 27848cccae7..73da508d7ac 100644 --- a/src/resolve/resolved.c +++ b/src/resolve/resolved.c @@ -15,6 +15,7 @@ #include "resolved-manager.h" #include "resolved-resolv-conf.h" #include "selinux-util.h" +#include "service-util.h" #include "signal-util.h" #include "user-util.h" @@ -25,8 +26,11 @@ static int run(int argc, char *argv[]) { log_setup_service(); - if (argc != 1) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments."); + r = service_parse_argv("systemd-resolved.service", + "Provide name resolution with caching using DNS, mDNS, LLMNR.", + argc, argv); + if (r <= 0) + return r; umask(0022); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 8e15cd4f06e..6dac0bafffa 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -28,6 +28,7 @@ #include "missing_capability.h" #include "path-util.h" #include "selinux-util.h" +#include "service-util.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" @@ -1126,10 +1127,13 @@ static int run(int argc, char *argv[]) { log_setup_service(); - umask(0022); + r = service_parse_argv("systemd-timedated.service", + "Manage the system clock and timezone and NTP enablement.", + argc, argv); + if (r <= 0) + return r; - if (argc != 1) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments."); + umask(0022); assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);