diff options
Diffstat (limited to 'src/user-sessions/user-sessions.c')
-rw-r--r-- | src/user-sessions/user-sessions.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/user-sessions/user-sessions.c b/src/user-sessions/user-sessions.c index fa0829e384..4f711c2ed6 100644 --- a/src/user-sessions/user-sessions.c +++ b/src/user-sessions/user-sessions.c @@ -6,17 +6,18 @@ #include "fileio.h" #include "fileio-label.h" #include "fs-util.h" +#include "main-func.h" #include "log.h" #include "selinux-util.h" #include "string-util.h" #include "util.h" -int main(int argc, char*argv[]) { +static int run(int argc, char*argv[]) { int r, k; if (argc != 2) { log_error("This program requires one argument."); - return EXIT_FAILURE; + return -EINVAL; } log_setup_service(); @@ -28,16 +29,15 @@ int main(int argc, char*argv[]) { if (streq(argv[1], "start")) { r = unlink_or_warn("/run/nologin"); k = unlink_or_warn("/etc/nologin"); - if (k < 0 && r >= 0) - r = k; + if (r < 0) + return r; + return k; } else if (streq(argv[1], "stop")) - r = create_shutdown_run_nologin_or_warn(); - else { - log_error("Unknown verb '%s'.", argv[1]); - r = -EINVAL; - } + return create_shutdown_run_nologin_or_warn(); - mac_selinux_finish(); - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + log_error("Unknown verb '%s'.", argv[1]); + return -EINVAL; } + +DEFINE_MAIN_FUNCTION(run); |