]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e9278741 LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2010 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
8 | under the terms of the GNU Lesser General Public License as published by |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
e9278741 LP |
10 | (at your option) any later version. |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 15 | Lesser General Public License for more details. |
e9278741 | 16 | |
5430f7f2 | 17 | You should have received a copy of the GNU Lesser General Public License |
e9278741 LP |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
19 | ***/ | |
20 | ||
e9278741 | 21 | #include <errno.h> |
07630cea | 22 | #include <unistd.h> |
e9278741 | 23 | |
07630cea | 24 | #include "fileio.h" |
ea4e6292 | 25 | #include "fileio-label.h" |
af229d7a | 26 | #include "fs-util.h" |
e9278741 | 27 | #include "log.h" |
ea4e6292 | 28 | #include "selinux-util.h" |
07630cea | 29 | #include "string-util.h" |
e9278741 | 30 | #include "util.h" |
e9278741 LP |
31 | |
32 | int main(int argc, char*argv[]) { | |
af229d7a | 33 | int r, k; |
e9278741 LP |
34 | |
35 | if (argc != 2) { | |
36 | log_error("This program requires one argument."); | |
37 | return EXIT_FAILURE; | |
38 | } | |
39 | ||
4cfa2c99 | 40 | log_set_target(LOG_TARGET_AUTO); |
e9278741 LP |
41 | log_parse_environment(); |
42 | log_open(); | |
43 | ||
4c12626c LP |
44 | umask(0022); |
45 | ||
c3dacc8b | 46 | mac_selinux_init(); |
ea4e6292 | 47 | |
e9278741 | 48 | if (streq(argv[1], "start")) { |
af229d7a ZJS |
49 | r = unlink_or_warn("/run/nologin"); |
50 | k = unlink_or_warn("/etc/nologin"); | |
6079afa9 LP |
51 | if (k < 0 && r >= 0) |
52 | r = k; | |
4a8a5b29 | 53 | |
6e11e7e6 LP |
54 | } else if (streq(argv[1], "stop")) |
55 | r = create_shutdown_run_nologin_or_warn(); | |
56 | else { | |
6079afa9 LP |
57 | log_error("Unknown verb '%s'.", argv[1]); |
58 | r = -EINVAL; | |
e9278741 LP |
59 | } |
60 | ||
ea4e6292 | 61 | mac_selinux_finish(); |
6079afa9 | 62 | return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |
e9278741 | 63 | } |