7a3408
From 47dd73a795f67459851f20af3f9dded334f3a941 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <47dd73a795f67459851f20af3f9dded334f3a941@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Mon, 24 Aug 2015 13:04:47 +0200
7a3408
Subject: [PATCH] security: Add virSecurityDomainSetDirLabel
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
7a3408
7a3408
That function can be used for setting security labels on arbitrary
7a3408
directories.
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit f65a2a12f4b9ab6144a979774f0486cdc4f7a60a)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/libvirt_private.syms        |  1 +
7a3408
 src/security/security_driver.h  |  5 +++++
7a3408
 src/security/security_manager.c | 17 +++++++++++++++++
7a3408
 src/security/security_manager.h |  4 ++++
7a3408
 4 files changed, 27 insertions(+)
7a3408
7a3408
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
7a3408
index be85c6b..434bbf3 100644
7a3408
--- a/src/libvirt_private.syms
7a3408
+++ b/src/libvirt_private.syms
7a3408
@@ -1022,6 +1022,7 @@ virSecurityDriverLookup;
7a3408
 # security/security_manager.h
7a3408
 virSecurityManagerCheckAllLabel;
7a3408
 virSecurityManagerClearSocketLabel;
7a3408
+virSecurityManagerDomainSetDirLabel;
7a3408
 virSecurityManagerGenLabel;
7a3408
 virSecurityManagerGetBaseLabel;
7a3408
 virSecurityManagerGetDOI;
7a3408
diff --git a/src/security/security_driver.h b/src/security/security_driver.h
7a3408
index f0dca09..784b0de 100644
7a3408
--- a/src/security/security_driver.h
7a3408
+++ b/src/security/security_driver.h
7a3408
@@ -118,6 +118,9 @@ typedef int (*virSecurityDomainSetImageLabel) (virSecurityManagerPtr mgr,
7a3408
 typedef int (*virSecurityDomainRestoreImageLabel) (virSecurityManagerPtr mgr,
7a3408
                                                    virDomainDefPtr def,
7a3408
                                                    virStorageSourcePtr src);
7a3408
+typedef int (*virSecurityDomainSetDirLabel) (virSecurityManagerPtr mgr,
7a3408
+                                             virDomainDefPtr def,
7a3408
+                                             const char *path);
7a3408
 
7a3408
 
7a3408
 struct _virSecurityDriver {
7a3408
@@ -168,6 +171,8 @@ struct _virSecurityDriver {
7a3408
     virSecurityDomainSetHugepages domainSetSecurityHugepages;
7a3408
 
7a3408
     virSecurityDriverGetBaseLabel getBaseLabel;
7a3408
+
7a3408
+    virSecurityDomainSetDirLabel domainSetDirLabel;
7a3408
 };
7a3408
 
7a3408
 virSecurityDriverPtr virSecurityDriverLookup(const char *name,
7a3408
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
7a3408
index b0cd9e8..1098558 100644
7a3408
--- a/src/security/security_manager.c
7a3408
+++ b/src/security/security_manager.c
7a3408
@@ -991,3 +991,20 @@ virSecurityManagerSetHugepages(virSecurityManagerPtr mgr,
7a3408
 
7a3408
     return 0;
7a3408
 }
7a3408
+
7a3408
+
7a3408
+int
7a3408
+virSecurityManagerDomainSetDirLabel(virSecurityManagerPtr mgr,
7a3408
+                                    virDomainDefPtr vm,
7a3408
+                                    const char *path)
7a3408
+{
7a3408
+    if (mgr->drv->domainSetDirLabel) {
7a3408
+        int ret;
7a3408
+        virObjectLock(mgr);
7a3408
+        ret = mgr->drv->domainSetDirLabel(mgr, vm, path);
7a3408
+        virObjectUnlock(mgr);
7a3408
+        return ret;
7a3408
+    }
7a3408
+
7a3408
+    return 0;
7a3408
+}
7a3408
diff --git a/src/security/security_manager.h b/src/security/security_manager.h
7a3408
index 13468db..78f34a0 100644
7a3408
--- a/src/security/security_manager.h
7a3408
+++ b/src/security/security_manager.h
7a3408
@@ -150,4 +150,8 @@ int virSecurityManagerRestoreImageLabel(virSecurityManagerPtr mgr,
7a3408
                                         virDomainDefPtr vm,
7a3408
                                         virStorageSourcePtr src);
7a3408
 
7a3408
+int virSecurityManagerDomainSetDirLabel(virSecurityManagerPtr mgr,
7a3408
+                                        virDomainDefPtr vm,
7a3408
+                                        const char *path);
7a3408
+
7a3408
 #endif /* VIR_SECURITY_MANAGER_H__ */
7a3408
-- 
7a3408
2.5.1
7a3408