Commit 069a4bcf authored by Guido Trotter's avatar Guido Trotter
Browse files

Workaround missing SO_PEERCRED

This bug happens in a few new distributions, so we workaround it by
defining the constant ourselves, if it's missing.
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarThomas Thrainer <>
parent ae549364
......@@ -52,6 +52,12 @@ from ganeti import vcluster
# Workaround a bug in some linux distributions that don't define SO_PEERCRED
except AttributeError:
# Regexes used to find IP addresses in the output of ip.
_IP_RE_TEXT = r"[.:a-z0-9]+" # separate for testing purposes
_IP_FAMILY_RE = re.compile(r"(?P<family>inet6?)\s+(?P<ip>%s)/" % _IP_RE_TEXT,
......@@ -93,7 +99,7 @@ def GetSocketCredentials(sock):
@return: The PID, UID and GID of the connected foreign process.
peercred = sock.getsockopt(socket.SOL_SOCKET, IN.SO_PEERCRED,
peercred = sock.getsockopt(socket.SOL_SOCKET, _SO_PEERCRED,
return struct.unpack(_STRUCT_UCRED, peercred)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment