]> 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)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 24 Aug 2015 09:53:17 +0000 (11:53 +0200)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/security/security_selinux.c

index a37f8c140b072d18aa42875b704fe7f52616a581..d4bfee76c5a5d4ff39be4c5e053d5d00c0d69d0f 100644 (file)
@@ -2505,6 +2505,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,
@@ -2549,4 +2564,6 @@ virSecurityDriver virSecurityDriverSELinux = {
 
     .domainGetSecurityMountOptions      = virSecuritySELinuxGetSecurityMountOptions,
     .getBaseLabel                       = virSecuritySELinuxGetBaseLabel,
+
+    .domainSetDirLabel                  = virSecuritySELinuxDomainSetDirLabel,
 };