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