On Tue, Jan 17, 2017 at 12:32:16PM +0100, Michal Privoznik wrote:
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(a)redhat.com>
---
src/qemu/qemu_domain.c | 3 +++
src/qemu/qemu_process.c | 3 ---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 35baffb51..c67604222 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7400,6 +7400,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
goto cleanup;
}
+ if (virProcessSetupPrivateMountNS() < 0)
+ goto cleanup;
+
if (qemuDomainSetupDev(driver, vm, devPath) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a980f5a9e..184440dc1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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;
Tested-by: Richard W.M. Jones <rjones(a)redhat.com>
The commit message should also refer to the bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1413922
Please make sure this bug blocks the release of 3.0.0.
Thanks,
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org