From 825de497675df7040452e1f03b8c3bf74a237682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 20 Mar 2018 15:54:23 +0100 Subject: [PATCH] storage: make DirectoryThinPool helper less verbose, add sudo Don't print scary messages when given pool cannot be found. Also, add sudo to make it work from non-root user (tests) --- qubes/storage/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index f373740a..45eb79ae 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -932,9 +932,12 @@ class DirectoryThinPool: fs_major = (fs_stat.st_dev & 0xff00) >> 8 fs_minor = fs_stat.st_dev & 0xff - root_table = subprocess.check_output(["dmsetup", + sudo = [] + if os.getuid(): + sudo = ['sudo'] + root_table = subprocess.check_output(sudo + ["dmsetup", "-j", str(fs_major), "-m", str(fs_minor), - "table"]) + "table"], stderr=subprocess.DEVNULL) _start, _sectors, target_type, target_args = \ root_table.decode().split(" ", 3)