diff mbox

[3/6] policycoreutils: fixfiles: clarify exclude_dirs()

Message ID 20170504170122.26882-3-alan.christopher.jenkins@gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Alan Jenkins May 4, 2017, 5:01 p.m. UTC
The usage of exclude_dirs() is non-obvious.

It turns out it is only used by the `-C` mode of fixfiles.  The other four
modes use the narrower list generated by exclude_dirs_from_relabelling().
Let's make this distinction more obvious.

(The purpose of the extra exclusions is not clear.  E.g. there's an
exclusion for /dev.  Whereas the `fixfiles check` mode explicitly tells you
that it's going to relabel /dev, without causing any problem.  Maybe that
part is out of date?  But without some explanation of the list, I don't
want to change anything!)
---
 policycoreutils/scripts/fixfiles | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 7e5ce88..dae073d 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -101,15 +101,6 @@  exclude_dirs_from_relabelling() {
     echo "$exclude_from_relabelling"
 }
 
-exclude_dirs() {
-    exclude=
-    for i in /sys /proc /dev /run /mnt /var/tmp /var/lib/BackupPC /home /tmp /dev; do
-	[ -e $i ]  && exclude="$exclude -e $i";
-    done
-    exclude="$exclude `exclude_dirs_from_relabelling`"
-    echo "$exclude"
-}
-
 #
 # Set global Variables
 #
@@ -162,6 +153,12 @@  newer() {
 # run restorecon on all files affected by the differences.
 #
 diff_filecontext() {
+exclude_dirs=
+for i in /sys /proc /dev /run /mnt /var/tmp /var/lib/BackupPC /home /tmp /dev; do
+    [ -e $i ]  && exclude_dirs="$exclude_dirs -e $i";
+done
+exclude_dirs="$exclude_dirs `exclude_dirs_from_relabelling`"
+
 if [ -f ${PREFC} -a -x /usr/bin/diff ]; then
 	TEMPFILE=`mktemp ${FC}.XXXXXXXXXX`
 	test -z "$TEMPFILE" && exit
@@ -191,7 +188,7 @@  if [ -f ${PREFC} -a -x /usr/bin/diff ]; then
 		  esac; \
 	       fi; \
 	    done | \
-	${RESTORECON} ${VERBOSE} -i -f - -R $* `exclude_dirs`; \
+	${RESTORECON} ${VERBOSE} -i -f - -R $* $exclude_dirs; \
 	rm -f ${TEMPFILE} ${PREFCTEMPFILE}
 fi
 }