| Server IP : 172.67.216.113 / Your IP : 172.71.28.146 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /usr/lib64/python2.6/site-packages/setools/ |
Upload File : |
#!/usr/bin/env python
# Author: Thomas Liu <[email protected]>
import _sesearch
import _seinfo
import types
TYPE = _seinfo.TYPE
ROLE = _seinfo.ROLE
ATTRIBUTE = _seinfo.ATTRIBUTE
PORT = _seinfo.PORT
USER = _seinfo.USER
ALLOW = 'allow'
AUDITALLOW = 'auditallow'
NEVERALLOW = 'neverallow'
DONTAUDIT = 'dontaudit'
SCONTEXT = 'scontext'
TCONTEXT = 'tcontext'
PERMS = 'permlist'
CLASS = 'class'
def sesearch(types, info):
valid_types = [ALLOW, AUDITALLOW, NEVERALLOW, DONTAUDIT]
for type in types:
if type not in valid_types:
raise ValueError("Type has to be in %s" % valid_types)
info[type] = True
perms = []
if PERMS in info:
perms = info[PERMS]
info[PERMS] = ",".join(info[PERMS])
dict_list = _sesearch.sesearch(info)
if len(perms) != 0:
dict_list = filter(lambda x: dict_has_perms(x, perms), dict_list)
return dict_list
def dict_has_perms(dict, perms):
for perm in perms:
if perm not in dict[PERMS]:
return False
return True
def seinfo(setype, name=None):
dict_list = _seinfo.seinfo(setype, name)
return dict_list