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

List:       busybox
Subject:    Re: [PATCH v2] sysctl: fix compatibility with procps sysctl
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2019-02-08 15:53:44
Message-ID: CAK1hOcMMFeZRZuUTEEC68ikNUShikR1NPQMPAkP=Nst9kpHm9Q () mail ! gmail ! com
[Download RAW message or body]

Applied in a slightly different form. Please test current git.

On Mon, Feb 4, 2019 at 8:38 PM Aaro Koskinen <aaro.koskinen@iki.fi> wrote:
>
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
>
> Busybox sysctl is incompatible with procps when '.' appears in
> directory name, mostly happens with VLANs.
>
>         busybox syntax (since 2008): net.ipv4.conf.eth0.100.mc_forwarding
>          procps syntax (since 2002): net.ipv4.conf.eth0/100.mc_forwarding
>                  (supported by both: net/ipv4/conf/eth0.100/mc_forwarding)
>
> Use procps syntax for output; for input, allow both.
>
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
>
>         v2: Drop the config option, and support the busybox-specific syntax on
>             input.
>
>  procps/sysctl.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/procps/sysctl.c b/procps/sysctl.c
> index 5fa7646d1..eb5ed37dc 100644
> --- a/procps/sysctl.c
> +++ b/procps/sysctl.c
> @@ -57,7 +57,28 @@ enum {
>  static void sysctl_dots_to_slashes(char *name)
>  {
>         char *cptr, *last_good, *end;
> +       int n = 0;
>
> +       if (!strchr(name, '/'))
> +               goto busybox_old_syntax;
> +
> +       cptr = name;
> +       while (*cptr) {
> +               if (*cptr == '.') {
> +                       *cptr = '/';
> +                       n++;
> +               } else if (*cptr == '/') {
> +                       if (!n)
> +                               return; /* slash syntax is used */
> +                       *cptr = '.';
> +               } else if (*cptr == '=') {
> +                       return;
> +               }
> +               cptr++;
> +       }
> +       return;
> +
> +busybox_old_syntax:
>         /* Convert minimum number of '.' to '/' so that
>          * we end up with existing file's name.
>          *
> @@ -112,6 +133,8 @@ static int sysctl_act_on_setting(char *setting)
>         while (*cptr) {
>                 if (*cptr == '/')
>                         *cptr = '.';
> +               else if (*cptr == '.')
> +                       *cptr = '/';
>                 cptr++;
>         }
>
> --
> 2.17.0
>
> _______________________________________________
> 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