mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-05-17 06:30:55 +02:00
Replace BaseException with Exception
BaseException includes exceptions like SystemExit, KeyboardInterrupt and GeneratorExit that we should not be catching.
This commit is contained in:
parent
9e3209e931
commit
d6fa0c1462
@ -200,7 +200,7 @@ def main(method_name, syslog):
|
|||||||
try:
|
try:
|
||||||
(family, width, exclude, ip, fport, lport) = \
|
(family, width, exclude, ip, fport, lport) = \
|
||||||
line.strip().split(',', 5)
|
line.strip().split(',', 5)
|
||||||
except BaseException:
|
except Exception:
|
||||||
raise Fatal('expected route or NSLIST but got %r' % line)
|
raise Fatal('expected route or NSLIST but got %r' % line)
|
||||||
subnets.append((
|
subnets.append((
|
||||||
int(family),
|
int(family),
|
||||||
@ -222,7 +222,7 @@ def main(method_name, syslog):
|
|||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
(family, ip) = line.strip().split(',', 1)
|
(family, ip) = line.strip().split(',', 1)
|
||||||
except BaseException:
|
except Exception:
|
||||||
raise Fatal('expected nslist or PORTS but got %r' % line)
|
raise Fatal('expected nslist or PORTS but got %r' % line)
|
||||||
nslist.append((int(family), ip))
|
nslist.append((int(family), ip))
|
||||||
debug2('Got partial nslist: %r' % nslist)
|
debug2('Got partial nslist: %r' % nslist)
|
||||||
@ -317,46 +317,46 @@ def main(method_name, syslog):
|
|||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
debug1('undoing changes.')
|
debug1('undoing changes.')
|
||||||
except BaseException:
|
except Exception:
|
||||||
debug2('An error occurred, ignoring it.')
|
debug2('An error occurred, ignoring it.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if subnets_v6 or nslist_v6:
|
if subnets_v6 or nslist_v6:
|
||||||
debug2('undoing IPv6 changes.')
|
debug2('undoing IPv6 changes.')
|
||||||
method.restore_firewall(port_v6, socket.AF_INET6, udp, user)
|
method.restore_firewall(port_v6, socket.AF_INET6, udp, user)
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
debug1("Error trying to undo IPv6 firewall.")
|
debug1("Error trying to undo IPv6 firewall.")
|
||||||
debug1(traceback.format_exc())
|
debug1(traceback.format_exc())
|
||||||
except BaseException:
|
except Exception:
|
||||||
debug2('An error occurred, ignoring it.')
|
debug2('An error occurred, ignoring it.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if subnets_v4 or nslist_v4:
|
if subnets_v4 or nslist_v4:
|
||||||
debug2('undoing IPv4 changes.')
|
debug2('undoing IPv4 changes.')
|
||||||
method.restore_firewall(port_v4, socket.AF_INET, udp, user)
|
method.restore_firewall(port_v4, socket.AF_INET, udp, user)
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
debug1("Error trying to undo IPv4 firewall.")
|
debug1("Error trying to undo IPv4 firewall.")
|
||||||
debug1(traceback.format_exc())
|
debug1(traceback.format_exc())
|
||||||
except BaseException:
|
except Exception:
|
||||||
debug2('An error occurred, ignoring it.')
|
debug2('An error occurred, ignoring it.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# debug2() message printed in restore_etc_hosts() function.
|
# debug2() message printed in restore_etc_hosts() function.
|
||||||
restore_etc_hosts(hostmap, port_v6 or port_v4)
|
restore_etc_hosts(hostmap, port_v6 or port_v4)
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
debug1("Error trying to undo /etc/hosts changes.")
|
debug1("Error trying to undo /etc/hosts changes.")
|
||||||
debug1(traceback.format_exc())
|
debug1(traceback.format_exc())
|
||||||
except BaseException:
|
except Exception:
|
||||||
debug2('An error occurred, ignoring it.')
|
debug2('An error occurred, ignoring it.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flush_systemd_dns_cache()
|
flush_systemd_dns_cache()
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
debug1("Error trying to flush systemd dns cache.")
|
debug1("Error trying to flush systemd dns cache.")
|
||||||
debug1(traceback.format_exc())
|
debug1(traceback.format_exc())
|
||||||
except BaseException:
|
except Exception:
|
||||||
debug2("An error occurred, ignoring it.")
|
debug2("An error occurred, ignoring it.")
|
||||||
|
@ -55,7 +55,7 @@ def write_host_cache():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
os.unlink(tmpname)
|
os.unlink(tmpname)
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user