[PATCH] telnet: busybox telnet autologin with -a -l user option picks incorrect username
Tito
farmatito at tiscali.it
Thu Aug 17 11:56:17 UTC 2017
On 08/17/2017 01:14 PM, Athira Rajeev wrote:
>
>> On 17-Aug-2017, at 4:21 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>>
>> 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?
>>
>
> Hi Denys,
>
> Thanks for the quick response. And yes, the above change works . Checked with -a, -l and giving both options !
>
> Thanks
> Athira Rajeev
>
Hi,
why not (untested):
#if ENABLE_FEATURE_TELNET_AUTOLOGIN
G.autologin = getenv("USER");
getopt32(argv, "al:", &G.autologin);
argv += optind;
#else
argv++;
Ciao,
Tito
More information about the busybox
mailing list