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

[virt-tools-list] [PATCH 2/3] virtManager: when present, prefer the user specified in capabilities



Prefer the user specified in the host capabilities to the default one
when checking for the access to disk images.

Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
---
 virtManager/uihelpers.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/virtManager/uihelpers.py b/virtManager/uihelpers.py
index 3928849..4238790 100644
--- a/virtManager/uihelpers.py
+++ b/virtManager/uihelpers.py
@@ -21,6 +21,7 @@
 import logging
 import os
 import statvfs
+import pwd
 
 # pylint: disable=E0611
 from gi.repository import GObject
@@ -1008,6 +1009,15 @@ def check_path_search_for_qemu(err, conn, path):
 
     user = config.running_config.default_qemu_user
 
+    for i in conn.caps.host.secmodels:
+        if i.model == "dac":
+            label = i.baselabels.get("kvm") or i.baselabels.get("qemu")
+            if not label:
+                continue
+            pwuid = pwd.getpwuid(int(label.split(":")[0].replace("+", "")))
+            if pwuid:
+                user = pwuid[0]
+
     skip_paths = config.running_config.get_perms_fix_ignore()
     broken_paths = virtinst.VirtualDisk.check_path_search_for_user(
                                                           conn.get_backend(),
-- 
1.8.3.1


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