]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Actually unshare() iff running as root
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Jan 2017 11:15:16 +0000 (12:15 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Jan 2017 12:23:56 +0000 (13:23 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1413922

While all the code that deals with qemu namespaces correctly
detects whether we are running as root (and turn into NO-OP for
qemu:///session) the actual unshare() call is not guarded with
such check. Therefore any attempt to start a domain under
qemu:///session shall fail as unshare() is reserved for root.

The fix consists of moving unshare() call (for which we have a
wrapper called virProcessSetupPrivateMountNS) into
qemuDomainBuildNamespace() where the proper check is performed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_process.c

index 35baffb5104110b5f0e9af0d22a42fd32f4a9f3f..c676042228a0eeb3faaa0578c6ed85da53f8003c 100644 (file)
@@ -7400,6 +7400,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
+    if (virProcessSetupPrivateMountNS() < 0)
+        goto cleanup;
+
     if (qemuDomainSetupDev(driver, vm, devPath) < 0)
         goto cleanup;
 
index a980f5a9e524b335796b7fbb12095c9ff4166a58..184440dc1af6e426a8251bb7189488be3bbb4834 100644 (file)
@@ -2663,9 +2663,6 @@ static int qemuProcessHook(void *data)
     if (virSecurityManagerClearSocketLabel(h->driver->securityManager, h->vm->def) < 0)
         goto cleanup;
 
-    if (virProcessSetupPrivateMountNS() < 0)
-        goto cleanup;
-
     if (qemuDomainBuildNamespace(h->driver, h->vm) < 0)
         goto cleanup;