mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-23 19:49:39 +00:00
sepolicy: support non-MLS policy in manpage
"sepolicy manpage" fails when the system does not use MLS because using x.context.range_ raises an exception. Avoid using range and levels when _pol.mls is False. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
07d06cc430
commit
908340e8e7
@ -207,10 +207,17 @@ def info(setype, name=None):
|
||||
elif len(ports) == 1:
|
||||
q.ports = (ports[0], ports[0])
|
||||
|
||||
if _pol.mls:
|
||||
return ({
|
||||
'high': x.ports.high,
|
||||
'protocol': str(x.protocol),
|
||||
'range': str(x.context.range_),
|
||||
'type': str(x.context.type_),
|
||||
'low': x.ports.low,
|
||||
} for x in q.results())
|
||||
return ({
|
||||
'high': x.ports.high,
|
||||
'protocol': str(x.protocol),
|
||||
'range': str(x.context.range_),
|
||||
'type': str(x.context.type_),
|
||||
'low': x.ports.low,
|
||||
} for x in q.results())
|
||||
@ -220,11 +227,16 @@ def info(setype, name=None):
|
||||
if name:
|
||||
q.name = name
|
||||
|
||||
if _pol.mls:
|
||||
return ({
|
||||
'range': str(x.mls_range),
|
||||
'name': str(x),
|
||||
'roles': list(map(str, x.roles)),
|
||||
'level': str(x.mls_level),
|
||||
} for x in q.results())
|
||||
return ({
|
||||
'range': str(x.mls_range),
|
||||
'name': str(x),
|
||||
'roles': list(map(str, x.roles)),
|
||||
'level': str(x.mls_level),
|
||||
} for x in q.results())
|
||||
|
||||
elif setype == BOOLEAN:
|
||||
|
@ -84,7 +84,8 @@ def get_all_users_info():
|
||||
|
||||
for d in allusers_info:
|
||||
allusers.append(d['name'])
|
||||
users_range[d['name'].split("_")[0]] = d['range']
|
||||
if 'range' in d:
|
||||
users_range[d['name'].split("_")[0]] = d['range']
|
||||
|
||||
for u in allusers:
|
||||
if u not in ["system_u", "root", "unconfined_u"]:
|
||||
|
Loading…
Reference in New Issue
Block a user