]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: get rid of fileio-label.[ch]
authorLennart Poettering <lennart@poettering.net>
Tue, 22 Oct 2024 08:25:26 +0000 (10:25 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Oct 2024 15:51:26 +0000 (17:51 +0200)
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.

src/login/logind-dbus.c
src/shared/fileio-label.c [deleted file]
src/shared/fileio-label.h [deleted file]
src/shared/meson.build
src/shared/reboot-util.c
src/shared/reboot-util.h
src/user-sessions/user-sessions.c

index 9582fb47dfa59fa2e49a23d16dd4cb0d06646299..5de882e42bc02d601e072119a2bb0291c45485fe 100644 (file)
@@ -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"
diff --git a/src/shared/fileio-label.c b/src/shared/fileio-label.c
deleted file mode 100644 (file)
index 69ea82c..0000000
+++ /dev/null
@@ -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;
-}
diff --git a/src/shared/fileio-label.h b/src/shared/fileio-label.h
deleted file mode 100644 (file)
index 9fbe0f4..0000000
+++ /dev/null
@@ -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);
index 1141efa45381dabd5f9d2c7054903550f9fe2f17..af9ef74b329636180eff453ef59aa415ce5b5d4c 100644 (file)
@@ -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',
index b1c1aa75e6213f3dac3aaef3b2193f1fe6bb72f5..903e19efae2610546d720e96dc9a51dad0588618 100644 (file)
@@ -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;
+}
index 2ac478f7840e89333d4c35b47af13242d93e6b87..92189bee881b142af546543e9b0cd6243bfd257a 100644 (file)
@@ -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);
index 58054f89fb33759a21e024a835e7c616660fdf98..7d84d6b54063d9274fca0904f4c018f1a798097a 100644 (file)
@@ -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"