edecca
From e22ab3412457f4d804ad7b0f62bd37ae07ec186d Mon Sep 17 00:00:00 2001
edecca
Message-Id: <e22ab3412457f4d804ad7b0f62bd37ae07ec186d@dist-git>
edecca
From: Peter Krempa <pkrempa@redhat.com>
edecca
Date: Tue, 5 Feb 2019 10:20:33 +0100
edecca
Subject: [PATCH] qemu: caps: Don't try to ask for CAP_DAC_OVERRIDE if non-root
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
It will not work. This breaks qemu capabilities probing as a user.
edecca
edecca
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
edecca
Reviewed-by: Erik Skultety <eskultet@redhat.com>
edecca
(cherry picked from commit 620d9dd598fde388f56ac37bcd3b31168c2f9fc6)
edecca
edecca
https: //bugzilla.redhat.com/show_bug.cgi?id=1665400
edecca
Signed-off-by: Erik Skultety <eskultet@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_capabilities.c | 3 ++-
edecca
 1 file changed, 2 insertions(+), 1 deletion(-)
edecca
edecca
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
edecca
index f71cd08f4d..912f758bcd 100644
edecca
--- a/src/qemu/qemu_capabilities.c
edecca
+++ b/src/qemu/qemu_capabilities.c
edecca
@@ -4482,7 +4482,8 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd,
edecca
 #if WITH_CAPNG
edecca
     /* QEMU might run into permission issues, e.g. /dev/sev (0600), override
edecca
      * them just for the purpose of probing */
edecca
-    virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE);
edecca
+    if (geteuid() == 0)
edecca
+        virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE);
edecca
 #endif
edecca
 
edecca
     virCommandSetGID(cmd->cmd, cmd->runGid);
edecca
-- 
edecca
2.20.1
edecca