klippy_connection: handle credential exceptions

Handle exceptions should the attempt to fetch peer
credentials on the unix socket fail.  This isn't a hard
requirement for connection and should not cause
the connection to abort.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan committed 2022-04-08 14:37:11 -04:00
1 parent b21f909705
commit 7631999c8f
1 file changed
+8 -2
+8 -2
View File
@@ -232,8 +232,14 @@ class KlippyConnection:
"Unable to get Unix Socket, cant fetch peer credentials"
)
return
data = sock.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, 12)
pid, uid, gid = struct.unpack("@LLL", data)
try:
data = sock.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, 12)
pid, uid, gid = struct.unpack("@LLL", data)
except asyncio.CancelledError:
raise
except Exception:
logging.exception("Failed to get Klippy Credentials")
return
self._peer_cred = {
"process_id": pid,
"user_id": uid,