richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
1ff636
From ca5c3dbfd843b6acd92425a6f56c4b01d1a80dde Mon Sep 17 00:00:00 2001
1ff636
From: Michal Sekletar <msekleta@redhat.com>
1ff636
Date: Mon, 21 Sep 2015 14:55:39 +0200
1ff636
Subject: [PATCH] login: fix label on /run/nologin
1ff636
1ff636
rhel-only for now, not yet posted upstream
1ff636
1ff636
Resolves: #1264073
1ff636
---
1ff636
 Makefile.am               | 3 ++-
1ff636
 src/login/user-sessions.c | 7 ++++++-
1ff636
 2 files changed, 8 insertions(+), 2 deletions(-)
1ff636
1ff636
diff --git a/Makefile.am b/Makefile.am
181b3f
index 58bcc2c42..0fcb73750 100644
1ff636
--- a/Makefile.am
1ff636
+++ b/Makefile.am
1ff636
@@ -5829,7 +5829,8 @@ systemd_user_sessions_SOURCES = \
1ff636
 	src/login/user-sessions.c
1ff636
 
1ff636
 systemd_user_sessions_LDADD = \
1ff636
-	libsystemd-shared.la
1ff636
+	libsystemd-shared.la \
1ff636
+	libsystemd-label.la
1ff636
 
1ff636
 rootlibexec_PROGRAMS += \
1ff636
 	systemd-logind \
1ff636
diff --git a/src/login/user-sessions.c b/src/login/user-sessions.c
181b3f
index 6edb823e8..d1d429c0d 100644
1ff636
--- a/src/login/user-sessions.c
1ff636
+++ b/src/login/user-sessions.c
1ff636
@@ -26,6 +26,7 @@
1ff636
 #include "log.h"
1ff636
 #include "util.h"
1ff636
 #include "fileio.h"
1ff636
+#include "selinux-util.h"
1ff636
 
1ff636
 int main(int argc, char*argv[]) {
1ff636
 
1ff636
@@ -40,6 +41,8 @@ int main(int argc, char*argv[]) {
1ff636
 
1ff636
         umask(0022);
1ff636
 
1ff636
+        mac_selinux_init(NULL);
1ff636
+
1ff636
         if (streq(argv[1], "start")) {
1ff636
                 int r = 0;
1ff636
 
1ff636
@@ -66,7 +69,7 @@ int main(int argc, char*argv[]) {
1ff636
         } else if (streq(argv[1], "stop")) {
1ff636
                 int r;
1ff636
 
1ff636
-                r = write_string_file_atomic("/run/nologin", "System is going down.");
1ff636
+                r = write_string_file_atomic_label("/run/nologin", "System is going down.");
1ff636
                 if (r < 0) {
1ff636
                         log_error_errno(r, "Failed to create /run/nologin: %m");
1ff636
                         return EXIT_FAILURE;
1ff636
@@ -77,5 +80,7 @@ int main(int argc, char*argv[]) {
1ff636
                 return EXIT_FAILURE;
1ff636
         }
1ff636
 
1ff636
+        mac_selinux_finish();
1ff636
+
1ff636
         return EXIT_SUCCESS;
1ff636
 }