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