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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-04-23 10:19:46 +02:00
parent 7ae473268c
commit fc021a5bbf
7 changed files with 48 additions and 28 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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