From cbfd0dc8873fbfb604782faded94fc77a7ab9430 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 23 Jan 2018 23:07:07 +0100 Subject: [tests] workaround for functional tests in docker polkit doesn't work inside docker. --- src/leap/bitmask/vpn/_checks.py | 3 +++ src/leap/bitmask/vpn/helpers/__init__.py | 1 - src/leap/bitmask/vpn/privilege.py | 3 +++ tests/functional/features/steps/vpn.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/leap/bitmask/vpn/_checks.py b/src/leap/bitmask/vpn/_checks.py index 681f7428..2549e366 100644 --- a/src/leap/bitmask/vpn/_checks.py +++ b/src/leap/bitmask/vpn/_checks.py @@ -27,6 +27,9 @@ def get_failure_for(provider): def is_service_ready(provider): if not _has_valid_cert(provider): return False + if os.getuid() == 0: + # it's your problem if you run as root, not mine. + return True if IS_LINUX and not is_pkexec_in_system(): log.warn('System has no pkexec') return False diff --git a/src/leap/bitmask/vpn/helpers/__init__.py b/src/leap/bitmask/vpn/helpers/__init__.py index 69b34e00..b0f6990f 100644 --- a/src/leap/bitmask/vpn/helpers/__init__.py +++ b/src/leap/bitmask/vpn/helpers/__init__.py @@ -62,7 +62,6 @@ if IS_LINUX: openvpn = (os.path.exists(OPENVPN_SYSTEM) or _is_up_to_date(_config.get_bitmask_openvpn_path(), OPENVPN_LOCAL, "")) - return helper and polkit and openvpn def _is_up_to_date(src, local, system): diff --git a/src/leap/bitmask/vpn/privilege.py b/src/leap/bitmask/vpn/privilege.py index 1856ec8c..9c9ce130 100644 --- a/src/leap/bitmask/vpn/privilege.py +++ b/src/leap/bitmask/vpn/privilege.py @@ -147,6 +147,9 @@ class LinuxPolicyChecker(object): # Note that gnome-shell does not uses a separate process for the # polkit-agent, it uses a polkit-agent within its own process so we # can't ps-grep a polkit process, we can ps-grep gnome-shell itself. + if os.getuid() == 0: + # if you're running as root, it's your problem, not mine. + return True running = False for proc in psutil.process_iter(): diff --git a/tests/functional/features/steps/vpn.py b/tests/functional/features/steps/vpn.py index 489d4234..be50175d 100644 --- a/tests/functional/features/steps/vpn.py +++ b/tests/functional/features/steps/vpn.py @@ -22,7 +22,7 @@ def apply_dns_workaround(): resolv = commands.getoutput('cat /etc/resolv.conf') print("original resolv.conf: %s" % resolv) result = commands.getoutput( - 'echo "nameserver 10.42.0.1" > /etc/resolv.conf') + 'echo "nameserver 10.41.0.1" > /etc/resolv.conf') resolv2 = commands.getoutput('cat /etc/resolv.conf') print("changed resolv.conf: %s" % resolv2) print("Workaround OK") -- cgit v1.2.3