diff options
Diffstat (limited to 'libmproxy/platform')
-rw-r--r-- | libmproxy/platform/osx.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libmproxy/platform/osx.py b/libmproxy/platform/osx.py index c5922850..2824718e 100644 --- a/libmproxy/platform/osx.py +++ b/libmproxy/platform/osx.py @@ -19,8 +19,17 @@ class Resolver(object): def original_addr(self, csock): peer = csock.getpeername() - stxt = subprocess.check_output(self.STATECMD, stderr=subprocess.STDOUT) - if "sudo: a password is required" in stxt: + try: + stxt = subprocess.check_output(self.STATECMD, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError, e: + if "sudo: a password is required" in e.output: + insufficient_priv = True + else: + raise RuntimeError("Error getting pfctl state: " + repr(e)) + else: + insufficient_priv = "sudo: a password is required" in stxt + + if insufficient_priv: raise RuntimeError( "Insufficient privileges to access pfctl. " "See http://mitmproxy.org/doc/transparent/osx.html for details.") |