Fix handling OSError in FirewallClient#__init__

This commit is contained in:
Krouton 2020-11-16 10:36:39 +09:00
parent 6b75d62d68
commit 5ff834bd32

View File

@ -223,7 +223,6 @@ class FirewallClient:
def setup(): def setup():
# run in the child process # run in the child process
s2.close() s2.close()
e = None
if os.getuid() == 0: if os.getuid() == 0:
argv_tries = argv_tries[-1:] # last entry only argv_tries = argv_tries[-1:] # last entry only
for argv in argv_tries: for argv in argv_tries:
@ -232,16 +231,13 @@ class FirewallClient:
sys.stderr.write('[local su] ') sys.stderr.write('[local su] ')
self.p = ssubprocess.Popen(argv, stdout=s1, preexec_fn=setup) self.p = ssubprocess.Popen(argv, stdout=s1, preexec_fn=setup)
# No env: Talking to `FirewallClient.start`, which has no i18n. # No env: Talking to `FirewallClient.start`, which has no i18n.
e = None
break break
except OSError: except OSError as e:
pass log('Spawning firewall manager: %r\n' % argv)
raise Fatal(e)
self.argv = argv self.argv = argv
s1.close() s1.close()
self.pfile = s2.makefile('rwb') self.pfile = s2.makefile('rwb')
if e:
log('Spawning firewall manager: %r\n' % self.argv)
raise Fatal(e)
line = self.pfile.readline() line = self.pfile.readline()
self.check() self.check()
if line[0:5] != b'READY': if line[0:5] != b'READY':