Re-run mitmproxywrapper.py with sudo if necessary.
This commit is contained in:
parent
ceafd411f3
commit
09c95ece52
|
@ -11,6 +11,8 @@ import subprocess
|
|||
import re
|
||||
import argparse
|
||||
import contextlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
class Wrapper(object):
|
||||
|
||||
|
@ -103,6 +105,12 @@ class Wrapper(object):
|
|||
if self.proxy_enabled_for_service(service_name):
|
||||
self.disable_proxy_for_service(service_name)
|
||||
|
||||
@classmethod
|
||||
def ensure_superuser(cls):
|
||||
if os.getuid() != 0:
|
||||
print 'Relaunching with sudo...'
|
||||
os.execv('/usr/bin/sudo', ['/usr/bin/sudo'] + sys.argv)
|
||||
|
||||
@classmethod
|
||||
def main(cls):
|
||||
parser = argparse.ArgumentParser(description='Helper tool for OS X proxy configuration and mitmproxy')
|
||||
|
@ -122,5 +130,6 @@ class Wrapper(object):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Wrapper.ensure_superuser()
|
||||
Wrapper.main()
|
||||
|
||||
|
|
Loading…
Reference in New Issue