mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-24 03:59:41 +00:00
sepolicy: ignore comments and empty lines in file_contexts.subs_dist
In refpolicy, file_contexts.subs_dist begins with comments: # This file can is used to configure base path aliases as in: # # /aliased_path /original_path_as_configured_in_file_contexts # The first line gets parsed in read_file_equiv even though it is not a valid path substitution and the second line triggers an exception when accessing f[1]: IndexError: list index out of range Parse substitutions only for lines which are not comment. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
6d9258e5a0
commit
175efbf3ae
@ -526,10 +526,10 @@ def find_entrypoint_path(exe, exclude_list=[]):
|
||||
def read_file_equiv(edict, fc_path, modify):
|
||||
try:
|
||||
with open(fc_path, "r") as fd:
|
||||
fc = fd.readlines()
|
||||
for e in fc:
|
||||
for e in fd:
|
||||
f = e.split()
|
||||
edict[f[0]] = {"equiv": f[1], "modify": modify}
|
||||
if f and not f[0].startswith('#'):
|
||||
edict[f[0]] = {"equiv": f[1], "modify": modify}
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user