|
|
7a3408 |
From 07bbdd7925cc66eb30284de1d592b1a1c0889313 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <07bbdd7925cc66eb30284de1d592b1a1c0889313@dist-git>
|
|
|
7a3408 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
7a3408 |
Date: Mon, 24 Aug 2015 13:04:49 +0200
|
|
|
7a3408 |
Subject: [PATCH] security_selinux: Add SetDirLabel support
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
7a3408 |
(cherry picked from commit 3f48345f7ec0c44b8ce2371cab454d2118f830b4)
|
|
|
7a3408 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/security/security_selinux.c | 17 +++++++++++++++++
|
|
|
7a3408 |
1 file changed, 17 insertions(+)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
|
|
|
7a3408 |
index a37f8c1..d4bfee7 100644
|
|
|
7a3408 |
--- a/src/security/security_selinux.c
|
|
|
7a3408 |
+++ b/src/security/security_selinux.c
|
|
|
7a3408 |
@@ -2505,6 +2505,21 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr,
|
|
|
7a3408 |
return opts;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
+static char *
|
|
|
7a3408 |
+virSecuritySELinuxDomainSetDirLabel(virSecurityManagerPtr mgr,
|
|
|
7a3408 |
+ virDomainDefPtr def,
|
|
|
7a3408 |
+ const char *path)
|
|
|
7a3408 |
+{
|
|
|
7a3408 |
+ virSecurityLabelDefPtr seclabel;
|
|
|
7a3408 |
+ int ret = -1;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
|
|
|
7a3408 |
+ if (!seclabel || !seclabel->relabel)
|
|
|
7a3408 |
+ return 0;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ return virSecuritySELinuxSetFilecon(path, seclabel->imagelabel);
|
|
|
7a3408 |
+}
|
|
|
7a3408 |
+
|
|
|
7a3408 |
virSecurityDriver virSecurityDriverSELinux = {
|
|
|
7a3408 |
.privateDataLen = sizeof(virSecuritySELinuxData),
|
|
|
7a3408 |
.name = SECURITY_SELINUX_NAME,
|
|
|
7a3408 |
@@ -2549,4 +2564,6 @@ virSecurityDriver virSecurityDriverSELinux = {
|
|
|
7a3408 |
|
|
|
7a3408 |
.domainGetSecurityMountOptions = virSecuritySELinuxGetSecurityMountOptions,
|
|
|
7a3408 |
.getBaseLabel = virSecuritySELinuxGetBaseLabel,
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ .domainSetDirLabel = virSecuritySELinuxDomainSetDirLabel,
|
|
|
7a3408 |
};
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.1
|
|
|
7a3408 |
|