From b1fef732258ed9418f509ca1a4bf6cb31f55e2e9 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 25 Feb 2021 16:29:22 +0100 Subject: [PATCH] virConnectOpen: Require root dir to be absolute path In theory, users might want to use a relative path as a root directory for embed drivers. But in practice, nothing in driver initialization (specifically QEMU driver since it's the only one that supports embedding now), is prepared for that. Document and enforce absolute paths. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1883725 Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- docs/drvqemu.html.in | 2 ++ src/libvirt.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/docs/drvqemu.html.in b/docs/drvqemu.html.in index 375c1b0352..fdf74979ad 100644 --- a/docs/drvqemu.html.in +++ b/docs/drvqemu.html.in @@ -73,6 +73,8 @@ qemu+ssh://root@example.com/system (remote access, SSH tunnelled) registered & be running an instance of the event loop. To open the driver in embedded mode the app use the new URI path and specify a virtual root directory under which the driver will create content. + The path to the root directory must be absolute. Passing a relative + path results in an error.

diff --git a/src/libvirt.c b/src/libvirt.c
index 5778b5daee..f2f0efa0cb 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -996,6 +996,12 @@ virConnectOpenInternal(const char *name,
             if (!root)
                 goto failed;
 
+            if (!g_path_is_absolute(root)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("root path must be absolute"));
+                goto failed;
+            }
+
             if (virEventRequireImpl() < 0)
                 goto failed;
 
-- 
2.47.2