mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #809 from zbuc/pfctl_errhandling
Better error handling/reporting for pfctl failures on OS X
This commit is contained in:
commit
fb463f50ed
@ -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.")
|
||||
|
Loading…
Reference in New Issue
Block a user