The python call grp.getgrall() shows only local groups, unlike the call to the getgrouplist c function, which restarts all users, for example, also users in sssd, which is supported by ldap, but the listing is disabled. (as in FreeIPA). After finding the easiest way to get all the groups the users belong to in python, the best way I've found is to call the getgrouplist c function:
#!/usr/bin/python import grp, pwd, os from ctypes import * from ctypes.util import find_library libc = cdll.LoadLibrary(find_library('libc')) getgrouplist = libc.getgrouplist
To get a list of all users for whom this function was run in a similar way, you would need to find out what call c was made by getent passwd and call it in python.
Jens Timmerman Apr 23 '18 at 10:39 2018-04-23 10:39
source share