]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
security_dac: Add SetDirLabel support
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 17 Aug 2015 18:15:58 +0000 (11:15 -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_dac.c

index bed23c30ae8c34a2f9224cf9dfad2266fed0c366..864d75b2fd9c0238a865507cea8a8fe72387d636 100644 (file)
@@ -1394,6 +1394,24 @@ virSecurityDACGetBaseLabel(virSecurityManagerPtr mgr,
     return priv->baselabel;
 }
 
+static int
+virSecurityDACDomainSetDirLabel(virSecurityManagerPtr mgr,
+                                virDomainDefPtr def,
+                                const char *path)
+{
+    virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr);
+    virSecurityLabelDefPtr seclabel;
+    uid_t user;
+    gid_t group;
+
+    seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME);
+
+    if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL) < 0)
+        return -1;
+
+    return virSecurityDACSetOwnership(path, user, group);
+}
+
 virSecurityDriver virSecurityDriverDAC = {
     .privateDataLen                     = sizeof(virSecurityDACData),
     .name                               = SECURITY_DAC_NAME,
@@ -1441,4 +1459,6 @@ virSecurityDriver virSecurityDriverDAC = {
     .domainGetSecurityMountOptions      = virSecurityDACGetMountOptions,
 
     .getBaseLabel                       = virSecurityDACGetBaseLabel,
+
+    .domainSetDirLabel                  = virSecurityDACDomainSetDirLabel,
 };