X Tutup
Skip to content

Commit fc021a5

Browse files
committed
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.
1 parent 7ae4732 commit fc021a5

File tree

7 files changed

+48
-28
lines changed

7 files changed

+48
-28
lines changed

src/hostname/hostnamed.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "parse-util.h"
2727
#include "path-util.h"
2828
#include "selinux-util.h"
29+
#include "service-util.h"
2930
#include "signal-util.h"
3031
#include "strv.h"
3132
#include "user-util.h"
@@ -780,14 +781,15 @@ static int run(int argc, char *argv[]) {
780781

781782
log_setup_service();
782783

784+
r = service_parse_argv("systemd-hostnamed.service",
785+
"Manage the system hostname and related metadata.",
786+
argc, argv);
787+
if (r <= 0)
788+
return r;
789+
783790
umask(0022);
784791
mac_selinux_init();
785792

786-
if (argc != 1) {
787-
log_error("This program takes no arguments.");
788-
return -EINVAL;
789-
}
790-
791793
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
792794

793795
r = sd_event_default(&event);

src/import/importd.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "path-util.h"
2323
#include "process-util.h"
2424
#include "signal-util.h"
25+
#include "service-util.h"
2526
#include "socket-util.h"
2627
#include "stat-util.h"
2728
#include "string-table.h"
@@ -1374,12 +1375,13 @@ static int run(int argc, char *argv[]) {
13741375

13751376
log_setup_service();
13761377

1377-
umask(0022);
1378+
r = service_parse_argv("systemd-importd.service",
1379+
"VM and container image import and export service.",
1380+
argc, argv);
1381+
if (r <= 0)
1382+
return r;
13781383

1379-
if (argc != 1) {
1380-
log_error("This program takes no arguments.");
1381-
return -EINVAL;
1382-
}
1384+
umask(0022);
13831385

13841386
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
13851387

src/locale/localed.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "missing_capability.h"
2626
#include "path-util.h"
2727
#include "selinux-util.h"
28+
#include "service-util.h"
2829
#include "signal-util.h"
2930
#include "string-util.h"
3031
#include "strv.h"
@@ -754,12 +755,15 @@ static int run(int argc, char *argv[]) {
754755

755756
log_setup_service();
756757

758+
r = service_parse_argv("systemd-localed.service",
759+
"Manage system locale settings and key mappings.",
760+
argc, argv);
761+
if (r <= 0)
762+
return r;
763+
757764
umask(0022);
758765
mac_selinux_init();
759766

760-
if (argc != 1)
761-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
762-
763767
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
764768

765769
r = sd_event_default(&event);

src/login/logind.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "parse-util.h"
2828
#include "process-util.h"
2929
#include "selinux-util.h"
30+
#include "service-util.h"
3031
#include "signal-util.h"
3132
#include "strv.h"
3233
#include "terminal-util.h"
@@ -1201,12 +1202,13 @@ static int run(int argc, char *argv[]) {
12011202
log_set_facility(LOG_AUTH);
12021203
log_setup_service();
12031204

1204-
umask(0022);
1205+
r = service_parse_argv("systemd-logind.service",
1206+
"Manager for user logins and devices and privileged operations.",
1207+
argc, argv);
1208+
if (r <= 0)
1209+
return r;
12051210

1206-
if (argc != 1) {
1207-
log_error("This program takes no arguments.");
1208-
return -EINVAL;
1209-
}
1211+
umask(0022);
12101212

12111213
r = mac_selinux_init();
12121214
if (r < 0)

src/machine/machined.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "machined.h"
2323
#include "main-func.h"
2424
#include "process-util.h"
25+
#include "service-util.h"
2526
#include "signal-util.h"
2627
#include "special.h"
2728

@@ -357,12 +358,13 @@ static int run(int argc, char *argv[]) {
357358
log_set_facility(LOG_AUTH);
358359
log_setup_service();
359360

360-
umask(0022);
361+
r = service_parse_argv("systemd-machined.service",
362+
"Manage registrations of local VMs and containers.",
363+
argc, argv);
364+
if (r <= 0)
365+
return r;
361366

362-
if (argc != 1) {
363-
log_error("This program takes no arguments.");
364-
return -EINVAL;
365-
}
367+
umask(0022);
366368

367369
/* Always create the directories people can create inotify watches in. Note that some applications might check
368370
* for the existence of /run/systemd/machines/ to determine whether machined is available, so please always

src/resolve/resolved.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "resolved-manager.h"
1616
#include "resolved-resolv-conf.h"
1717
#include "selinux-util.h"
18+
#include "service-util.h"
1819
#include "signal-util.h"
1920
#include "user-util.h"
2021

@@ -25,8 +26,11 @@ static int run(int argc, char *argv[]) {
2526

2627
log_setup_service();
2728

28-
if (argc != 1)
29-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
29+
r = service_parse_argv("systemd-resolved.service",
30+
"Provide name resolution with caching using DNS, mDNS, LLMNR.",
31+
argc, argv);
32+
if (r <= 0)
33+
return r;
3034

3135
umask(0022);
3236

src/timedate/timedated.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "missing_capability.h"
2929
#include "path-util.h"
3030
#include "selinux-util.h"
31+
#include "service-util.h"
3132
#include "signal-util.h"
3233
#include "string-util.h"
3334
#include "strv.h"
@@ -1126,10 +1127,13 @@ static int run(int argc, char *argv[]) {
11261127

11271128
log_setup_service();
11281129

1129-
umask(0022);
1130+
r = service_parse_argv("systemd-timedated.service",
1131+
"Manage the system clock and timezone and NTP enablement.",
1132+
argc, argv);
1133+
if (r <= 0)
1134+
return r;
11301135

1131-
if (argc != 1)
1132-
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
1136+
umask(0022);
11331137

11341138
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
11351139

0 commit comments

Comments
 (0)
X Tutup