Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 729920 - net-misc/netifrc - net/pppd.sh: pppd version check fails when pppd is configured to load modules
Summary: net-misc/netifrc - net/pppd.sh: pppd version check fails when pppd is configu...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: netifrc Team
URL:
Whiteboard:
Keywords: PATCH, PullRequest
Depends on:
Blocks:
 
Reported: 2020-06-27 16:09 UTC by Ed Wildgoose
Modified: 2023-05-29 00:33 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Wildgoose 2020-06-27 16:09:25 UTC
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
Comment 1 kfm 2021-01-18 12:12:54 UTC
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.
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2021-01-18 12:20:26 UTC
(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
Comment 3 kfm 2021-01-18 12:32:47 UTC
(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.
Comment 4 Larry the Git Cow gentoo-dev 2021-01-18 12:33:34 UTC
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(-)
Comment 5 Larry the Git Cow gentoo-dev 2021-01-18 13:04:17 UTC
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(-)
Comment 6 kfm 2021-01-18 13:15:30 UTC
Nice solution!
Comment 7 Ed Wildgoose 2021-01-18 17:57:10 UTC
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!