]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/user-sessions/user-sessions.c
man,units: drop "temporary" from description of systemd-tmpfiles
[thirdparty/systemd.git] / src / user-sessions / user-sessions.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <errno.h>
4 #include <fcntl.h>
5 #include <sys/stat.h>
6 #include <sys/types.h>
7 #include <unistd.h>
8
9 #include "fileio.h"
10 #include "fileio-label.h"
11 #include "fs-util.h"
12 #include "main-func.h"
13 #include "log.h"
14 #include "selinux-util.h"
15 #include "string-util.h"
16
17 static int run(int argc, char *argv[]) {
18 int r;
19
20 if (argc != 2)
21 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
22 "This program requires one argument.");
23
24 log_setup();
25
26 umask(0022);
27
28 r = mac_init();
29 if (r < 0)
30 return r;
31
32 /* We only touch /run/nologin. See create_shutdown_run_nologin_or_warn() for details. */
33
34 if (streq(argv[1], "start"))
35 return unlink_or_warn("/run/nologin");
36 if (streq(argv[1], "stop"))
37 return create_shutdown_run_nologin_or_warn();
38
39 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb '%s'.", argv[1]);
40 }
41
42 DEFINE_MAIN_FUNCTION(run);