]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
security_selinux: Add SetDirLabel support
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 17 Aug 2015 18:07:07 +0000 (11:07 -0700)
committerCole Robinson <crobinso@redhat.com>
Tue, 22 Sep 2015 00:18:06 +0000 (20:18 -0400)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3f48345f7ec0c44b8ce2371cab454d2118f830b4)

src/security/security_selinux.c

index d267d5acd0bd3f5402f21077e0cbaf0d680f8e2f..da1f2dd45f96a67e581f60a0b713736cf61b46d3 100644 (file)
@@ -2506,6 +2506,21 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr,
     return opts;
 }
 
+static char *
+virSecuritySELinuxDomainSetDirLabel(virSecurityManagerPtr mgr,
+                                    virDomainDefPtr def,
+                                    const char *path)
+{
+    virSecurityLabelDefPtr seclabel;
+    int ret = -1;
+
+    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
+    if (!seclabel || !seclabel->relabel)
+        return 0;
+
+    return virSecuritySELinuxSetFilecon(path, seclabel->imagelabel);
+}
+
 virSecurityDriver virSecurityDriverSELinux = {
     .privateDataLen                     = sizeof(virSecuritySELinuxData),
     .name                               = SECURITY_SELINUX_NAME,
@@ -2550,4 +2565,6 @@ virSecurityDriver virSecurityDriverSELinux = {
 
     .domainGetSecurityMountOptions      = virSecuritySELinuxGetSecurityMountOptions,
     .getBaseLabel                       = virSecuritySELinuxGetBaseLabel,
+
+    .domainSetDirLabel                  = virSecuritySELinuxDomainSetDirLabel,
 };