]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ | |
2 | ||
3 | #include <errno.h> | |
4 | #include <unistd.h> | |
5 | ||
6 | #include "fileio.h" | |
7 | #include "fileio-label.h" | |
8 | #include "fs-util.h" | |
9 | #include "main-func.h" | |
10 | #include "log.h" | |
11 | #include "selinux-util.h" | |
12 | #include "string-util.h" | |
13 | #include "util.h" | |
14 | ||
15 | static int run(int argc, char*argv[]) { | |
16 | int r, k; | |
17 | ||
18 | if (argc != 2) | |
19 | return log_error_errno(SYNTHETIC_ERRNO(EINVAL), | |
20 | "This program requires one argument."); | |
21 | ||
22 | log_setup_service(); | |
23 | ||
24 | umask(0022); | |
25 | ||
26 | mac_selinux_init(); | |
27 | ||
28 | if (streq(argv[1], "start")) { | |
29 | r = unlink_or_warn("/run/nologin"); | |
30 | k = unlink_or_warn("/etc/nologin"); | |
31 | if (r < 0) | |
32 | return r; | |
33 | return k; | |
34 | ||
35 | } else if (streq(argv[1], "stop")) | |
36 | return create_shutdown_run_nologin_or_warn(); | |
37 | ||
38 | return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb '%s'.", argv[1]); | |
39 | } | |
40 | ||
41 | DEFINE_MAIN_FUNCTION(run); |