openvpn-authenticator: Avoid infinite loop when losing socket connection

This patch will gracefully terminate the daemon when it loses its
connection to the OpenVPN daemon.

Fixes: #12963
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
This commit is contained in:
Michael Tremer
2022-12-06 10:01:42 +00:00
committed by Peter Müller
parent 9e7d4102b8
commit 92a9ce54bc

View File

@@ -116,11 +116,16 @@ class OpenVPNAuthenticator(object):
log.info("OpenVPN Authenticator started")
while True:
line = self._read_line()
try:
while True:
line = self._read_line()
if line.startswith(">CLIENT"):
self._client_event(line)
if line.startswith(">CLIENT"):
self._client_event(line)
# Terminate the daemon when it loses its connection to the OpenVPN daemon
except ConnectionResetError as e:
log.error("Connection to OpenVPN has been lost: %s" % e)
log.info("OpenVPN Authenticator terminated")