diff options
author | Chris Czub <chris.czub@gmail.com> | 2015-10-29 15:56:43 -0400 |
---|---|---|
committer | Chris Czub <chris.czub@gmail.com> | 2015-10-29 15:56:43 -0400 |
commit | 70c28f5d34c0bf3a74b84e89b7817d1d0fd9058b (patch) | |
tree | 12307b0b6caf44af23aecd4c51f946d4035f141c /libmproxy/platform/osx.py | |
parent | 65c08ec899f5041f279e9e68d100ce0829f9f3e5 (diff) | |
download | mitmproxy-70c28f5d34c0bf3a74b84e89b7817d1d0fd9058b.tar.gz mitmproxy-70c28f5d34c0bf3a74b84e89b7817d1d0fd9058b.tar.bz2 mitmproxy-70c28f5d34c0bf3a74b84e89b7817d1d0fd9058b.zip |
Better error handling/reporting for pfctl failures on OS X
Diffstat (limited to 'libmproxy/platform/osx.py')
-rw-r--r-- | libmproxy/platform/osx.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libmproxy/platform/osx.py b/libmproxy/platform/osx.py index c5922850..194e9cad 100644 --- a/libmproxy/platform/osx.py +++ b/libmproxy/platform/osx.py @@ -19,8 +19,15 @@ 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)) + + if insufficient_priv is True or "sudo: a password is required" in stxt: raise RuntimeError( "Insufficient privileges to access pfctl. " "See http://mitmproxy.org/doc/transparent/osx.html for details.") |