pwd.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:ave 作者: sonyxperiadev 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号