python类getpwall()的实例源码

CGIHTTPServer.py 文件源码 项目:empyrion-python-api 作者: huhlig 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
    return nobody
server.py 文件源码 项目:UMOG 作者: hsab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
test_process.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def setUp(self):
        if POSIX:
            import pwd
            import grp
            users = pwd.getpwall()
            groups = grp.getgrall()
            self.all_uids = set([x.pw_uid for x in users])
            self.all_usernames = set([x.pw_name for x in users])
            self.all_gids = set([x.gr_gid for x in groups])
test_process.py 文件源码 项目:FancyWord 作者: EastonLee 项目源码 文件源码 阅读 59 收藏 0 点赞 0 评论 0
def setUp(self):
        if POSIX:
            import pwd
            import grp
            users = pwd.getpwall()
            groups = grp.getgrall()
            self.all_uids = set([x.pw_uid for x in users])
            self.all_usernames = set([x.pw_name for x in users])
            self.all_gids = set([x.gr_gid for x in groups])
server.py 文件源码 项目:blackmamba 作者: zrzka 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
server.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
server.py 文件源码 项目:beepboop 作者: nicolehe 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
server.py 文件源码 项目:deb-python-eventlet 作者: openstack 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
conf.py 文件源码 项目:PolyArchiv 作者: d9pouces 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def check_username(value):
    if value not in {x[0] for x in pwd.getpwall()}:
        raise ValueError('%s is not a valid user' % value)
    return value
sshady.py 文件源码 项目:sshady 作者: droberson 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def find_ssh_directories():
    """ find_ssh_directories() -- Search pwents for home directories with .ssh
            directories. Scans each file in .ssh directory for valid SSH keys.
            Valid keys are added to VALID_KEYS list.

    Args:
        None

    Returns:
        True
    """
    # TODO: search /home for orphaned home directories that may contain keys
    xprint("[+] Searching for SSH keys via valid pwents..")

    for pwent in pwd.getpwall():
        user = pwent[0]
        sshdir = os.path.join(os.path.expanduser("~%s" % user), ".ssh")

        if os.path.isdir(sshdir):
            xprint("[*] Found .ssh directory for user %s: %s" % (user, sshdir))
            for root, _, filenames in os.walk(sshdir):
                for filename in filenames:
                    checkfile = os.path.join(root, filename)
                    process_key(checkfile, user)

    xprint("")
    xprint("[+] %s usable %s discovered." %
           (len(VALID_KEYS), "keys" if len(VALID_KEYS) > 1 else "key"))

    return True
server.py 文件源码 项目:hackathon 作者: vertica 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
server.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def nobody_uid():
    """Internal routine to get nobody's uid"""
    global nobody
    if nobody:
        return nobody
    try:
        import pwd
    except ImportError:
        return -1
    try:
        nobody = pwd.getpwnam('nobody')[2]
    except KeyError:
        nobody = 1 + max(x[2] for x in pwd.getpwall())
    return nobody
shistory.py 文件源码 项目:shistory 作者: mazingerzzz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def list_user_homedir():
    for p in pwd.getpwall():
        if p[6] == '/bin/bash' and p[0] not in users_blacklist:
            users[p[0]] = p[5]


问题


面经


文章

微信
公众号

扫码关注公众号