99cbc7
From cebb6519a3a4b65bf89d7f5ea7bf390f2303f5ee Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <cebb6519a3a4b65bf89d7f5ea7bf390f2303f5ee@dist-git>
99cbc7
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
99cbc7
Date: Wed, 3 Oct 2018 16:58:18 +0200
99cbc7
Subject: [PATCH] qemu: fix up permissions for pre-created UNIX sockets
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
My commit d6b8838 fixed the uid:gid for the pre-created UNIX sockets
99cbc7
but did not account for the different umask of libvirtd and QEMU.
99cbc7
Since commit 0e1a1a8c we set umask to '0002' for the QEMU process.
99cbc7
Manually tune-up the permissions to match what we would have gotten
99cbc7
if QEMU had created the socket.
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1633389
99cbc7
99cbc7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
99cbc7
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
(cherry picked from commit 8ba65c4d95712b54362fd81c34bae99f51d45a0b)
99cbc7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
99cbc7
99cbc7
RHEL 7.6.z: https://bugzilla.redhat.com/show_bug.cgi?id=1635228
99cbc7
RHEL 8.0: https://bugzilla.redhat.com/show_bug.cgi?id=1634775
99cbc7
99cbc7
Reviewed-by: Erik Skultety <eskultet@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_command.c | 6 ++++++
99cbc7
 1 file changed, 6 insertions(+)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
99cbc7
index f2b64ed720..98b554627e 100644
99cbc7
--- a/src/qemu/qemu_command.c
99cbc7
+++ b/src/qemu/qemu_command.c
99cbc7
@@ -4933,6 +4933,12 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev)
99cbc7
         goto error;
99cbc7
     }
99cbc7
 
99cbc7
+    /* We run QEMU with umask 0002. Compensate for the umask
99cbc7
+     * libvirtd might be running under to get the same permission
99cbc7
+     * QEMU would have. */
99cbc7
+    if (virFileUpdatePerm(dev->data.nix.path, 0002, 0664) < 0)
99cbc7
+        goto error;
99cbc7
+
99cbc7
     return fd;
99cbc7
 
99cbc7
  error:
99cbc7
-- 
99cbc7
2.21.0
99cbc7