commit:     0ac293faa15b49f08830120e7b5fa1e4523f19e5
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun May 28 20:07:47 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun May 28 22:49:02 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0ac293fa

Update pidfile path for ppp-2.5.0

Bug: https://bugs.gentoo.org/907311
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 net/pppd.sh | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 22644f2..1b14fed 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2005-2007 Gentoo Foundation
+# Copyright (c) 2005-2023 Gentoo Authors
 # Copyright (c) 2007-2008 Roy Marples <[email protected]>
 # Released under the 2-clause BSD license.
 # shellcheck shell=sh disable=SC1008
@@ -21,12 +21,28 @@ requote()
        printf "'%s' " "$@"
 }
 
+pppd_version_int() {
+       # 002004008 is v2.4.8
+       printf '%03d' $(/usr/sbin/pppd --version | awk '/pppd version/ {print 
$3}' | tr '.' ' ')
+}
+
 pppd_is_ge_248()
 {
-       local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ 
{print $3}' | tr '.' ' ')"
+       [ $(pppd_version_int) -ge 002004008 ]
+}
 
-       # 002004008 is v2.4.8
-       [ "$(printf '%03d' ${ver_str})" -ge 002004008 ]
+pppd_is_ge_250()
+{
+       [ $(pppd_version_int) -ge 002005000 ]
+}
+
+pppd_pidfile()
+{
+       if pppd_is_ge_250; then
+               echo "/run/pppd/ppp-${IFACE}.pid"
+       else
+               echo "/run/ppp-${IFACE}.pid"
+       fi
 }
 
 pppd_pre_start()
@@ -207,16 +223,18 @@ pppd_pre_start()
        fi
        [ "${insert_link_in_opts}" = "0" ] || opts="${link} ${opts}"
 
+       local pidfile="$(pppd_pidfile)"
+
        ebegin "Starting pppd in ${IFACE}"
        mark_service_inactive
        if [ -n "${username}" ] \
        && [ -n "${password}" -o -z "${passwordset}" ]; then
                printf "%s" "${password}" | \
                eval start-stop-daemon --start --exec /usr/sbin/pppd \
-                       --pidfile "/run/ppp-${IFACE}.pid" -- "${opts}" 
>/dev/null
+                       --pidfile "${pidfile}" -- "${opts}" >/dev/null
        else
                eval start-stop-daemon --start --exec /usr/sbin/pppd \
-                       --pidfile "/run/ppp-${IFACE}.pid" -- "${opts}" 
>/dev/null
+                       --pidfile "${pidfile}" -- "${opts}" >/dev/null
        fi
 
        if ! eend $? "Failed to start PPP"; then
@@ -243,9 +261,13 @@ pppd_start()
 pppd_stop()
 {
        yesno ${IN_BACKGROUND} && return 0
-       local pidfile="/run/ppp-${IFACE}.pid"
 
-       [ ! -s "${pidfile}" ] && return 0
+       local pidfile="$(pppd_pidfile)"
+       if [ ! -s "${pidfile}" ]; then
+               # Try the old path.
+               pidfile="/run/ppp-${IFACE}.pid"
+               [ -s "${pidfile}" ] || return 0
+       fi
 
        # Give pppd at least 30 seconds do die, #147490
        einfo "Stopping pppd on ${IFACE}"

Reply via email to