]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
lxcCapsInit: Allocate primary security driver unconditionally
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Jul 2013 13:36:04 +0000 (15:36 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 17 Jul 2013 10:36:45 +0000 (12:36 +0200)
Currently, if the primary security driver is 'none', we skip
initializing caps->host.secModels. This means, later, when LXC domain
XML is parsed and <seclabel type='none'/> is found (see
virSecurityLabelDefsParseXML), the model name is not copied to the
seclabel. This leads to subsequent crash in virSecurityManagerGenLabel
where we call STREQ() over the model (note, that we are expecting model
to be !NULL).

src/lxc/lxc_conf.c

index 4e859c5f1f17c21342235a71a3b596808770db83..78b155993a840b48cb097606dec24661f87f4780 100644 (file)
@@ -114,16 +114,14 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
 
         doi = virSecurityManagerGetDOI(driver->securityManager);
         model = virSecurityManagerGetModel(driver->securityManager);
-        if (STRNEQ(model, "none")) {
-            /* Allocate just the primary security driver for LXC. */
-            if (VIR_ALLOC(caps->host.secModels) < 0)
-                goto error;
-            caps->host.nsecModels = 1;
-            if (VIR_STRDUP(caps->host.secModels[0].model, model) < 0)
-                goto error;
-            if (VIR_STRDUP(caps->host.secModels[0].doi, doi) < 0)
-                goto error;
-        }
+        /* Allocate the primary security driver for LXC. */
+        if (VIR_ALLOC(caps->host.secModels) < 0)
+            goto error;
+        caps->host.nsecModels = 1;
+        if (VIR_STRDUP(caps->host.secModels[0].model, model) < 0)
+            goto error;
+        if (VIR_STRDUP(caps->host.secModels[0].doi, doi) < 0)
+            goto error;
 
         VIR_DEBUG("Initialized caps for security driver \"%s\" with "
                   "DOI \"%s\"", model, doi);