From 63af64d78df609c28080ebf17dc4200d0bb5d004 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 28 Feb 2020 14:42:44 +0100 Subject: [PATCH] qemu_shim: Allow other users to enter the root dir When virt-qemu-run is ran without any root directory specified on the command line, a temporary directory is made and used instead. But since we are using g_dir_make_tmp() to create the directory it is going to have 0700 mode. So even though we create the whole directory structure under it and label everything, QEMU is very likely to not have the access. This is because in this case there is no qemu.conf and thus distro default UID:GID is used to run QEMU (e.g. qemu:kvm on Fedora). Change the mode of the temporary directory so that everybody has eXecute permission. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/qemu/qemu_shim.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c index 5b7840e971..fd905825aa 100644 --- a/src/qemu/qemu_shim.c +++ b/src/qemu/qemu_shim.c @@ -158,6 +158,12 @@ int main(int argc, char **argv) return 1; } tmproot = true; + + if (chmod(root, 0755) < 0) { + g_printerr("%s: cannot chown temporary dir: %s\n", + argv[0], g_strerror(errno)); + goto cleanup; + } } virFileActivateDirOverrideForProg(argv[0]);