[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] nsenter: Fix parsing of -t, -S and -G options
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2018-05-13 18:16:30
Message-ID: CAK1hOcOMPUK3WeZR4peD1j28m4EsfPia6Ptg1d2k2AVe8EWtDw () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks

On Fri, May 4, 2018 at 5:18 PM, Euan Harris <euan.harris@docker.com> wrote:
> -t, -S and -G each take mandatory integer arguments.   getopt32long()'s
> option string syntax for this type of argument is 'c:+', however nsenter's
> opt_str uses 'c+', which specifies two options 'c' and '+' which do not
> take arguments.   This means that giving a target PID causes nsenter to
> exit and print the usage string:
>
>   # nsenter -t1 sh
>   nsenter: unrecognized option: 1
>   BusyBox v1.27.2 (2017-12-12 10:41:50 GMT) multi-call binary.
>   ...
>
> The long form options are also broken:
>
>   # nsenter --setuid=1000 --setgid=1000 sh
>   BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
>   ...
>
> `nsenter --target=<pid> sh` parses correctly and appears to work, but
> <pid> is ignored and set to 0.   This doesn't raise an error unless one
> of the namespace arguments is also given:
>
>   # ./busybox_unstripped nsenter --target=42 sh
>   # exit
>
>   # ./busybox_unstripped nsenter -n --target=42 sh
>   BusyBox v1.29.0.git (2018-05-04 13:56:49 UTC) multi-call binary.
>   ...
>
> This has caused problems in a couple of places:
>
>   https://github.com/linuxkit/linuxkit/issues/567
>   https://github.com/gliderlabs/docker-alpine/issues/359
>   https://github.com/kontena/pharos-cluster/pull/81
>
> Signed-off-by: Euan Harris <euan.harris@docker.com>
> ---
>  util-linux/nsenter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c
> index 35439a2..ae8103a 100644
> --- a/util-linux/nsenter.c
> +++ b/util-linux/nsenter.c
> @@ -105,7 +105,7 @@ static const struct namespace_descr ns_list[] = {
>  /*
>   * Upstream nsenter doesn't support the short option for --preserve-credentials
>   */
> -static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t+S+G+r::w::F";
> +static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t:+S:+G:+r::w::F";
>
>  #if ENABLE_LONG_OPTS
>  static const char nsenter_longopts[] ALIGN1 =
> --
> 2.7.4
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic