Add doas support for client

This commit is contained in:
evitalis 2018-05-08 19:57:02 -05:00 committed by Brian May
parent 55bd78fd43
commit ae5bd28dcf

View File

@ -184,6 +184,12 @@ class MultiListener:
class FirewallClient: class FirewallClient:
def __init__(self, method_name): def __init__(self, method_name):
# Default to sudo unless on OpenBSD in which case use built in `doas`
elevbin = 'sudo'
if platform.platform().startswith('OpenBSD'):
elevbin = 'doas'
self.auto_nets = [] self.auto_nets = []
python_path = os.path.dirname(os.path.dirname(__file__)) python_path = os.path.dirname(os.path.dirname(__file__))
argvbase = ([sys.executable, sys.argv[0]] + argvbase = ([sys.executable, sys.argv[0]] +
@ -193,10 +199,9 @@ class FirewallClient:
if ssyslog._p: if ssyslog._p:
argvbase += ['--syslog'] argvbase += ['--syslog']
argv_tries = [ argv_tries = [
['sudo', '-p', '[local sudo] Password: ', '/usr/bin/env', ['%(eb)s', '-p', '[local %(eb)s] Password: ', '/usr/bin/env',
('PYTHONPATH=%s' % python_path)] + argvbase, ('PYTHONPATH=%(pp)s' % {'eb': elevbin, 'pp': python_path})] +
argvbase argvbase, argvbase]
]
# we can't use stdin/stdout=subprocess.PIPE here, as we normally would, # we can't use stdin/stdout=subprocess.PIPE here, as we normally would,
# because stupid Linux 'su' requires that stdin be attached to a tty. # because stupid Linux 'su' requires that stdin be attached to a tty.