]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/user-sessions/user-sessions.c
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "fileio-label.h"
26 #include "selinux-util.h"
27 #include "string-util.h"
30 int main(int argc
, char*argv
[]) {
33 log_error("This program requires one argument.");
37 log_set_target(LOG_TARGET_AUTO
);
38 log_parse_environment();
43 mac_selinux_init(NULL
);
45 if (streq(argv
[1], "start")) {
48 if (unlink("/run/nologin") < 0 && errno
!= ENOENT
)
49 r
= log_error_errno(errno
,
50 "Failed to remove /run/nologin file: %m");
52 if (unlink("/etc/nologin") < 0 && errno
!= ENOENT
) {
53 /* If the file doesn't exist and /etc simply
54 * was read-only (in which case unlink()
55 * returns EROFS even if the file doesn't
56 * exist), don't complain */
58 if (errno
!= EROFS
|| access("/etc/nologin", F_OK
) >= 0) {
59 log_error_errno(errno
, "Failed to remove /etc/nologin file: %m");
67 } else if (streq(argv
[1], "stop")) {
70 r
= write_string_file_atomic_label("/run/nologin", "System is going down.");
72 log_error_errno(r
, "Failed to create /run/nologin: %m");
77 log_error("Unknown verb %s.", argv
[1]);