diff mbox

[1/2] policycoreutils: fixfiles should handle path arguments more robustly

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

Commit Message

Alan Jenkins March 26, 2017, 2:35 p.m. UTC
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

Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
---
 policycoreutils/scripts/fixfiles | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

James Carter March 28, 2017, 7:55 p.m. UTC | #1
On 03/26/2017 10:35 AM, Alan Jenkins wrote:
> 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
>
> Signed-off-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>

Both of these have been applied.

Thanks,
Jim

> ---
>  policycoreutils/scripts/fixfiles | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
> index 3896d19..d3a53ba 100755
> --- a/policycoreutils/scripts/fixfiles
> +++ b/policycoreutils/scripts/fixfiles
> @@ -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
>
diff mbox

Patch

diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 3896d19..d3a53ba 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -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