policycoreutils: semanage: skip comments while reading external configuration files
Fix fcontextRecords() in policycoreutils/semanage/seobject.py so that semanage does not produce an error in fcontext mode when the file_contexts.subs_dist file contains comments (prefixed by #). Properly skip blank lines. Treat both white space and tab as valid separators for the above mentioned policy configuration file (v2). Minimum number of changes (v2bis). Signed-off-by: Guido Trentalancia <guido@trentalancia.com> Reported-by: Sven Vermeulen <sven.vermeulen@siphos.be> Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
parent
1c8a7c194d
commit
b8067636b6
|
@ -1633,6 +1633,11 @@ class fcontextRecords(semanageRecords):
|
||||||
try:
|
try:
|
||||||
fd = open(selinux.selinux_file_context_subs_path(), "r")
|
fd = open(selinux.selinux_file_context_subs_path(), "r")
|
||||||
for i in fd.readlines():
|
for i in fd.readlines():
|
||||||
|
i = i.strip()
|
||||||
|
if len(i) == 0:
|
||||||
|
continue
|
||||||
|
if i.startswith("#"):
|
||||||
|
continue
|
||||||
target, substitute = i.split()
|
target, substitute = i.split()
|
||||||
self.equiv[target] = substitute
|
self.equiv[target] = substitute
|
||||||
fd.close()
|
fd.close()
|
||||||
|
@ -1641,6 +1646,11 @@ class fcontextRecords(semanageRecords):
|
||||||
try:
|
try:
|
||||||
fd = open(selinux.selinux_file_context_subs_dist_path(), "r")
|
fd = open(selinux.selinux_file_context_subs_dist_path(), "r")
|
||||||
for i in fd.readlines():
|
for i in fd.readlines():
|
||||||
|
i = i.strip()
|
||||||
|
if len(i) == 0:
|
||||||
|
continue
|
||||||
|
if i.startswith("#"):
|
||||||
|
continue
|
||||||
target, substitute = i.split()
|
target, substitute = i.split()
|
||||||
self.equiv_dist[target] = substitute
|
self.equiv_dist[target] = substitute
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
Loading…
Reference in New Issue