All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] ip: don't use program name to select command
@ 2021-01-11 19:05 Matteo Croce
  2021-01-14  3:20 ` David Ahern
  0 siblings, 1 reply; 2+ messages in thread
From: Matteo Croce @ 2021-01-11 19:05 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, David Ahern

From: Matteo Croce <mcroce@microsoft.com>

ip has an ancient behaviour of looking at its program name to determine
the command to run. If the name is longer than 2 characters, the first two
letters are stripped and the others are interpreted as the command name:

    $ ln -s /sbin/ip iproute
    $ ln -s /sbin/ip ipa
    $ ./iproute
    default via 192.168.55.1 dev wlp0s20f3 proto dhcp metric 600
    192.168.55.0/24 dev wlp0s20f3 proto kernel scope link src 192.168.55.26 metric 600
    192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
    $ ./ipa show dev lo
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever

This creates problems when the ip binary is renamed. For example, Yocto
renames it to 'ip.iproute2' when also the busybox implementation is
present, giving the following error:

    $ ip.iproute2
    Object ".iproute2" is unknown, try "ip help".

Since noone is using it, remove this undocumented feature.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
---
 ip/ip.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/ip/ip.c b/ip/ip.c
index 40d2998a..9b772307 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -311,9 +311,6 @@ int main(int argc, char **argv)
 
 	rtnl_set_strict_dump(&rth);
 
-	if (strlen(basename) > 2)
-		return do_cmd(basename+2, argc, argv);
-
 	if (argc > 1)
 		return do_cmd(argv[1], argc-1, argv+1);
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2-next] ip: don't use program name to select command
  2021-01-11 19:05 [PATCH iproute2-next] ip: don't use program name to select command Matteo Croce
@ 2021-01-14  3:20 ` David Ahern
  0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2021-01-14  3:20 UTC (permalink / raw)
  To: Matteo Croce, netdev; +Cc: Stephen Hemminger

On 1/11/21 12:05 PM, Matteo Croce wrote:
> From: Matteo Croce <mcroce@microsoft.com>
> 
> ip has an ancient behaviour of looking at its program name to determine
> the command to run. If the name is longer than 2 characters, the first two
> letters are stripped and the others are interpreted as the command name:
> 
>     $ ln -s /sbin/ip iproute
>     $ ln -s /sbin/ip ipa
>     $ ./iproute
>     default via 192.168.55.1 dev wlp0s20f3 proto dhcp metric 600
>     192.168.55.0/24 dev wlp0s20f3 proto kernel scope link src 192.168.55.26 metric 600
>     192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
>     $ ./ipa show dev lo
>     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
>         link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>         inet 127.0.0.1/8 scope host lo
>            valid_lft forever preferred_lft forever
> 
> This creates problems when the ip binary is renamed. For example, Yocto
> renames it to 'ip.iproute2' when also the busybox implementation is
> present, giving the following error:
> 
>     $ ip.iproute2
>     Object ".iproute2" is unknown, try "ip help".
> 
> Since noone is using it, remove this undocumented feature.
> 
> Signed-off-by: Matteo Croce <mcroce@microsoft.com>
> ---
>  ip/ip.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/ip/ip.c b/ip/ip.c
> index 40d2998a..9b772307 100644
> --- a/ip/ip.c
> +++ b/ip/ip.c
> @@ -311,9 +311,6 @@ int main(int argc, char **argv)
>  
>  	rtnl_set_strict_dump(&rth);
>  
> -	if (strlen(basename) > 2)
> -		return do_cmd(basename+2, argc, argv);
> -
>  	if (argc > 1)
>  		return do_cmd(argv[1], argc-1, argv+1);
>  
> 

This has been around for too long to just remove it. How about adding an
option to do_cmd that this appears to be guess based on basename? If the
guess is wrong, fallback to the next do_cmd.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-14  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 19:05 [PATCH iproute2-next] ip: don't use program name to select command Matteo Croce
2021-01-14  3:20 ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.