]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
openvpn-authenticator: Break read loop when daemon goes away
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 6 Dec 2022 10:01:44 +0000 (10:01 +0000)
committerPeter Müller <peter.mueller@ipfire.org>
Sun, 11 Dec 2022 11:53:12 +0000 (11:53 +0000)
Fixes: #12963
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
config/ovpn/openvpn-authenticator

index c22e08f0a99a4ddbcbf4569947582fefd88a959d..4341993e6da8ed5ffa3b0df7d30a1bb132ff2773 100644 (file)
@@ -68,6 +68,12 @@ class OpenVPNAuthenticator(object):
 
                while True:
                        char = self.sock.recv(1)
+
+                       # Break if we could not read from the socket
+                       if not char:
+                               raise EOFError("Could not read from socket")
+
+                       # Append to buffer
                        buf.append(char)
 
                        # Reached end of line
@@ -112,7 +118,7 @@ class OpenVPNAuthenticator(object):
                                        self._client_event(line)
 
                # Terminate the daemon when it loses its connection to the OpenVPN daemon
-               except ConnectionResetError as e:
+               except (ConnectionResetError, EOFError) as e:
                        log.error("Connection to OpenVPN has been lost: %s" % e)
 
                log.info("OpenVPN Authenticator terminated")