shared: get rid of fileio-label.[ch]
Move the renaming function to reboot-util.h (since it writes out /run/nologin at shutdown), and let's get rid of fileio-label.[ch] now that it serves no purpose anymore.
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
#include "event-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fileio-label.h"
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "logind-action.h"
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "fileio-label.h"
|
||||
#include "fileio.h"
|
||||
#include "selinux-util.h"
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void) {
|
||||
int r;
|
||||
|
||||
/* This is used twice: once in systemd-user-sessions.service, in order to block logins when we
|
||||
* actually go down, and once in systemd-logind.service when shutdowns are scheduled, and logins are
|
||||
* to be turned off a bit in advance. We use the same wording of the message in both cases.
|
||||
*
|
||||
* Traditionally, there was only /etc/nologin, and we managed that. Then, in PAM 1.1
|
||||
* support for /run/nologin was added as alternative
|
||||
* (https://github.com/linux-pam/linux-pam/commit/e9e593f6ddeaf975b7fe8446d184e6bc387d450b).
|
||||
* 13 years later we stopped managing /etc/nologin, leaving it for the administrator to manage.
|
||||
*/
|
||||
|
||||
r = write_string_file("/run/nologin",
|
||||
"System is going down. Unprivileged users are not permitted to log in anymore. "
|
||||
"For technical details, see pam_nologin(8).",
|
||||
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_LABEL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/nologin: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* These functions are split out of fileio.h (and not for example just flags to the functions they wrap) in order to
|
||||
* optimize linking: This way, -lselinux is needed only for the callers of these functions that need selinux, but not
|
||||
* for all */
|
||||
|
||||
#include "fileio.h"
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void);
|
||||
@@ -72,7 +72,6 @@ shared_sources = files(
|
||||
'extension-util.c',
|
||||
'fdset.c',
|
||||
'fido2-util.c',
|
||||
'fileio-label.c',
|
||||
'find-esp.c',
|
||||
'firewall-util-nft.c',
|
||||
'firewall-util.c',
|
||||
|
||||
@@ -204,3 +204,26 @@ bool kexec_loaded(void) {
|
||||
|
||||
return s[0] == '1';
|
||||
}
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void) {
|
||||
int r;
|
||||
|
||||
/* This is used twice: once in systemd-user-sessions.service, in order to block logins when we
|
||||
* actually go down, and once in systemd-logind.service when shutdowns are scheduled, and logins are
|
||||
* to be turned off a bit in advance. We use the same wording of the message in both cases.
|
||||
*
|
||||
* Traditionally, there was only /etc/nologin, and we managed that. Then, in PAM 1.1
|
||||
* support for /run/nologin was added as alternative
|
||||
* (https://github.com/linux-pam/linux-pam/commit/e9e593f6ddeaf975b7fe8446d184e6bc387d450b).
|
||||
* 13 years later we stopped managing /etc/nologin, leaving it for the administrator to manage.
|
||||
*/
|
||||
|
||||
r = write_string_file("/run/nologin",
|
||||
"System is going down. Unprivileged users are not permitted to log in anymore. "
|
||||
"For technical details, see pam_nologin(8).",
|
||||
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_LABEL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create /run/nologin: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool reboot_parameter_is_valid(const char *parameter);
|
||||
int update_reboot_parameter_and_warn(const char *parameter, bool keep);
|
||||
|
||||
@@ -16,3 +18,5 @@ int reboot_with_parameter(RebootFlags flags);
|
||||
bool shall_restore_state(void);
|
||||
|
||||
bool kexec_loaded(void);
|
||||
|
||||
int create_shutdown_run_nologin_or_warn(void);
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fileio.h"
|
||||
#include "fileio-label.h"
|
||||
#include "fs-util.h"
|
||||
#include "main-func.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "reboot-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user