user_dirs.py 文件源码

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

项目:unearth 作者: chilcote 项目源码 文件源码
def fact():
    '''Gets the home directories of all console users'''
    users = []
    homes = []

    excluded = ('root', 'daemon', 'nobody')
    cmd = ['/usr/bin/dscl', '.', 'list', '/Users']
    output = subprocess.check_output(cmd)
    for user in output.split():
        if user not in excluded and not user.startswith('_'):
            users.append(user)

    for user in users:
        cmd = ['/usr/bin/dscl', '-plist', '.', 'read', '/Users/' + user]
        output = subprocess.check_output(cmd)
        d = plistlib.readPlistFromString(output)
        homes.append(d['dsAttrTypeStandard:NFSHomeDirectory'][0])

    return {factoid: homes}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号