ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
803fb7
From 4dd0d6644c71149a0a1af89944b95325ac4d2f18 Mon Sep 17 00:00:00 2001
803fb7
From: Michal Sekletar <msekleta@redhat.com>
803fb7
Date: Wed, 23 Sep 2015 11:26:58 +0200
803fb7
Subject: [PATCH] shutdown: make sure /run/nologin has correct label
803fb7
803fb7
rhel-only for now, not yet posted upstream
803fb7
803fb7
Related: #1264073
803fb7
---
803fb7
 src/shutdownd/shutdownd.c | 8 +++++++-
803fb7
 1 file changed, 7 insertions(+), 1 deletion(-)
803fb7
803fb7
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
803fb7
index 701882b96..e1917a626 100644
803fb7
--- a/src/shutdownd/shutdownd.c
803fb7
+++ b/src/shutdownd/shutdownd.c
803fb7
@@ -39,6 +39,8 @@
803fb7
 #include "utmp-wtmp.h"
803fb7
 #include "mkdir.h"
803fb7
 #include "fileio.h"
803fb7
+#include "selinux-util.h"
803fb7
+#include "fileio-label.h"
803fb7
 
803fb7
 union shutdown_buffer {
803fb7
         struct sd_shutdown_command command;
803fb7
@@ -278,6 +280,8 @@ int main(int argc, char *argv[]) {
803fb7
 
803fb7
         umask(0022);
803fb7
 
803fb7
+        mac_selinux_init(NULL);
803fb7
+
803fb7
         n_fds = sd_listen_fds(true);
803fb7
         if (n_fds < 0) {
803fb7
                 log_error_errno(r, "Failed to read listening file descriptors from environment: %m");
803fb7
@@ -404,7 +408,7 @@ int main(int argc, char *argv[]) {
803fb7
 
803fb7
                         log_info("Creating /run/nologin, blocking further logins...");
803fb7
 
803fb7
-                        e = write_string_file_atomic("/run/nologin", "System is going down.");
803fb7
+                        e = write_string_file_atomic_label("/run/nologin", "System is going down.");
803fb7
                         if (e < 0)
803fb7
                                 log_error_errno(e, "Failed to create /run/nologin: %m");
803fb7
                         else
803fb7
@@ -433,6 +437,8 @@ finish:
803fb7
 
803fb7
         unlink("/run/systemd/shutdown/scheduled");
803fb7
 
803fb7
+        mac_selinux_finish();
803fb7
+
803fb7
         if (exec_shutdown && !b.command.dry_run) {
803fb7
                 char sw[3];
803fb7