diff mbox series

[ovs-dev] ovs-ctl: Prepend OVS binary directories to PATH.

Message ID 20201028194752.1409953-1-fbl@sysclose.org
State Accepted
Headers show
Series [ovs-dev] ovs-ctl: Prepend OVS binary directories to PATH. | expand

Commit Message

Flavio Leitner Oct. 28, 2020, 7:47 p.m. UTC
The inclusion of LSB functions in ovs-lib resets $PATH to
system's default. Then ovs-ctl appends missing directories
including the OVS default ones $sbindir and $bindir.

The problem is that the wrong binaries can be used if they
are available in the system's default locations because of
the PATH wrong order. The same issue happens if one changes
$OVS_BINDIR or $OVS_SBINDIR variables.

The solution is to prepend those directories if they are not
already in PATH.

Reported-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Flavio Leitner <fbl@sysclose.org>
---
 utilities/ovs-ctl.in | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Mark Gray Oct. 29, 2020, 10:01 a.m. UTC | #1
On 28/10/2020 19:47, Flavio Leitner wrote:
> The inclusion of LSB functions in ovs-lib resets $PATH to
> system's default. Then ovs-ctl appends missing directories
> including the OVS default ones $sbindir and $bindir.
> 
> The problem is that the wrong binaries can be used if they
> are available in the system's default locations because of
> the PATH wrong order. The same issue happens if one changes
> $OVS_BINDIR or $OVS_SBINDIR variables.
> 
> The solution is to prepend those directories if they are not
> already in PATH.
> 
> Reported-by: Mark Gray <mark.d.gray@redhat.com>
> Signed-off-by: Flavio Leitner <fbl@sysclose.org>
> ---
>  utilities/ovs-ctl.in | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
> index 8c5cd7032..8ff500f0d 100644
> --- a/utilities/ovs-ctl.in
> +++ b/utilities/ovs-ctl.in
> @@ -22,7 +22,11 @@ esac
>  for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
>      case :$PATH: in
>          *:$dir:*) ;;
> -        *) PATH=$PATH:$dir ;;
> +        *)
> +        case $dir in
> +            $sbindir | $bindir) PATH=$dir:$PATH ;;
> +            *) PATH=$PATH:$dir ;;
> +        esac
>      esac
>  done
>  
> 
Tested and see no problems with the approach

Acked-by: Mark Gray <mark.d.gray@redhat.com>
Paolo Valerio Dec. 22, 2020, 10:16 p.m. UTC | #2
Flavio Leitner <fbl@sysclose.org> writes:

> The inclusion of LSB functions in ovs-lib resets $PATH to
> system's default. Then ovs-ctl appends missing directories
> including the OVS default ones $sbindir and $bindir.
>
> The problem is that the wrong binaries can be used if they
> are available in the system's default locations because of
> the PATH wrong order. The same issue happens if one changes
> $OVS_BINDIR or $OVS_SBINDIR variables.
>
> The solution is to prepend those directories if they are not
> already in PATH.
>
> Reported-by: Mark Gray <mark.d.gray@redhat.com>
> Signed-off-by: Flavio Leitner <fbl@sysclose.org>
> ---
>  utilities/ovs-ctl.in | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
> index 8c5cd7032..8ff500f0d 100644
> --- a/utilities/ovs-ctl.in
> +++ b/utilities/ovs-ctl.in
> @@ -22,7 +22,11 @@ esac
>  for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
>      case :$PATH: in
>          *:$dir:*) ;;
> -        *) PATH=$PATH:$dir ;;
> +        *)
> +        case $dir in
> +            $sbindir | $bindir) PATH=$dir:$PATH ;;
> +            *) PATH=$PATH:$dir ;;
> +        esac
>      esac
>  done
>  
> -- 
> 2.26.2

Acked-by: Paolo Valerio <pvalerio@redhat.com>
Ilya Maximets Jan. 27, 2021, 5 p.m. UTC | #3
On 10/28/20 8:47 PM, Flavio Leitner wrote:
> The inclusion of LSB functions in ovs-lib resets $PATH to
> system's default. Then ovs-ctl appends missing directories
> including the OVS default ones $sbindir and $bindir.
> 
> The problem is that the wrong binaries can be used if they
> are available in the system's default locations because of
> the PATH wrong order. The same issue happens if one changes
> $OVS_BINDIR or $OVS_SBINDIR variables.
> 
> The solution is to prepend those directories if they are not
> already in PATH.
> 
> Reported-by: Mark Gray <mark.d.gray@redhat.com>
> Signed-off-by: Flavio Leitner <fbl@sysclose.org>
> ---

Thanks!  Applied to master.
If you think that this needs to be backported, please let me know.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 8c5cd7032..8ff500f0d 100644
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -22,7 +22,11 @@  esac
 for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
     case :$PATH: in
         *:$dir:*) ;;
-        *) PATH=$PATH:$dir ;;
+        *)
+        case $dir in
+            $sbindir | $bindir) PATH=$dir:$PATH ;;
+            *) PATH=$PATH:$dir ;;
+        esac
     esac
 done