]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Cleaner fix for compilation without SELinux
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 10 Feb 2012 15:22:50 +0000 (16:22 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 29 Feb 2012 13:55:32 +0000 (14:55 +0100)
Just a cleanup of commit 32f881c6c42f94da70a3782fe20a058fe3dc39cc.

src/lxc/lxc_container.c

index e93fda5008b7e7eb10f4924e2dcae440a1c37b28..2282eb069e0e3bf168cf172126dd04fc796ee585 100644 (file)
@@ -449,8 +449,6 @@ static int lxcContainerMountBasicFS(const char *srcprefix, bool pivotRoot)
     char *opts = NULL;
 #if HAVE_SELINUX
     security_context_t con;
-#else
-    bool con = false;
 #endif
 
     VIR_DEBUG("Mounting basic filesystems %s pivotRoot=%d", NULLSTR(srcprefix), pivotRoot);
@@ -511,10 +509,17 @@ static int lxcContainerMountBasicFS(const char *srcprefix, bool pivotRoot)
          * tmpfs is limited to 64kb, since we only have device nodes in there
          * and don't want to DOS the entire OS RAM usage
          */
-        if (virAsprintf(&opts, "mode=755,size=65536%s%s%s",
-                        con ? ",context=\"" : "",
-                        con ? (const char *)con : "",
-                        con ? "\"" : "") < 0) {
+
+#if HAVE_SELINUX
+        if (con)
+            ignore_value(virAsprintf(&opts,
+                                     "mode=755,size=65536,context=\"%s\"",
+                                     (const char *)con));
+        else
+#endif
+            opts = strdup("mode=755,size=65536");
+
+        if (!opts) {
             virReportOOMError();
             goto cleanup;
         }