net-misc/netifrc tries to check version of pppd in pppd.sh This uses a grep for things with numbers and dots in them, but if there are any pppd plugins installed then these also appear to get reported in the same output I posted a patch here: https://github.com/gentoo/netifrc/pull/33 Patch is: --- a/net/pppd.sh 2020-06-22 13:28:07.256697786 +0000 +++ b/net/pppd.sh 2020-06-22 13:29:21.563886935 +0000 @@ -23,7 +23,7 @@ pppd_is_ge_248() { - local ver_str="$(/usr/sbin/pppd --version 2>&1 | grep -o '[[:digit:]\.]\+')" + local ver_str="$(/usr/sbin/pppd --version 2>&1 | grep 'pppd version' | grep -o '[[:digit:]\.]\+')" local maj_ver="$(echo ${ver_str} | cut -d . -f 1)" local min_ver="$(echo ${ver_str} | cut -d . -f 2)" local patch_ver="$(echo ${ver_str} | cut -d . -f 3)" However, on closer inspection I can see that the plugin output is sent as part of stdout and the version string goes to stderr So an alternative grep line could be: local ver_str="$(/usr/sbin/pppd --version 2>&1 >/dev/null | grep -o '[[:digit:]\.]\+')" I'm not sure which is most robust on the various platforms we support? For me the output of $ /usr/sbin/pppd --version Plugin tpb_idletimer.so loaded. plugin_init pppd version 2.4.8 Which after the original grep would give: $ /usr/sbin/pppd --version 2>&1 | grep -o '[[:digit:]\.]\+' . . 2.4.8 Which obviously fails to parse as expected in pppd.sh Reproducible: Always
It shouldn't be using \+ to begin with because that's a nasty GNUism. Either \{1,\} can be used or the -E option can be specified to request the ERE (extended) dialect, in which case + is acceptable. Not only that but [[:digit:]] is locale-sensitive; one should just use [0-9] instead. The entire routine could be written more cleanly, I think. I shall propose a new patch shortly.
(In reply to Kerin Millar from comment #1) > It shouldn't be using \+ to begin with because that's a nasty GNUism. Either > \{1,\} can be used or the -E option can be specified to request the ERE > (extended) dialect, in which case + is acceptable. Not only that but > [[:digit:]] is locale-sensitive; one should just use [0-9] instead. The > entire routine could be written more cleanly, I think. I shall propose a new > patch shortly. I already have a better patch available which is using awk instead of grep
(In reply to Lars Wendler (Polynomial-C) from comment #2) > (In reply to Kerin Millar from comment #1) > > It shouldn't be using \+ to begin with because that's a nasty GNUism. Either > > \{1,\} can be used or the -E option can be specified to request the ERE > > (extended) dialect, in which case + is acceptable. Not only that but > > [[:digit:]] is locale-sensitive; one should just use [0-9] instead. The > > entire routine could be written more cleanly, I think. I shall propose a new > > patch shortly. > > I already have a better patch available which is using awk instead of grep Alright.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e08ad3fd1aa2fca27ddf0ad7dfeedb82db4a3666 commit e08ad3fd1aa2fca27ddf0ad7dfeedb82db4a3666 Author: Lars Wendler <polynomial-c@gentoo.org> AuthorDate: 2021-01-18 11:44:10 +0000 Commit: Lars Wendler <polynomial-c@gentoo.org> CommitDate: 2021-01-18 12:32:31 +0000 net/pppd.sh: Improved pppd version check Ed Wildgoose reported an issue with pppd version check if plugins are also to be initialized. I this case "pppd --version" also reports the plugins and that can confuse our original version check. Bug: https://bugs.gentoo.org/729920 Thanks-to: Ed Wildgoose <ed+git@wildgooses.com> Closes: https://github.com/gentoo/netifrc/pull/33 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> net/pppd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=72b3a820214fc50d50b8ac0f031491106d8d8634 commit 72b3a820214fc50d50b8ac0f031491106d8d8634 Author: Lars Wendler <polynomial-c@gentoo.org> AuthorDate: 2021-01-18 13:01:54 +0000 Commit: Lars Wendler <polynomial-c@gentoo.org> CommitDate: 2021-01-18 13:01:54 +0000 net/pppd.sh: Completely overhauled pppd version check Thanks-to: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/729920 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> net/pppd.sh | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
Nice solution!
Thanks for that. I confirm this works as expected in my environment (with plugins and under busybox). Much neater solution than my silly suggestion. Thanks!