]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/user-sessions/user-sessions.c
license: LGPL-2.1+ -> LGPL-2.1-or-later
[thirdparty/systemd.git] / src / user-sessions / user-sessions.c
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
e9278741 2
e9278741 3#include <errno.h>
ca78ad1d
ZJS
4#include <fcntl.h>
5#include <sys/stat.h>
6#include <sys/types.h>
07630cea 7#include <unistd.h>
e9278741 8
07630cea 9#include "fileio.h"
ea4e6292 10#include "fileio-label.h"
af229d7a 11#include "fs-util.h"
8d38b8ad 12#include "main-func.h"
e9278741 13#include "log.h"
ea4e6292 14#include "selinux-util.h"
07630cea 15#include "string-util.h"
e9278741 16
f2a3de01 17static int run(int argc, char *argv[]) {
af229d7a 18 int r, k;
e9278741 19
baaa35ad
ZJS
20 if (argc != 2)
21 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
22 "This program requires one argument.");
e9278741 23
6bf3c61c 24 log_setup_service();
e9278741 25
4c12626c
LP
26 umask(0022);
27
a9ba0e32
CG
28 r = mac_selinux_init();
29 if (r < 0)
30 return r;
ea4e6292 31
e9278741 32 if (streq(argv[1], "start")) {
af229d7a
ZJS
33 r = unlink_or_warn("/run/nologin");
34 k = unlink_or_warn("/etc/nologin");
8d38b8ad
ZJS
35 if (r < 0)
36 return r;
37 return k;
4a8a5b29 38
6e11e7e6 39 } else if (streq(argv[1], "stop"))
8d38b8ad 40 return create_shutdown_run_nologin_or_warn();
e9278741 41
baaa35ad 42 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb '%s'.", argv[1]);
e9278741 43}
8d38b8ad
ZJS
44
45DEFINE_MAIN_FUNCTION(run);