Python os.getresuid() Examples
The following are 12
code examples of os.getresuid().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: __init__.py From procszoo with GNU General Public License v3.0 | 6 votes |
def _accetable_user_map(user_map): if not user_map: return False ruid, euid, suid = getresuid() inter_id, outer_id, _range = _covert_map_to_tuple(user_map, 'user') 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 [ruid, euid, suid]: return False _id += 1 return True
Example #2
Source File: __init__.py From procszoo with GNU General Public License v3.0 | 6 votes |
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, }
Example #3
Source File: test_process.py From vnpy_crypto with MIT License | 5 votes |
def test_uids(self): p = psutil.Process() real, effective, saved = p.uids() # os.getuid() refers to "real" uid self.assertEqual(real, os.getuid()) # os.geteuid() refers to "effective" uid self.assertEqual(effective, os.geteuid()) # No such thing as os.getsuid() ("saved" uid), but starting # from python 2.7 we have os.getresuid() which returns all # of them. if hasattr(os, "getresuid"): self.assertEqual(os.getresuid(), p.uids())
Example #4
Source File: test_process.py From vnpy_crypto with MIT License | 5 votes |
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())
Example #5
Source File: test_process.py From psutil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_uids(self): p = psutil.Process() real, effective, saved = p.uids() # os.getuid() refers to "real" uid self.assertEqual(real, os.getuid()) # os.geteuid() refers to "effective" uid self.assertEqual(effective, os.geteuid()) # No such thing as os.getsuid() ("saved" uid), but starting # from python 2.7 we have os.getresuid() which returns all # of them. if hasattr(os, "getresuid"): self.assertEqual(os.getresuid(), p.uids())
Example #6
Source File: test_process.py From psutil with BSD 3-Clause "New" or "Revised" License | 5 votes |
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())
Example #7
Source File: _util.py From shadowsocks with Apache License 2.0 | 5 votes |
def _make_passphrase(length=None, save=False, file=None): """Create a passphrase and write it to a file that only the user can read. This is not very secure, and should not be relied upon for actual key passphrases. :param int length: The length in bytes of the string to generate. :param file file: The file to save the generated passphrase in. If not given, defaults to 'passphrase-<the real user id>-<seconds since epoch>' in the top-level directory. """ if not length: length = 40 passphrase = _make_random_string(length) if save: ruid, euid, suid = os.getresuid() gid = os.getgid() now = mktime(localtime()) if not file: filename = str('passphrase-%s-%s' % uid, now) file = os.path.join(_repo, filename) with open(file, 'a') as fh: fh.write(passphrase) fh.flush() fh.close() os.chmod(file, stat.S_IRUSR | stat.S_IWUSR) os.chown(file, ruid, gid) log.warn("Generated passphrase saved to %s" % file) return passphrase
Example #8
Source File: __init__.py From procszoo with GNU General Public License v3.0 | 5 votes |
def getresuid(self): try: os.getresuid except AttributeError: pass else: return os.getresuid() ruid = c_int() euid = c_int() suid = c_int() self._c_func_getresuid(ruid, euid, suid) return (ruid.value, euid.value, suid.value)
Example #9
Source File: __init__.py From procszoo with GNU General Public License v3.0 | 5 votes |
def getresuid(): return workbench.getresuid()
Example #10
Source File: test_process.py From jarvis with GNU General Public License v2.0 | 5 votes |
def test_uids(self): p = psutil.Process() real, effective, saved = p.uids() # os.getuid() refers to "real" uid self.assertEqual(real, os.getuid()) # os.geteuid() refers to "effective" uid self.assertEqual(effective, os.geteuid()) # No such thing as os.getsuid() ("saved" uid), but starting # from python 2.7 we have os.getresuid() which returns all # of them. if hasattr(os, "getresuid"): self.assertEqual(os.getresuid(), p.uids())
Example #11
Source File: test_process.py From jarvis with GNU General Public License v2.0 | 5 votes |
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())
Example #12
Source File: fwaudit.py From fwaudit with GNU General Public License v2.0 | 4 votes |
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()