[PATCH] qemu_shim: Require absolute path for root directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The virConnectOpen(), well virConnectOpenInternal() reports an
error if embed root is not an absolute path. This is a fair
requirement, but our qemu_shim doesn't check this requirement and
instead mkdir()-s passed path only to fail later on, leaving the
empty directory behind:

  $ ls -d asd
  ls: cannot access 'asd': No such file or directory

  $ virt-qemu-run -r asd whatever.xml
  virt-qemu-run: cannot open qemu:///embed?root=asd: unsupported configuration: root path must be absolute

  $ ls -d asd
  asd

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_shim.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c
index 7b58583074..33a6aa7d94 100644
--- a/src/qemu/qemu_shim.c
+++ b/src/qemu/qemu_shim.c
@@ -209,10 +209,18 @@ int main(int argc, char **argv)
         }
         tmproot = true;
 
-    } else if (g_mkdir_with_parents(root, 0755) < 0) {
-        g_printerr("%s: cannot create dir: %s\n",
-                   argv[0], g_strerror(errno));
-        goto cleanup;
+    } else {
+        if (!g_path_is_absolute(root)) {
+            g_printerr("%s: the root directory must be an absolute path\n",
+                       argv[0]);
+            goto cleanup;
+        }
+
+        if (g_mkdir_with_parents(root, 0755) < 0) {
+            g_printerr("%s: cannot create dir: %s\n",
+                       argv[0], g_strerror(errno));
+            goto cleanup;
+        }
     }
 
     if (chmod(root, 0755) < 0) {
-- 
2.39.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux