def getpwnam_gid(name):
cmd = [
'/usr/bin/python2', os.path.realpath(__file__), 'pwd.getpwnam.gid', name
]
s,o,e = ave.cmd.run(cmd)
o = o.strip()
if s != 0:
raise Exception(o)
return int(o)
# a bug in winbindd or its client makes it close "inherited" file descriptors
# *before* it forks. it will in fact close one or more file descriptors which
# it does not own. unfortunately, the Python pwd module may use this backend on
# systems that authenticate against ActiveDirectory. so, calling pwd functions
# must be done in a context where no file descriptors can be clobbered (i.e.
# none were opened before the call). e.g. in a new process (__main__, below).
# it is not entirely safe to communicate with the new process over e.g. a pipe
# as winbindd could clobber *that* file descriptor. printing on stdout appears
# to be safe, so just execute __file__ as a separate program with some options
# to steer the use of pwd and print the result.
评论列表
文章目录