|
|
9bbebd |
From 99582e3bf63475b7af5793bb9230e88d847dc7c8 Mon Sep 17 00:00:00 2001
|
|
|
9bbebd |
From: Petr Lautrbach <plautrba@redhat.com>
|
|
|
9bbebd |
Date: Tue, 2 Jul 2019 17:11:32 +0200
|
|
|
9bbebd |
Subject: [PATCH] policycoreutils/fixfiles: Fix [-B] [-F] onboot
|
|
|
9bbebd |
|
|
|
9bbebd |
Commit 6e289bb7bf3d ("policycoreutils: fixfiles: remove bad modes of "relabel"
|
|
|
9bbebd |
command") added "$RESTORE_MODE" != DEFAULT test when onboot is used. It makes
|
|
|
9bbebd |
`fixfiles -B onboot` to show usage instead of updating /.autorelabel
|
|
|
9bbebd |
|
|
|
9bbebd |
The code is restructured to handle -B for different modes correctly.
|
|
|
9bbebd |
|
|
|
9bbebd |
Fixes:
|
|
|
9bbebd |
# fixfiles -B onboot
|
|
|
9bbebd |
Usage: /usr/sbin/fixfiles [-v] [-F] [-f] relabel
|
|
|
9bbebd |
...
|
|
|
9bbebd |
|
|
|
9bbebd |
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
|
|
|
9bbebd |
---
|
|
|
9bbebd |
policycoreutils/scripts/fixfiles | 29 +++++++++++++++--------------
|
|
|
9bbebd |
1 file changed, 15 insertions(+), 14 deletions(-)
|
|
|
9bbebd |
|
|
|
9bbebd |
diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
|
|
|
9bbebd |
index 53d28c7b..9dd44213 100755
|
|
|
9bbebd |
--- a/policycoreutils/scripts/fixfiles
|
|
|
9bbebd |
+++ b/policycoreutils/scripts/fixfiles
|
|
|
9bbebd |
@@ -112,7 +112,7 @@ VERBOSE="-p"
|
|
|
9bbebd |
FORCEFLAG=""
|
|
|
9bbebd |
RPMFILES=""
|
|
|
9bbebd |
PREFC=""
|
|
|
9bbebd |
-RESTORE_MODE="DEFAULT"
|
|
|
9bbebd |
+RESTORE_MODE=""
|
|
|
9bbebd |
SETFILES=/sbin/setfiles
|
|
|
9bbebd |
RESTORECON=/sbin/restorecon
|
|
|
9bbebd |
FILESYSTEMSRW=`get_rw_labeled_mounts`
|
|
|
9bbebd |
@@ -214,16 +214,17 @@ restore () {
|
|
|
9bbebd |
OPTION=$1
|
|
|
9bbebd |
shift
|
|
|
9bbebd |
|
|
|
9bbebd |
-case "$RESTORE_MODE" in
|
|
|
9bbebd |
- PREFC)
|
|
|
9bbebd |
- diff_filecontext $*
|
|
|
9bbebd |
- return
|
|
|
9bbebd |
- ;;
|
|
|
9bbebd |
- BOOTTIME)
|
|
|
9bbebd |
+# [-B | -N time ]
|
|
|
9bbebd |
+if [ -z "$BOOTTIME" ]; then
|
|
|
9bbebd |
newer $BOOTTIME $*
|
|
|
9bbebd |
return
|
|
|
9bbebd |
- ;;
|
|
|
9bbebd |
-esac
|
|
|
9bbebd |
+fi
|
|
|
9bbebd |
+
|
|
|
9bbebd |
+# -C PREVIOUS_FILECONTEXT
|
|
|
9bbebd |
+if [ "$RESTORE_MODE" == PREFC ]; then
|
|
|
9bbebd |
+ diff_filecontext $*
|
|
|
9bbebd |
+ return
|
|
|
9bbebd |
+fi
|
|
|
9bbebd |
|
|
|
9bbebd |
[ -x /usr/sbin/genhomedircon ] && /usr/sbin/genhomedircon
|
|
|
9bbebd |
|
|
|
9bbebd |
@@ -239,7 +240,7 @@ case "$RESTORE_MODE" in
|
|
|
9bbebd |
FILEPATH)
|
|
|
9bbebd |
${RESTORECON} ${VERBOSE} ${EXCLUDEDIRS} ${FORCEFLAG} $* -R -- "$FILEPATH"
|
|
|
9bbebd |
;;
|
|
|
9bbebd |
- DEFAULT)
|
|
|
9bbebd |
+ *)
|
|
|
9bbebd |
if [ -n "${FILESYSTEMSRW}" ]; then
|
|
|
9bbebd |
LogReadOnly
|
|
|
9bbebd |
echo "${OPTION}ing `echo ${FILESYSTEMSRW}`"
|
|
|
9bbebd |
@@ -272,7 +273,7 @@ fullrelabel() {
|
|
|
9bbebd |
|
|
|
9bbebd |
|
|
|
9bbebd |
relabel() {
|
|
|
9bbebd |
- if [ "$RESTORE_MODE" != DEFAULT ]; then
|
|
|
9bbebd |
+ if [ -n "$RESTORE_MODE" -a "$RESTORE_MODE" != DEFAULT ]; then
|
|
|
9bbebd |
usage
|
|
|
9bbebd |
exit 1
|
|
|
9bbebd |
fi
|
|
|
9bbebd |
@@ -306,7 +307,7 @@ case "$1" in
|
|
|
9bbebd |
verify) restore Verify -n;;
|
|
|
9bbebd |
relabel) relabel;;
|
|
|
9bbebd |
onboot)
|
|
|
9bbebd |
- if [ "$RESTORE_MODE" != DEFAULT ]; then
|
|
|
9bbebd |
+ if [ -n "$RESTORE_MODE" -a "$RESTORE_MODE" != DEFAULT ]; then
|
|
|
9bbebd |
usage
|
|
|
9bbebd |
exit 1
|
|
|
9bbebd |
fi
|
|
|
9bbebd |
@@ -344,7 +345,7 @@ if [ $# -eq 0 ]; then
|
|
|
9bbebd |
fi
|
|
|
9bbebd |
|
|
|
9bbebd |
set_restore_mode() {
|
|
|
9bbebd |
- if [ "$RESTORE_MODE" != DEFAULT ]; then
|
|
|
9bbebd |
+ if [ -n "$RESTORE_MODE" ]; then
|
|
|
9bbebd |
# can't specify two different modes
|
|
|
9bbebd |
usage
|
|
|
9bbebd |
exit 1
|
|
|
9bbebd |
@@ -357,7 +358,7 @@ while getopts "N:BC:FfR:l:v" i; do
|
|
|
9bbebd |
case "$i" in
|
|
|
9bbebd |
B)
|
|
|
9bbebd |
BOOTTIME=`/bin/who -b | awk '{print $3}'`
|
|
|
9bbebd |
- set_restore_mode BOOTTIME
|
|
|
9bbebd |
+ set_restore_mode DEFAULT
|
|
|
9bbebd |
;;
|
|
|
9bbebd |
N)
|
|
|
9bbebd |
BOOTTIME=$OPTARG
|
|
|
9bbebd |
--
|
|
|
9bbebd |
2.21.0
|
|
|
9bbebd |
|