dcavalca / rpms / systemd

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