- # capsh has a --user option starting with f14
- # so if only for f12 we need to fake this one
- #
- # capsh.c does essentially the following when invoked with --user:
- # pwd = getpwnam(user); ...
- # ngroups = MAX_GROUPS;
- # status = getgrouplist(user, pwd->pw_gid, groups, &ngroups); ...
- # status = setgroups(ngroups, groups); ...
- # status = setgid(pwd->pw_gid); ...
- # status = setuid(pwd->pw_uid); ...
- # however we cannot simulate that ourselves because if we did in this process then
- # capsh could not be allowed to mess with caps any more
-
- def getuid (slicename):
- import pwd
- try:
- return pwd.getpwnam(slicename).pw_uid
- except:
- return
-