diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-06-05 17:31:37 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2017-06-07 12:31:25 +0200 |
commit | 05f2b9d2b72139df56f67e88aeb7ceb6d8ec4e69 (patch) | |
tree | 6fce3da1defff38fe799321e3adfa7bc56537295 /src/leap/bitmask/vpn/fw | |
parent | 1c418514c6f3ea57570023833ef66d2c9d3473f2 (diff) |
[feature] run vpn directly if user is root
- Improve tests too: add entry in resolv.conf, not done without
resolvconf
Diffstat (limited to 'src/leap/bitmask/vpn/fw')
-rw-r--r-- | src/leap/bitmask/vpn/fw/firewall.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/leap/bitmask/vpn/fw/firewall.py b/src/leap/bitmask/vpn/fw/firewall.py index 95130b2..73eccb9 100644 --- a/src/leap/bitmask/vpn/fw/firewall.py +++ b/src/leap/bitmask/vpn/fw/firewall.py @@ -23,12 +23,12 @@ import commands import os import subprocess -from twisted.logger import getLogger +from twisted.logger import Logger from leap.bitmask.vpn.constants import IS_MAC from leap.common.events import catalog, emit_async -log = getLogger() +log = Logger() # TODO -- subclass it for osx/windows, not only for linux. @@ -43,7 +43,6 @@ NOT_ROOT = os.getuid() != 0 def check_root(cmd): if NOT_ROOT: cmd = ['pkexec'] + cmd - print "COMMAND IS >>>", cmd return cmd @@ -86,13 +85,14 @@ class FirewallManager(object): if restart: cmd.append("restart") + result = '<did not run>' try: - result = subprocess.check_output( - cmd + gateways, - stderr=subprocess.STDOUT) + retcode, result = commands.getstatusoutput( + ' '.join(cmd + gateways)) + #stderr=subprocess.STDOUT) except Exception: log.failure('Error launching the firewall') - else: + finally: log.debug(result) emit_async(catalog.VPN_STATUS_CHANGED) return True |