7a3408
From f2cbaf777e1a5808944bce8b14899be93f253d4b Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <f2cbaf777e1a5808944bce8b14899be93f253d4b@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Mon, 24 Aug 2015 13:04:48 +0200
7a3408
Subject: [PATCH] security_stack: 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 99cf04e32d94025a8a969057fba4451eb416a56e)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/security/security_stack.c | 20 ++++++++++++++++++++
7a3408
 1 file changed, 20 insertions(+)
7a3408
7a3408
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
7a3408
index 1ded57b..8d9560d 100644
7a3408
--- a/src/security/security_stack.c
7a3408
+++ b/src/security/security_stack.c
7a3408
@@ -599,6 +599,24 @@ virSecurityStackRestoreSecurityImageLabel(virSecurityManagerPtr mgr,
7a3408
     return rc;
7a3408
 }
7a3408
 
7a3408
+static int
7a3408
+virSecurityStackDomainSetDirLabel(virSecurityManagerPtr mgr,
7a3408
+                                  virDomainDefPtr vm,
7a3408
+                                  const char *path)
7a3408
+{
7a3408
+    virSecurityStackDataPtr priv = virSecurityManagerGetPrivateData(mgr);
7a3408
+    virSecurityStackItemPtr item = priv->itemsHead;
7a3408
+    int rc = 0;
7a3408
+
7a3408
+    for (; item; item = item->next) {
7a3408
+        if (virSecurityManagerDomainSetDirLabel(item->securityManager,
7a3408
+                                                vm, path) < 0)
7a3408
+            rc = -1;
7a3408
+    }
7a3408
+
7a3408
+    return rc;
7a3408
+}
7a3408
+
7a3408
 virSecurityDriver virSecurityDriverStack = {
7a3408
     .privateDataLen                     = sizeof(virSecurityStackData),
7a3408
     .name                               = "stack",
7a3408
@@ -648,4 +666,6 @@ virSecurityDriver virSecurityDriverStack = {
7a3408
     .domainSetSecurityHugepages         = virSecurityStackSetHugepages,
7a3408
 
7a3408
     .getBaseLabel                       = virSecurityStackGetBaseLabel,
7a3408
+
7a3408
+    .domainSetDirLabel                  = virSecurityStackDomainSetDirLabel,
7a3408
 };
7a3408
-- 
7a3408
2.5.1
7a3408