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