From b8067636b6855384965a74b8bcb1ed886ac68bfb Mon Sep 17 00:00:00 2001 From: Guido Trentalancia Date: Sun, 19 Aug 2012 17:59:20 +0200 Subject: [PATCH] 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 Reported-by: Sven Vermeulen Signed-off-by: Eric Paris --- policycoreutils/semanage/seobject.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py index 8ed26860..ad7dc8ca 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -1633,6 +1633,11 @@ class fcontextRecords(semanageRecords): try: fd = open(selinux.selinux_file_context_subs_path(), "r") for i in fd.readlines(): + i = i.strip() + if len(i) == 0: + continue + if i.startswith("#"): + continue target, substitute = i.split() self.equiv[target] = substitute fd.close() @@ -1641,6 +1646,11 @@ class fcontextRecords(semanageRecords): try: fd = open(selinux.selinux_file_context_subs_dist_path(), "r") for i in fd.readlines(): + i = i.strip() + if len(i) == 0: + continue + if i.startswith("#"): + continue target, substitute = i.split() self.equiv_dist[target] = substitute fd.close()