[PATCH] telnet: busybox telnet autologin with -a -l user option picks incorrect username

Denys Vlasenko vda.linux at googlemail.com
Thu Aug 17 10:51:22 UTC 2017


On Thu, Aug 17, 2017 at 12:01 PM, Athira Rajeev
<atrajeev at linux.vnet.ibm.com> wrote:
>     Adding patch which has the following change similar to telnet which:
>     - Assigns from getenv("USER") only if G.autologin is NULL
>
>     Signed-off-by: Athira Rajeev <atrajeev at linux.vnet.ibm.com>
>
> diff --git a/networking/telnet.c b/networking/telnet.c
> index e1c2595..d1b79a0 100644
> --- a/networking/telnet.c
> +++ b/networking/telnet.c
> @@ -644,7 +644,8 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
>
>  #if ENABLE_FEATURE_TELNET_AUTOLOGIN
>      if (1 & getopt32(argv, "al:", &G.autologin))
> -        G.autologin = getenv("USER");
> +        if (G.autologin == NULL)
> +            G.autologin = getenv("USER");
>      argv += optind;

if (G.autologin == NULL), then -l was not specified.
I propose to simply check for that condition:

if (1 == getopt32(argv, "al:", &G.autologin)) /* -a without -l USER */

and not add more conditionals.

Can you test that this works for you?


More information about the busybox mailing list