]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/fileio-label.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "fileio-label.h"
7 #include "selinux-util.h"
9 int write_string_file_atomic_label_ts(const char *fn
, const char *line
, struct timespec
*ts
) {
12 r
= mac_selinux_create_file_prepare(fn
, S_IFREG
);
16 r
= write_string_file_ts(fn
, line
, WRITE_STRING_FILE_CREATE
|WRITE_STRING_FILE_ATOMIC
, ts
);
18 mac_selinux_create_file_clear();
23 int create_shutdown_run_nologin_or_warn(void) {
26 /* This is used twice: once in systemd-user-sessions.service, in order to block logins when we
27 * actually go down, and once in systemd-logind.service when shutdowns are scheduled, and logins are
28 * to be turned off a bit in advance. We use the same wording of the message in both cases.
30 * Traditionally, there was only /etc/nologin, and we managed that. Then, in PAM 1.1
31 * support for /run/nologin was added as alternative
32 * (https://github.com/linux-pam/linux-pam/commit/e9e593f6ddeaf975b7fe8446d184e6bc387d450b).
33 * 13 years later we stopped managing /etc/nologin, leaving it for the administrator to manage.
36 r
= write_string_file_atomic_label("/run/nologin",
37 "System is going down. Unprivileged users are not permitted to log in anymore. "
38 "For technical details, see pam_nologin(8).");
40 return log_error_errno(r
, "Failed to create /run/nologin: %m");