| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <sys/stat.h> |
| 4 |
|
| 5 |
#include "fs-util.h" |
| 6 |
#include "label-util.h" |
| 7 |
#include "log.h" |
| 8 |
#include "main-func.h" |
| 9 |
#include "reboot-util.h" |
| 10 |
#include "string-util.h" |
| 11 |
|
| 12 |
static int run(int argc, char *argv[]) { |
| 13 |
int r; |
| 14 |
|
| 15 |
if (argc != 2) |
| 16 |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), |
| 17 |
"This program requires one argument."); |
| 18 |
|
| 19 |
log_setup(); |
| 20 |
|
| 21 |
umask(0022); |
| 22 |
|
| 23 |
r = mac_init(); |
| 24 |
if (r < 0) |
| 25 |
return r; |
| 26 |
|
| 27 |
/* We only touch /run/nologin. See create_shutdown_run_nologin_or_warn() for details. */ |
| 28 |
|
| 29 |
if (streq(argv[1], "start")) |
| 30 |
return unlink_or_warn("/run/nologin"); |
| 31 |
if (streq(argv[1], "stop")) |
| 32 |
return create_shutdown_run_nologin_or_warn(); |
| 33 |
|
| 34 |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb '%s'.", argv[1]); |
| 35 |
} |
| 36 |
|
| 37 |
DEFINE_MAIN_FUNCTION(run); |