All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly
@ 2017-03-26 14:35 Alan Jenkins
  2017-03-26 14:35 ` [PATCH 2/2] policycoreutils: fixfiles: handle unexpected spaces in command Alan Jenkins
  2017-03-28 19:55 ` [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly James Carter
  0 siblings, 2 replies; 3+ messages in thread
From: Alan Jenkins @ 2017-03-26 14:35 UTC (permalink / raw)
  To: selinux; +Cc: Alan Jenkins

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(-)

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
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] policycoreutils: fixfiles: handle unexpected spaces in command
  2017-03-26 14:35 [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly Alan Jenkins
@ 2017-03-26 14:35 ` Alan Jenkins
  2017-03-28 19:55 ` [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly James Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Jenkins @ 2017-03-26 14:35 UTC (permalink / raw)
  To: selinux; +Cc: Alan Jenkins

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: ...

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

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly
  2017-03-26 14:35 [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly Alan Jenkins
  2017-03-26 14:35 ` [PATCH 2/2] policycoreutils: fixfiles: handle unexpected spaces in command Alan Jenkins
@ 2017-03-28 19:55 ` James Carter
  1 sibling, 0 replies; 3+ messages in thread
From: James Carter @ 2017-03-28 19:55 UTC (permalink / raw)
  To: Alan Jenkins, selinux

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
>


-- 
James Carter <jwcart2@tycho.nsa.gov>
National Security Agency

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-28 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26 14:35 [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly Alan Jenkins
2017-03-26 14:35 ` [PATCH 2/2] policycoreutils: fixfiles: handle unexpected spaces in command Alan Jenkins
2017-03-28 19:55 ` [PATCH 1/2] policycoreutils: fixfiles should handle path arguments more robustly James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.