policycoreutils: fixfiles: clarify exclude_dirs()

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!)
This commit is contained in:
Alan Jenkins 2017-05-04 18:01:19 +01:00 committed by James Carter
parent aa62e3665c
commit 08df753962
1 changed files with 7 additions and 10 deletions

View File

@ -101,15 +101,6 @@ exclude_dirs_from_relabelling() {
echo "$exclude_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 # Set global Variables
# #
@ -162,6 +153,12 @@ newer() {
# run restorecon on all files affected by the differences. # run restorecon on all files affected by the differences.
# #
diff_filecontext() { 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 if [ -f ${PREFC} -a -x /usr/bin/diff ]; then
TEMPFILE=`mktemp ${FC}.XXXXXXXXXX` TEMPFILE=`mktemp ${FC}.XXXXXXXXXX`
test -z "$TEMPFILE" && exit test -z "$TEMPFILE" && exit
@ -191,7 +188,7 @@ if [ -f ${PREFC} -a -x /usr/bin/diff ]; then
esac; \ esac; \
fi; \ fi; \
done | \ done | \
${RESTORECON} ${VERBOSE} -i -f - -R $* `exclude_dirs`; \ ${RESTORECON} ${VERBOSE} -i -f - -R $* $exclude_dirs; \
rm -f ${TEMPFILE} ${PREFCTEMPFILE} rm -f ${TEMPFILE} ${PREFCTEMPFILE}
fi fi
} }