utils.py 文件源码

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

项目:beesly 作者: bincyber 项目源码 文件源码
def get_group_membership(username):
    """
    Returns a list of groups the user is a member of to support Role-Based Access Control.
    The `id` command is used because it reports all (POSIX) groups that the user
    is a member of including external groups from Identity Management systems (AD, IdM, FreeIPA).

    Arguments
    ----------
    username : string
      the username to get group membership for
    """
    exe = find_executable('id')
    p = subprocess.Popen([exe, '-Gn', username], stdout=subprocess.PIPE)
    groups = p.stdout.read().split()
    groups.remove(username)
    return groups
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号