当前位置: 首页>>代码示例>>Python>>正文


Python os.getresgid方法代码示例

本文整理汇总了Python中os.getresgid方法的典型用法代码示例。如果您正苦于以下问题:Python os.getresgid方法的具体用法?Python os.getresgid怎么用?Python os.getresgid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


在下文中一共展示了os.getresgid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _accetable_group_map

# 需要导入模块: import os [as 别名]
# 或者: from os import getresgid [as 别名]
def _accetable_group_map(group_map):
    if not group_map:
        return False

    rgid, egid, sgid = getresgid()

    inter_id, outer_id, _range = _covert_map_to_tuple(group_map, 'group')

    if i_am_not_superuser():
        _id = outer_id
        _max_id = outer_id + _range
        if _range > 3:
            return False
        while _id < _max_id:
            if _id not in [rgid, egid, sgid]:
                return False
            _id += 1

    return True 
开发者ID:procszoo,项目名称:procszoo,代码行数:21,代码来源:__init__.py

示例2: get_current_users_and_groups

# 需要导入模块: import os [as 别名]
# 或者: from os import getresgid [as 别名]
def get_current_users_and_groups(displayer=None):
    ruid, euid, suid = getresuid()
    rgid, egid, sgid = getresgid()
    supplementary_groups = os.getgroups()

    _supplementary_groups = []
    for _id in supplementary_groups:
        _name = get_name_by_gid(_id)
        _supplementary_groups.append({'name': _name, 'id': _id})

    return {
        'users': {
            'real user': {'name': get_name_by_uid(ruid), 'id': ruid},
            'effective user': {'name': get_name_by_uid(euid), 'id': euid},
            'saved user': {'name': get_name_by_uid(suid), 'id': suid},},
        'groups': {
            'real group': {'name': get_name_by_gid(rgid), 'id': rgid},
            'effective group': {'name': get_name_by_gid(rgid), 'id': rgid},
            'saved group': {'name': get_name_by_gid(rgid), 'id': rgid},},
        'supplementary_groups': _supplementary_groups,
        } 
开发者ID:procszoo,项目名称:procszoo,代码行数:23,代码来源:__init__.py

示例3: test_gids

# 需要导入模块: import os [as 别名]
# 或者: from os import getresgid [as 别名]
def test_gids(self):
        p = psutil.Process()
        real, effective, saved = p.gids()
        # os.getuid() refers to "real" uid
        self.assertEqual(real, os.getgid())
        # os.geteuid() refers to "effective" uid
        self.assertEqual(effective, os.getegid())
        # No such thing as os.getsgid() ("saved" gid), but starting
        # from python 2.7 we have os.getresgid() which returns all
        # of them.
        if hasattr(os, "getresuid"):
            self.assertEqual(os.getresgid(), p.gids()) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:14,代码来源:test_process.py

示例4: getresgid

# 需要导入模块: import os [as 别名]
# 或者: from os import getresgid [as 别名]
def getresgid(self):
        try:
            os.getresgid
        except AttributeError:
            pass
        else:
            return os.getresgid()

        rgid = c_int()
        egid = c_int()
        sgid = c_int()
        self._c_func_getresgid(rgid, egid, sgid)

        return (rgid.value, egid.value, sgid.value) 
开发者ID:procszoo,项目名称:procszoo,代码行数:16,代码来源:__init__.py

示例5: show_user_group_process_info

# 需要导入模块: import os [as 别名]
# 或者: from os import getresgid [as 别名]
def show_user_group_process_info():
    '''TBW'''
    # XXX environment variable stuff is Unix-centric
    # XXX UID/GID/EGID is Unix-centric.
    try:
        pid = os.getpid()
        uid = os.getuid()
        gid = os.getgid()
        pgrp = os.getpgrp()
        ppid = os.getppid()
        # egid = os.getegid()
        # euid = os.geteuid()
        (ruid, euid, suid) = os.getresuid()
        (rgid, egid, sgid) = os.getresgid()
    except:
        error('Unable to get user/process/group info.')
        sys.exc_info()
        return
    if ((uid == 0) and (euid == 0)):  # XXX or?
        info('User is ROOT.')
    else:
        info('User is NOT root.')
    log('UID=' + str(uid) +
        ', GID=' + str(gid) +
        ', EUID=' + str(euid) +
        ', EGID=' + str(egid) +
        ', RUID=' + str(ruid) +
        ', RGID=' + str(rgid) +
        ', SUID=' + str(suid) +
        ', SGID=' + str(sgid) +
        ', PID=' + str(pid) +
        ', PPID=' + str(ppid) +
        ', PGRP=' + str(pgrp))
    # XXX which to use, os.environ['s'] or getenv('s')?
    try:
        user = os.environ['USER']
        home = os.environ['HOME']
        logname = os.environ['LOGNAME']
        log('HOME     = ' + home)
        log('USER     = ' + user)
        log('LOGNAME  = ' + logname)
    except:
        error('Unable to get env info.')
        sys.exc_info()
        return
    try:
        cwd = os.getcwd()
        log('cwd = ' + cwd)
        getuid_name = pwd.getpwuid(os.getuid())[0]
        log('uid0 name = ' + getuid_name)
        getlogin_name = os.getlogin()
        log('login name = ' + getlogin_name)
    except:
        error('Unable to get system info.')
        sys.exc_info() 
开发者ID:PreOS-Security,项目名称:fwaudit,代码行数:57,代码来源:fwaudit.py


注:本文中的os.getresgid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。