Bug#798329: ifconfig: changed output format breaks scripts
On Tue, 8 Sep 2015, Guillem Jover wrote: > Well, the ifconfig implementation in inetutils provides selectable Oh, there’s another one? I’ve not looked at that one (yet)… … but then, I really need something that works even with CentOS, though it (even in version 6, which is way younger than 2003) has the same output format as jessie. > > Finally, I have no intentions on maintaining a fork of net-tools to > > support the 14 years old output format of ifconfig, so I am closing this > > as wontfix. > > This is quite reasonable IMO. Mh okay. I’m using code similar to the following to catch both the old and new format (some day I’m going to test inetutils’): export LC_ALL=C PATH=/bin:/sbin:/usr/bin:/usr/sbin unset LANGUAGE hn=$(hostname -f || echo $(hostname).invalid.fqdn) [[ $hn = *.* ]] || hn=$hn.no.fqdn lladdr= test -s /etc/tarent/primary.mac && lladdr=$(cat /etc/tarent/primary.mac) test -n "$lladdr" || lladdr=$(tgetif | \ sed -ne '/^ *ether \([0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]\)\( .*\)$/s//\1/p' -e '2,$d' -e '/^.* HWaddr \([0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]\)\( .*\)$/s//\1/p' | head -n 1) ipaddr=$(tgetif | sed -n '/^ *inet \(addr:\)*\([0-9.]*\) .*$/s//\2/p') netconf=$(/sbin/ip a | tr '\n' '~' | sed 's/~ /= /g' | tr '~' '\n' | fgrep -v vnet | tr '=' '\n' | sed -ne '/^[0-9]*: \([^:@]*\)\(@NONE\)*\([^:]*\):.*$/s//\1\3/p' -e '/inet/s/ scope.*//p' -e '/ link/s/ brd.*$//p' ) || netconf= Maybe this helps others. bye, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#798329: ifconfig: changed output format breaks scripts
THorsten, On 08/09/15 10:25, Thorsten Glaser wrote: > the changed output format of ifconfig breaks scripts parsing it. [..] > This particularily breaks both getting the MAC address and > the/an IP address. I don't think it is feasible to try and keep the old format, I have finally updated net-tools to what upstream has been doing in the past 10 years.. Is this breaking a package or just your scripts? In any case, I think you should be doing this differently. Either using iproute2 that has a parseable format (although that has changed too), or direcly parsing files in /proc/net -- Martín Ferrari (Tincho)
Bug#798329: ifconfig: changed output format breaks scripts
Package: net-tools Version: 1.60+git20150829.73cef8a-1 Severity: important Hi, the changed output format of ifconfig breaks scripts parsing it. Before: br0 Link encap:Ethernet HWaddr 90:e2:ba:0c:b8:17 inet addr:172.26.3.108 Bcast:172.26.255.255 Mask:255.255.0.0 inet6 addr: fe80::21b:21ff:fe62:2577/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2351724 errors:0 dropped:2931 overruns:0 frame:0 TX packets:525699 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1659213748 (1.5 GiB) TX bytes:216861337 (206.8 MiB) After: br0: flags=4163mtu 1500 inet 172.26.3.108 netmask 255.255.0.0 broadcast 172.26.255.255 inet6 fe80::21b:21ff:fe62:2577 prefixlen 64 scopeid 0x20 ether 90:e2:ba:0c:b8:17 txqueuelen 0 (Ethernet) RX packets 2351867 bytes 1659222913 (1.5 GiB) RX errors 0 dropped 2931 overruns 0 frame 0 TX packets 525708 bytes 216861987 (206.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 This particularily breaks both getting the MAC address and the/an IP address. -- System Information: Debian Release: stretch/sid APT prefers unreleased APT policy: (500, 'unreleased'), (500, 'buildd-unstable'), (500, 'unstable') Architecture: x32 (x86_64) Foreign Architectures: i386, amd64 Kernel: Linux 4.1.0-2-amd64 (SMP w/4 CPU cores) Locale: LANG=C, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/lksh Init: sysvinit (via /sbin/init) Versions of packages net-tools depends on: ii libc6 2.19-19 net-tools recommends no packages. net-tools suggests no packages. -- no debconf information
Bug#798329: ifconfig: changed output format breaks scripts
On Tue, 8 Sep 2015, Martín Ferrari wrote: > Is this breaking a package or just your scripts? This is breaking at least two scripts of mine, which is where and why I noticed this immediately after the dist-upgrade today, but there’ll be others lurking. Probably none of them packaged, though. > In any case, I think you should be doing this differently. Either using > iproute2 that has a parseable format (although that has changed too), or This won’t work, I did quite the WTF today at iproute2 now, as it appends “@NONE” to the interface names. I need reliable, consistent, parsable output across all Debian versions (and some derivates). > direcly parsing files in /proc/net Excuse me, but WTF? The standard Unix interface for things is stdout of other commands, as in, filters and pipes. ifconfig is *the* standard utility to get information about interfaces. bye, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#798329: ifconfig: changed output format breaks scripts
Hi! On Tue, 2015-09-08 at 12:56:09 +0300, Martín Ferrari wrote: > On 08/09/15 12:34, Thorsten Glaser wrote: > > I need reliable, consistent, parsable output across all Debian versions > > (and some derivates). > > There is no software that currently offers that promise. I understand it > is annoying, and myself have reported a bug to iproute2 (#726417) for a > similar situation, but the maintainer also did not want to diverge from > upstream, so I had to live with that. Well, the ifconfig implementation in inetutils provides selectable output formats, which might be close to that promise, but I think I agree in general that relying on this kind of output is not wise. > >> direcly parsing files in /proc/net > > > > Excuse me, but WTF? > > > > The standard Unix interface for things is stdout of other commands, > > as in, filters and pipes. ifconfig is *the* standard utility to get > > information about interfaces. > > Sorry, but ifconfig output is not standarised by policy or any other > doc. In fact, it varies wildly in its many implementations. It has been > deprecated as a means of talking with the network stack in Linux since > iproute exists, which is a Long Time Ago. Yes, see the above comment on inetutils' ifconfig selectable output. > Also, it is not breaking other Debian packages, nor it is > malfunctioning, so severity can't be more than wishlist. We might not know yet, I do actually expect this might break some stuff also parsing output from ifconfig. Perhaps a quick check could be performed on codesearch.d.n? > Finally, I have no intentions on maintaining a fork of net-tools to > support the 14 years old output format of ifconfig, so I am closing this > as wontfix. This is quite reasonable IMO. Thanks, Guillem
Bug#798329: ifconfig: changed output format breaks scripts
severity 798329 wishlist tags 798329 wontfix close 798329 thanks On 08/09/15 12:34, Thorsten Glaser wrote: > I need reliable, consistent, parsable output across all Debian versions > (and some derivates). There is no software that currently offers that promise. I understand it is annoying, and myself have reported a bug to iproute2 (#726417) for a similar situation, but the maintainer also did not want to diverge from upstream, so I had to live with that. >> direcly parsing files in /proc/net > > Excuse me, but WTF? > > The standard Unix interface for things is stdout of other commands, > as in, filters and pipes. ifconfig is *the* standard utility to get > information about interfaces. Sorry, but ifconfig output is not standarised by policy or any other doc. In fact, it varies wildly in its many implementations. It has been deprecated as a means of talking with the network stack in Linux since iproute exists, which is a Long Time Ago. Also, it is not breaking other Debian packages, nor it is malfunctioning, so severity can't be more than wishlist. Finally, I have no intentions on maintaining a fork of net-tools to support the 14 years old output format of ifconfig, so I am closing this as wontfix. -- Martín Ferrari (Tincho)
Bug#798329: ifconfig: changed output format breaks scripts
On Tue, 8 Sep 2015, Martín Ferrari wrote: > Finally, I have no intentions on maintaining a fork of net-tools to > support the 14 years old output format of ifconfig, so I am closing this > as wontfix. Hmpf. I’ll search for scripts using either ip or ifconfig and do some hackery to work with either output format then. Will the current format at least stay? //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Bug#798329: ifconfig: changed output format breaks scripts
On 08/09/15 13:44, Thorsten Glaser wrote: > Will the current format at least stay? Honestly, I don't know upstream plans, but I don't foresee many more changes. If I read the git logs correctly, this change dates back to 2003, and the latest upload is just catching up with 14 years of upstream development with no releases. -- Martín Ferrari (Tincho)