python/semanage: Do not sort local fcontext definitions
Entries in file_contexts.local are processed from the most recent one to the oldest, with first match being used. Therefore it is important to preserve their order when listing (semanage fcontext -lC) and exporting (semanage export). Signed-off-by: Vit Mojzis <vmojzis@redhat.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
fc2822a474
commit
1a3d58945b
|
@ -133,7 +133,11 @@ class fcontextPage(semanagePage):
|
||||||
self.fcontext = seobject.fcontextRecords()
|
self.fcontext = seobject.fcontextRecords()
|
||||||
self.store.clear()
|
self.store.clear()
|
||||||
fcon_dict = self.fcontext.get_all(self.local)
|
fcon_dict = self.fcontext.get_all(self.local)
|
||||||
for k in sorted(fcon_dict.keys()):
|
if self.local:
|
||||||
|
fkeys = fcon_dict.keys()
|
||||||
|
else:
|
||||||
|
fkeys = sorted(fcon_dict.keys())
|
||||||
|
for k in fkeys:
|
||||||
if not self.match(fcon_dict, k, filter):
|
if not self.match(fcon_dict, k, filter):
|
||||||
continue
|
continue
|
||||||
iter = self.store.append()
|
iter = self.store.append()
|
||||||
|
|
|
@ -2653,7 +2653,7 @@ class fcontextRecords(semanageRecords):
|
||||||
def customized(self):
|
def customized(self):
|
||||||
l = []
|
l = []
|
||||||
fcon_dict = self.get_all(True)
|
fcon_dict = self.get_all(True)
|
||||||
for k in sorted(fcon_dict.keys()):
|
for k in fcon_dict.keys():
|
||||||
if fcon_dict[k]:
|
if fcon_dict[k]:
|
||||||
if fcon_dict[k][3]:
|
if fcon_dict[k][3]:
|
||||||
l.append("-a -f %s -t %s -r '%s' '%s'" % (file_type_str_to_option[k[1]], fcon_dict[k][2], fcon_dict[k][3], k[0]))
|
l.append("-a -f %s -t %s -r '%s' '%s'" % (file_type_str_to_option[k[1]], fcon_dict[k][2], fcon_dict[k][3], k[0]))
|
||||||
|
@ -2670,7 +2670,12 @@ class fcontextRecords(semanageRecords):
|
||||||
if len(fcon_dict) != 0:
|
if len(fcon_dict) != 0:
|
||||||
if heading:
|
if heading:
|
||||||
print("%-50s %-18s %s\n" % (_("SELinux fcontext"), _("type"), _("Context")))
|
print("%-50s %-18s %s\n" % (_("SELinux fcontext"), _("type"), _("Context")))
|
||||||
for k in sorted(fcon_dict.keys()):
|
# do not sort local customizations since they are evaluated based on the order they where added in
|
||||||
|
if locallist:
|
||||||
|
fkeys = fcon_dict.keys()
|
||||||
|
else:
|
||||||
|
fkeys = sorted(fcon_dict.keys())
|
||||||
|
for k in fkeys:
|
||||||
if fcon_dict[k]:
|
if fcon_dict[k]:
|
||||||
if is_mls_enabled:
|
if is_mls_enabled:
|
||||||
print("%-50s %-18s %s:%s:%s:%s " % (k[0], k[1], fcon_dict[k][0], fcon_dict[k][1], fcon_dict[k][2], translate(fcon_dict[k][3], False)))
|
print("%-50s %-18s %s:%s:%s:%s " % (k[0], k[1], fcon_dict[k][0], fcon_dict[k][1], fcon_dict[k][2], translate(fcon_dict[k][3], False)))
|
||||||
|
|
Loading…
Reference in New Issue