From 59789bae7df5de6d7568a1b372b95a891fd5c3a2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 3 Oct 2019 16:06:15 -0400 Subject: [PATCH] Fix python3 ctypes str usage In python3, the string is likely to be unicode and incompatible with the libc function. If it isn't bytes, force it to be bytes. --- confluent_server/confluent/userutil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/confluent_server/confluent/userutil.py b/confluent_server/confluent/userutil.py index 04f8e976..a171758d 100644 --- a/confluent_server/confluent/userutil.py +++ b/confluent_server/confluent/userutil.py @@ -18,6 +18,8 @@ def getgrouplist(name, gid, ng=32): _getgrouplist.argtypes = [c_char_p, c_uint, POINTER(c_uint * ng), POINTER(c_int)] glist = (c_uint * ng)() nglist = c_int(ng) + if not isinstance(name, bytes): + name = name.encode('utf-8') count = _getgrouplist(name, gid, byref(glist), byref(nglist)) if count < 0: raise TooSmallException(nglist.value)