policycoreutils: fixfiles should handle path arguments more robustly
PATCH 1/2 policycoreutils: fixfiles should handle path arguments more robustly
E.g. fixfiles restore -v /usr - before:
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup
Progress and Verbose mutually exclusive
usage: /sbin/restorecon [-iFnprRv0] [-e excludedir] pathname... usage: /sbin/restorecon [-iFnprRv0] [-e excludedir] -f filename Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup
229k
after:
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup/sbin/restorecon: lstat(-v) failed: No such file or directory
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup
229k
This matches the usage shown in the manual page. While we're in there, we should handle spaces as well e.g fixfiles restore "a b". Before:
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup/sbin/restorecon: lstat(b) failed: No such file or directory
After:
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup/sbin/restorecon: lstat(a b) failed: No such file or directory
--- policycoreutils/scripts/fixfiles | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
policycoreutils/scripts/fixfiles +2 -2
@@ -248,7 +248,7 @@ if [ ! -z "$RPMFILES" ]; then exit $? fi if [ ! -z "$FILEPATH" ]; then - ${RESTORECON} $exclude_dirs ${FORCEFLAG} ${VERBOSE} -R $* $FILEPATH 2>&1 | cat >> $LOGFILE + ${RESTORECON} $exclude_dirs ${FORCEFLAG} ${VERBOSE} -R $* -- "$FILEPATH" 2>&1 | cat >> $LOGFILE return fi if [ -n "${FILESYSTEMSRW}" ]; then
@@ -400,7 +400,7 @@ else process $command else while [ -n "$1" ]; do - FILEPATH=$1 + FILEPATH="$1" process $command shift done
Signature · 1 line
2.9.3
PATCH 2/2 policycoreutils: fixfiles: handle unexpected spaces in command
I accidently ran fixfiles "a b" during testing. Let's fix this too. Before:
/sbin/fixfiles: line 394: [: a: binary operator expected
Usage: ...
After:
Usage: ...
--- policycoreutils/scripts/fixfiles | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
policycoreutils/scripts/fixfiles +5 -5
@@ -378,8 +378,8 @@ done shift $(( OPTIND - 1 )) # Check for the command -command=$1 -if [ -z $command ]; then +command="$1" +if [ -z "$command" ]; then usage fi
@@ -391,17 +391,17 @@ shift # if [ ! -z "$RPMFILES" ]; then - process $command + process "$command" if [ $# -gt 0 ]; then usage fi else if [ -z "$1" ]; then - process $command + process "$command" else while [ -n "$1" ]; do FILEPATH="$1" - process $command + process "$command" shift done fi
Signature · 1 line
2.9.3
Quoted 27 lines · Alan Jenkins
E.g.
fixfiles restore -v /usr- before:Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup
Progress and Verbose mutually exclusiveusage: /sbin/restorecon [-iFnprRv0] [-e excludedir] pathname... usage: /sbin/restorecon [-iFnprRv0] [-e excludedir] -f filename Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup
229kafter:
Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup/sbin/restorecon: lstat(-v) failed: No such file or directory
Warning: Skipping the following R/O filesystems:/sys/fs/cgroup
229kThis matches the usage shown in the manual page. While we're in there, we should handle spaces as well e.g
fixfiles restore "a b". Before:Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup/sbin/restorecon: lstat(b) failed: No such file or directory
Quoted 7 lines
After:
Warning: Skipping the following R/O filesystems:
/sys/fs/cgroup/sbin/restorecon: lstat(a b) failed: No such file or directorySigned-off-by Alan Jenkins <[email protected]>
Both of these have been applied.
Thanks,
Jim
Quoted 27 lines
--- policycoreutils/scripts/fixfiles | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)policycoreutils/scripts/fixfiles +2
-2@@ -248,7 +248,7 @@ if [ ! -z "$RPMFILES" ]; then exit $? fi if [ ! -z "$FILEPATH" ]; then - ${RESTORECON} $exclude_dirs ${FORCEFLAG} ${VERBOSE} -R $* $FILEPATH 2>&1 | cat >> $LOGFILE + ${RESTORECON} $exclude_dirs ${FORCEFLAG} ${VERBOSE} -R $* -- "$FILEPATH" 2>&1 | cat >> $LOGFILE return fi if [ -n "${FILESYSTEMSRW}" ]; then@@ -400,7 +400,7 @@ else process $command else while [ -n "$1" ]; do - FILEPATH=$1 + FILEPATH="$1" process $command shift done
Signature · 2 lines
James Carter <[email protected]> National Security Agency