[gentoo-commits] proj/netifrc:master commit in: init.d/, net/

2024-05-23 Thread Patrick McLean
commit: 7c6a8de0c521ea474bccb0dbda4338ff293cdfc6
Author: Alexander Zubkov  qrator  net>
AuthorDate: Fri May 10 21:38:02 2024 +
Commit: Patrick McLean  gentoo  org>
CommitDate: Thu May 23 16:12:29 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7c6a8de0

Allow setting blackhole-like routes

There were several problems preventing usage of routes of types
blackhole, prohibit, throw, unreachable in IFACE_routes variables:

- Those route types do not allow to use dev in the route definition,
  but it was added unconditionally

- As there is no dev, such routes are not flushed automatically by dev,
  they need to be remembered and deleted while stopping the interface

- Route type must go before the prefix in the command, but first
  parameters have special meaning

Signed-off-by: Alexander Zubkov  qrator.net>
Closes: https://bugs.gentoo.org/637394
Closes: https://github.com/gentoo/netifrc/pull/53
X-Gentoo-Bug: 637394
X-Gentoo-Bug-URL: https://bugs.gentoo.org/637394
Signed-off-by: Patrick McLean  gentoo.org>

 init.d/net.lo.in | 13 ++---
 net/iproute2.sh  | 48 +---
 2 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index afba99f..dbacaa2 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -780,9 +780,11 @@ ${routes}"
fi
fi
 
+   service_set_value "nodev_routes" ""
+
local OIFS="${IFS}" SIFS="${IFS-y}"
local IFS="$__IFS"
-   local fam
+   local cmd_head fam
for cmd in ${routes}; do
unset IFS
if ${first}; then
@@ -795,8 +797,13 @@ ${routes}"
-4" "*) fam="-4"; cmd=${cmd#-4 };;
esac
 
+   cmd_head=
+   case ${cmd%% *} in
+   blackhole|prohibit|throw|unreachable) 
cmd_head="${cmd_head} ${cmd%% *}"; cmd=${cmd#* };;
+   esac
+
eindent
-   ebegin ${cmd}
+   ebegin ${cmd_head} ${cmd}
# Work out if we're a host or a net if not told
case ${cmd} in
-net\ *|-host\ *);;
@@ -808,7 +815,7 @@ ${routes}"
*:*/*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
-   _add_route ${fam} ${cmd}
+   _add_route ${fam} ${cmd_head} ${cmd}
eend $?
eoutdent
done

diff --git a/net/iproute2.sh b/net/iproute2.sh
index ea0a6f7..7db7f5b 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -253,6 +253,14 @@ _add_route()
shift
fi
 
+   local rtype=
+
+   # Check if route type is provided that does not allow to use dev
+   # Route type must come first, before the prefix, also it cannot be used 
to list routes
+   case "$1" in
+   blackhole|prohibit|throw|unreachable) rtype="$1" ; shift ;;
+   esac
+
if [ $# -eq 3 ]; then
set -- "$1" "$2" via "$3"
elif [ "$3" = "gw" ]; then
@@ -280,13 +288,25 @@ _add_route()
cmd="${cmd} metric ${metric}"
fi
 
+   # Process dev vs nodev routes
+   # Positional parameters are used for correct array handling
+   if [[ -n ${rtype} ]]; then
+   local nodev_routes="$(service_get_value "nodev_routes")"
+   service_set_value "nodev_routes" "${nodev_routes}
+${family} route del ${rtype} ${cmd}"
+   set --
+   else
+   set -- dev "${IFACE}"
+   fi
+
# Check for route already existing:
-   _ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \
+   _ip ${family} route show ${cmd_nometric} "$@" 2>/dev/null | \
grep -Fsq "${cmd%% *}"
route_already_exists=$?
 
-   _ip -v ${family} route append ${cmd} dev "${IFACE}"
+   _ip -v ${family} route append ${rtype} ${cmd} "$@"
rc=$?
+
# Check return code in some cases
if [ $rc -ne 0 ]; then
# If the route already exists, our default behavior is to WARN 
but continue.
@@ -301,7 +321,7 @@ _add_route()
*) msgfunc=eerror rc=1 ; eerror "Unknown error 
behavior: $eh_behavior" ;;
esac
eval $msgfunc "Route '$cmd_nometric' already existed:"
-   eval $msgfunc \"$(_ip $family route show 
${cmd_nometric} dev "${IFACE}" 2>&1)\"
+   eval $msgfunc \"$(_ip $family route show 
${cmd_nometric} \"$@\" 2>&1)\"
else
: # TODO: Handle other errors
fi
@@ -342,6 +362,7 @@ _trim() {
 # This allows for advanced routing tricks
 _ip_rule_runner() {
local cmd rules OIFS="${IFS}" family
+   local ru ruN
if [ "$1" = "-4" -o "$1" = "-6" 

[gentoo-commits] proj/netifrc:master commit in: init.d/

2024-01-07 Thread Sam James
commit: 6b54da4cc0b85aaed4e4546bbb0893476fb6835c
Author: Matoro Mahri  matoro  tk>
AuthorDate: Wed Jan  3 15:37:03 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan  7 09:42:33 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6b54da4c

net.lo.in: replace "type" bashism with "command"

Closes: https://bugs.gentoo.org/844178
Signed-off-by: Matoro Mahri  matoro.tk>
Closes: https://github.com/gentoo/netifrc/pull/50
Signed-off-by: Sam James  gentoo.org>

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 0bb69f3..afba99f 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -902,7 +902,7 @@ stop()
yesno ${module} && _down 2>/dev/null
fi
 
-   type resolvconf >/dev/null 2>&1 && resolvconf -d "${IFACE}" 2>/dev/null
+   command -v resolvconf >/dev/null && resolvconf -d "${IFACE}" 2>/dev/null
 
if [ "$(command -v "postdown")" = "postdown" ]; then
ebegin "Running postdown"



[gentoo-commits] proj/netifrc:master commit in: init.d/

2021-03-30 Thread Patrick McLean
commit: bef5edf9d2d1fcd982ae19a7cb05dc2d58b854e7
Author: Patrick McLean  gentoo  org>
AuthorDate: Wed Mar 31 01:06:31 2021 +
Commit: Patrick McLean  gentoo  org>
CommitDate: Wed Mar 31 01:10:48 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bef5edf9

net.lo.in: quote variables in _configure_variables

The variables being passed to eval aren't quoted either in the before-eval
scope, or in what is passed to eval. Make sure they are quoted.

Signed-off-by: Patrick McLean  gentoo.org>

 init.d/net.lo.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 06304e1..0bb69f3 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -225,9 +225,9 @@ _configure_variables()
for var in ${_config_vars}; do
local v=
for t; do
-   eval v=\$${var}_${t}
+   eval v="\"\$${var}_${t}\""
if [ -n "${v}" ]; then
-   eval ${var}_${IFVAR}=\$${var}_${t}
+   eval "${var}_${IFVAR}=\"\$${var}_${t}\""
continue 2
fi
done



[gentoo-commits] proj/netifrc:master commit in: init.d/

2020-09-07 Thread Lars Wendler
commit: 26aa22cc703d5ec0da2d78f042ad3bb9c42afb6a
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Sep  7 08:55:10 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Sep  7 13:02:58 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=26aa22cc

init.d/net.lo.in: Add missing closing function bracket

Bug introdcued with commit d3b5d78c5f3696aaf841d7900e69a37de29cfc25

Signed-off-by: Lars Wendler  gentoo.org>

 init.d/net.lo.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 3ab83b2..fb55788 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -295,6 +295,7 @@ _get_errorhandler_behavior() {
echo "$value" && break
fi
done
+}
 
 _show_address6()
 {



[gentoo-commits] proj/netifrc:master commit in: init.d/, doc/, net/

2020-06-02 Thread Robin H. Johnson
commit: d3b5d78c5f3696aaf841d7900e69a37de29cfc25
Author: Daniel Solano Gómez  solanogomez  org>
AuthorDate: Sat Apr  6 00:13:12 2013 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jun  2 21:24:24 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d3b5d78c

dhclientv6: Add DHCPv6 support via dhclient

This adds DHCPv6 support to OpenRC in Linux using dhclient as outlined
by Stuart Longland at 
.
The main place where the new support is added is via a modified copy of
the dhclient.sh script that:

- Renames functions using a 'v6' suffix
- Uses a different pid file
- Uses the '-6' argument when invoking dhclient
- Recognizes new DHCPv6-specific configuration variables with a fallback
  to the DHCP configuration variables.

Additionally:

1. The iproute2 and Linux ifconfig scripts have been ammended to be able
to return IPv6 addresses using new '_get_inet6_address' and
'_get_inet6_addresses' functions.

2. The 'net.lo' init script now has a '_show_address6' function.

3. The documentation in the Linux net.example now contains some DHCPv6
information.

Reported-by: Dustin C. Hatch  gmail.com>
X-Gentoo-Bug: 150908
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=150908
Signed-off-by: Robin H. Johnson  gentoo.org>
(cherry picked from commit bd7bd3a513c8ddc554e211316c990b5f98110982)
Closes: https://bugs.gentoo.org/450326
Signed-off-by: Robin H. Johnson  gentoo.org>

 doc/net.example.Linux.in | 35 +
 init.d/net.lo.in |  4 +++
 net/Makefile |  2 +-
 net/dhclientv6.sh| 82 
 net/ifconfig.sh.Linux.in | 26 +--
 net/iproute2.sh  | 19 +--
 6 files changed, 162 insertions(+), 6 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index a2993c0..53d9e84 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -518,6 +518,41 @@
 # You can use any combination of the above options - the default is not to
 # use any of them.
 
+#-
+# DHCPv6
+# DHCPv6 can be provided by dhclient
+#
+# dhclient: emerge net-misc/dhcp
+#
+# If you have more than one DHCP client installed, you should probably
+# explicitly use 'dhclient' to use dhclient for both DHCP and DHCPv6,
+# otherwise the default DHCP client will be used.  dhcpcd has some stateless
+# IPv6 autoconfiguration support which may clash with DHCPv6.
+#modules="dhclient" # to select dhclient over dhcpcd
+
+# Regardless of which DHCP client you prefer, you configure them the
+# same way using one of following depending on which interface modules
+# you're using.
+#config_eth0="dhcpv6"
+
+# You can also use both DHCP and DHCPv6 on a dual-stack network:
+#config_eth0="dhcp
+#dhcpv6"
+
+# To pass runtime arguments to dhclient for DHCPv6, you do it similarly to
+# setting runtime arguments for DHCP.  Note that you can set options for
+# DHCPv6 separately or in addition the dhclient arguments for DHCP.
+#dhclientv6_eth0="..." # options for DHCPv6 only
+#dhclient_eth0='..."   # options for DHCP (also for DHCPv6 when no
+#  # dhclientv6_eth0 is defined)
+
+# GENERIC DHCPv6 OPTIONS
+# Set generic DHCPv6 options just as with generic DHCP options.
+#dhcpv6_eth0="release nodns nontp nonis nogateway nosendhost"
+
+# If no generic DHCPv6 options are set, the default is to fall back to the
+# DHCP generic options.
+
 #-
 # For APIPA support, emerge net-misc/iputils or net-analyzer/arping
 

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index a5ac0fe..3ab83b2 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -295,6 +295,10 @@ _get_errorhandler_behavior() {
echo "$value" && break
fi
done
+
+_show_address6()
+{
+   einfo "received address $(_get_inet6_address "${IFACE}")"
 }
 
 # Basically sorts our modules into order and saves the list

diff --git a/net/Makefile b/net/Makefile
index dab94f9..ee48294 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -14,7 +14,7 @@ INC-Linux=adsl.sh apipa.sh arping.sh bonding.sh 
br2684ctl.sh bridge.sh \
ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh 
\
ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh 
udhcpc.sh \
vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh 
l2tp.sh \
-   iw.sh wireguard.sh veth.sh
+   iw.sh wireguard.sh veth.sh dhclientv6.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=ifwatchd.sh

diff --git a/net/dhclientv6.sh b/net/dhclientv6.sh
new file mode 100644
index 000..f87ed4d
--- /dev/null
+++ b/net/dhclientv6.sh
@@ -0,0 +1,82 @@
+# Copyright (c) 2007-2008 Roy Marples 
+# Released under the 2-clause BSD license.
+

[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: 5c989bfbac65b9f56c9a73c3380d8a735913cdf1
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:22:32 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:32:27 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=5c989bfb

init.d/net.lo.in: shellcheck: arrays

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index e49278f..c53d3ea 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -82,7 +82,7 @@ _array_helper()
 
 _get_array()
 {
-   local _a=
+   local _a=''
if [ -n "${BASH}" ]; then
# shellcheck disable=SC2039
case "$(declare -p "$1" 2>/dev/null)" in
@@ -99,7 +99,7 @@ _get_array()
esac
fi
 
-   _array_helper $1
+   _array_helper "$1"
 }
 
 # Flatten bash arrays to simple strings
@@ -122,7 +122,7 @@ _flatten_array()
esac
fi
 
-   _array_helper $1
+   _array_helper "$1"
 }
 
 _wait_for_presence()



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: bb833bd3afb35960a2faa879220697ea1f596546
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:19:44 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:30:34 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bb833bd3

init.d/net.lo.in: shellcheck: _gen_module_list(), _load_modules()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 3afe046..d9a4d24 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -10,6 +10,7 @@ _config_vars="config metric routes"
 
 [ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO"
 
+# shellcheck disable=SC2034
 description="Configures network interfaces."
 
 # Handy var so we don't have to embed new lines everywhere for array splitting
@@ -20,6 +21,7 @@ __IFS="
 : ${INIT:=openrc}
 
 if [ -f "$SHDIR/functions.sh" ]; then
+   # shellcheck disable=SC1090
. "$SHDIR/functions.sh"
 else
echo "$SHDIR/functions.sh missing. Exiting"
@@ -345,6 +347,7 @@ _gen_module_list()
 
for MODULE in "${MODULESDIR}"/*.sh; do
sh -n "${MODULE}" || continue
+   # shellcheck disable=SC1090
. "${MODULE}" || continue
MODULE=${MODULE#${MODULESDIR}/}
MODULE=${MODULE%.sh}
@@ -414,8 +417,10 @@ _load_modules()
 
# Ensure our list is up to date
_gen_module_list false
+   # shellcheck disable=SC1090
if ! . "${MODULESLIST}"; then
_gen_module_list true
+   # shellcheck disable=SC1090
. "${MODULESLIST}"
fi
 
@@ -461,6 +466,7 @@ _load_modules()
MODULES="${MODULES}${MODULES:+ }${mod}"
 
# Now load and wrap our functions
+   # shellcheck disable=SC1090
if ! . "${MODULESDIR}/${mod}.sh"; then
eend 1 "${RC_SVCNAME}: error loading module \`${mod}'"
exit 1



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: b7e61844bd3d66f61ce9967df78a5d30f3be8d00
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:28:33 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:44 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b7e61844

init.d/net.lo.in: shellcheck: stop()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 9ba2e03..a5ac0fe 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -830,14 +830,16 @@ stop()
# correctly if we go back to multiuser.
yesno ${keep_network:-YES} && yesno $RC_GOINGDOWN && return 0
 
-   local IFACE=$(get_interface) module=
-   local IFVAR=$(shell_var "${IFACE}") opts=
+   local IFACE='' module=''
+   local IFVAR=''
+   IFACE=$(get_interface)
+   IFVAR=$(shell_var "${IFACE}")
 
einfo "Bringing down interface ${IFACE}"
eindent
 
if [ -z "${MODULES}" ]; then
-   local MODULES=
+   local MODULES=''
_load_modules false
fi
 
@@ -883,7 +885,7 @@ stop()
# If not in background, and not loopback then bring the interface down
# unless overridden.
if ! yesno ${IN_BACKGROUND} && \
-   [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
+   [ "${IFACE}" != "lo" ] && [ "${IFACE}" != "lo0" ]; then
eval module=\$ifdown_${IFVAR}
module=${module:-${ifdown:-YES}}
yesno ${module} && _down 2>/dev/null



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: d2d52cd821372c65b92d262da66a30794735204c
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:21:51 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:31:06 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d2d52cd8

init.d/net.lo.in: shellcheck: disable some false positives

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index d9a4d24..1e5de3c 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -83,6 +83,7 @@ _get_array()
 {
local _a=
if [ -n "${BASH}" ]; then
+   # shellcheck disable=SC2039
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
ewarn "You are using a bash array for $1."
@@ -104,6 +105,7 @@ _get_array()
 _flatten_array()
 {
if [ -n "${BASH}" ]; then
+   # shellcheck disable=SC2039
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
ewarn "You are using a bash array for $1."
@@ -111,6 +113,7 @@ _flatten_array()
ewarn "Please see net.example for the correct 
format for $1."
eval "set -- \"\${$1[@]}\""
for x; do
+   # shellcheck disable=SC2059
printf "'%s' " "$(printf "$x" | sed 
"s:':'\\\'':g")"
done
return 0
@@ -194,6 +197,7 @@ _netmask2cidr()
quad=${quad}${quad:+.}0x${hex%${lastbut2}*}
hex=${lastbut2}
done
+   # shellcheck disable=SC2086
set -- ${quad}
;;
esac
@@ -427,6 +431,7 @@ _load_modules()
MODULES=
if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
eval mymods=\$modules_${IFVAR}
+   # shellcheck disable=SC2154
[ -z "${mymods}" ] && mymods=${modules}
fi
 
@@ -627,6 +632,7 @@ start()
local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
local metric=0 _up_before_preup
eval _up_before_preup="\$up_before_preup_${IFVAR}"
+   # shellcheck disable=SC2154
[ -z "${_up_before_preup}" ] && _up_before_preup=$up_before_preup
 
einfo "Bringing up interface ${IFACE}"



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: abcc0bd4c372e36cc6e5e46832e7664a72b6bcaa
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:22:09 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:32:11 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=abcc0bd4

init.d/net.lo.in: shellcheck: depend()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 6d6b581..e49278f 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -34,10 +34,11 @@ MODULESLIST="${RC_SVCDIR}/nettree$(get_interface)"
 
 depend()
 {
-   local IFACE=$(get_interface)
-   local IFVAR=$(shell_var "${IFACE}")
+   local IFACE IFVAR
+   IFACE=$(get_interface)
+   IFVAR=$(shell_var "${IFACE}")
 
-   if [ "$RC_UNAME" = Linux -a "$IFACE" != lo ]; then
+   if [ "$RC_UNAME" = Linux ] && [ "$IFACE" != lo ]; then
need sysfs
after modules
fi
@@ -54,14 +55,14 @@ depend()
esac
 
if [ "$(command -v "depend_${IFVAR}")" = "depend_${IFVAR}" ]; then
-   depend_${IFVAR}
+   "depend_${IFVAR}"
fi
 
-   local dep= prov=
+   local dep prov
for dep in need use before after provide keyword; do
eval prov=\$rc_${dep}_${IFVAR}
if [ -n "${prov}" ]; then
-   ${dep} ${prov}
+   "${dep}" "${prov}"
ewarn "rc_${dep}_${IFVAR} is deprecated."
ewarn "Please use rc_net_${IFVAR}_${dep} instead."
fi



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: b9b82d586cf03766f568b91156837d1b7861fb09
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:22:44 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:10 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b9b82d58

init.d/net.lo.in: shellcheck: _which()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 2999a96..77f0d8f 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -243,7 +243,7 @@ _which()
OIFS="$IFS"
IFS=:
for i in $PATH ; do
-   [ -x $i/$1 ] && echo $i/$1 && break
+   [ -x "$i/$1" ] && echo "$i/$1" && break
done
IFS=$OIFS
 }



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: 1ae3f8e257032e753713b6582e23121984c0f9fa
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:28:15 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:40 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1ae3f8e2

init.d/net.lo.in: shellcheck: start()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index e1a0cab..9ba2e03 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -632,9 +632,17 @@ is_interface_type()
 
 start()
 {
-   local IFACE=$(get_interface) oneworked=false fallback=false module=
-   local IFVAR=$(shell_var "${IFACE}") cmd= our_metric=
-   local metric=0 _up_before_preup
+   local IFACE=''
+   local IFVAR=''
+   local oneworked=false
+   local fallback=false
+   local module=''
+   local cmd=''
+   local our_metric=''
+   local metric=0
+   local _up_before_preup=''
+   IFACE=$(get_interface)
+   IFVAR=$(shell_var "${IFACE}")
eval _up_before_preup="\$up_before_preup_${IFVAR}"
# shellcheck disable=SC2154
[ -z "${_up_before_preup}" ] && _up_before_preup=$up_before_preup
@@ -682,14 +690,14 @@ start()
return 1
fi
 
-   local config= config_index=
+   local config='' config_index=''
_load_config
config_index=0
 
eval our_metric=\$metric_${IFVAR}
if [ -n "${our_metric}" ]; then
metric=${our_metric}
-   elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
+   elif [ "${IFACE}" != "lo" ] && [ "${IFACE}" != "lo0" ]; then
: $(( metric += $(_ifindex) ))
fi
 
@@ -698,7 +706,7 @@ start()
[ -z "${config}" ] && break
 
set -- ${config}
-   if [ "$1" != "null" -a "$1" != "noop" ]; then
+   if [ "$1" != "null" ] && [ "$1" != "noop" ]; then
ebegin "$1"
fi
eindent
@@ -754,7 +762,7 @@ start()
if [ -z "${routes}" ]; then
routes="$(_get_array "routes_${IFVAR}")"
fi
-   if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
+   if [ "${IFACE}" = "lo" ] || [ "${IFACE}" = "lo0" ]; then
if [ "${config_0}" != "null" ]; then
routes="127.0.0.0/8 via 127.0.0.1
 ${routes}"
@@ -780,11 +788,11 @@ ${routes}"
ebegin ${cmd}
# Work out if we're a host or a net if not told
case ${cmd} in
-   -net" "*|-host" "*);;
-   *" "netmask" "*)   cmd="-net ${cmd}";;
+   -net\ *|-host\ *);;
+   *\ netmask\ *) cmd="-net ${cmd}";;
*.*.*.*/32*)   cmd="-host ${cmd}";;
-   *.*.*.*/*|0.0.0.0|0.0.0.0" "*) cmd="-net ${cmd}";;
-   default|default" "*)   cmd="-net ${cmd}";;
+   *.*.*.*/*|0.0.0.0|0.0.0.0\ *) cmd="-net ${cmd}";;
+   default|default\ *)   cmd="-net ${cmd}";;
*:*/128*)  cmd="-host ${cmd}";;
*:*/*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: c88734624727231da02a3f610c9af0fda70fc1d0
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:23:22 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:35 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c8873462

init.d/net.lo.in: shellcheck: PROVIDEDBY MODULE trample

This is a logic error caught by shellcheck. The nested loops used the
same index variable, so the outer loop progress could get trampled.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 961d9fa..a958598 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -369,14 +369,14 @@ _gen_module_list()
VISITED="${VISITED} $1"
 
eval AFTER=\$${1}_after
-   for MODULE in ${AFTER}; do
-   eval PROVIDEDBY=\$${MODULE}_providedby
+   for MODULE1 in ${AFTER}; do
+   eval PROVIDEDBY=\$${MODULE1}_providedby
if [ -n "${PROVIDEDBY}" ]; then
-   for MODULE in ${PROVIDEDBY}; do
-   visit "${MODULE}"
+   for MODULE2 in ${PROVIDEDBY}; do
+   visit "${MODULE2}"
done
else
-   visit "${MODULE}"
+   visit "${MODULE1}"
fi
done
 



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: b8ea3b8f78cb91cd48661ba81f3e261c5ff12f44
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:25:29 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:36 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b8ea3b8f

init.d/net.lo.in: shellcheck: _load_config

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index c8af39f..30ab7fd 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -530,8 +530,9 @@ _load_modules()
 
 _load_config()
 {
-   local config="$(_get_array "config_${IFVAR}")"
-   local fallback="$(_get_array fallback_${IFVAR})"
+   local config='' fallback=''
+   config="$(_get_array "config_${IFVAR}")"
+   fallback="$(_get_array fallback_${IFVAR})"
 
config_index=0
local IFS="$__IFS"
@@ -545,7 +546,7 @@ _load_config()
# Of course, we may have a single address added old style.
# If the NEXT argument is a v4 or v6 address, it's the next 
config.
# Otherwise, it's arguments to the first config...
-   if [ "${2#*.*}" = "${2}" -a "${2#*:*}" = "${2}" ]; then
+   if [ "${2#*.*}" = "${2}" ] && [  "${2#*:*}" = "${2}" ]; then
# Not an IPv4/IPv6
local IFS="$__IFS"
set -- ${config}
@@ -553,7 +554,7 @@ _load_config()
fi
 
# Ensure that loopback has the correct address
-   if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ]; then
+   if [ "${IFACE}" = "lo" ] || [ "${IFACE}" = "lo0" ]; then
if [ "$1" != "null" ]; then
config_0="127.0.0.1/8"
config_index=1



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: ad3e0e73f5f9fbc8481dbee4f77fa8001ca78844
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:23:19 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:27 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ad3e0e73

init.d/net.lo.in: shellcheck: _gen_module_list()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 77f0d8f..961d9fa 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -300,11 +300,11 @@ _get_errorhandler_behavior() {
 # Basically sorts our modules into order and saves the list
 _gen_module_list()
 {
-   local x= f= force=$1
+   local x='' f='' force="$1"
if ! ${force} ; then
-   if [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt 
/proc/$$/status ]; then
+   if [ -s "${MODULESLIST}" ] && [ "${MODULESLIST}" -nt 
/proc/$$/status ]; then
ewarn "Discarding cached module list ($MODULESLIST) as 
it's newer current time!"
-   elif [ -s "${MODULESLIST}" -a "${MODULESLIST}" -nt 
"${MODULESDIR}" ]; then
+   elif [ -s "${MODULESLIST}" ] && [ "${MODULESLIST}" -nt 
"${MODULESDIR}" ]; then
local update=false
for x in "${MODULESDIR}"/*.sh; do
[ -e "${x}" ] || continue
@@ -333,7 +333,7 @@ _gen_module_list()
}
 
program() {
-   if [ "$1" = "start" -o "$1" = "stop" ]; then
+   if [ "$1" = "start" ] || [ "$1" = "stop" ]; then
local s="$1"
shift
eval 
${MODULE}_program_${s}="\"\${${MODULE}_program_${s}}\${${MODULE}_program_${s}:+ 
}$*\""
@@ -345,7 +345,7 @@ _gen_module_list()
provide() {
eval 
${MODULE}_provide="\"\${${MODULE}_provide}\${${MODULE}_provide:+ }$*\""
local x
-   for x in $*; do
+   for x in "$@"; do
eval 
${x}_providedby="\"\${${MODULE}_providedby}\${${MODULE}_providedby:+ 
}${MODULE}\""
done
}
@@ -356,7 +356,7 @@ _gen_module_list()
. "${MODULE}" || continue
MODULE=${MODULE#${MODULESDIR}/}
MODULE=${MODULE%.sh}
-   eval ${MODULE}_depend
+   eval "${MODULE}_depend"
MODULES="${MODULES} ${MODULE}"
done
 
@@ -402,13 +402,13 @@ _gen_module_list()
eval PROGRAM_START=\$${MODULE}_program_start
eval PROGRAM_STOP=\$${MODULE}_program_stop
eval PROVIDE=\$${MODULE}_provide
-   echo "module_${i}='${MODULE}'" >> "${TMPMODULESLIST}"
-   echo "module_${i}_program='${PROGRAM}'" >> "${TMPMODULESLIST}"
-   echo "module_${i}_program_start='${PROGRAM_START}'" >> 
"${TMPMODULESLIST}"
-   echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> 
"${TMPMODULESLIST}"
-   echo "module_${i}_provide='${PROVIDE}'" >> "${TMPMODULESLIST}"
+   echo "module_${i}='${MODULE}'"
+   echo "module_${i}_program='${PROGRAM}'"
+   echo "module_${i}_program_start='${PROGRAM_START}'"
+   echo "module_${i}_program_stop='${PROGRAM_STOP}'"
+   echo "module_${i}_provide='${PROVIDE}'"
: $(( i += 1 ))
-   done
+   done >> "${TMPMODULESLIST}"
echo "module_${i}=" >> "${TMPMODULESLIST}"
mv -f "${TMPMODULESLIST}" "${MODULESLIST}"
)



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: d3780ab87ea78da725012deda8a2e866b6276603
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:21:59 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:31:46 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d3780ab8

init.d/net.lo.in: shellcheck: toplevel INIT variable

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 1e5de3c..6d6b581 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -18,7 +18,7 @@ __IFS="
 "
 
 #  Set the INIT to be openrc if this file is called directly
-: ${INIT:=openrc}
+: "${INIT:=openrc}"
 
 if [ -f "$SHDIR/functions.sh" ]; then
# shellcheck disable=SC1090



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: a7e4efa284da47d89bd05f8a328b8a7b5edd2ad6
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:22:41 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:32:43 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a7e4efa2

init.d/net.lo.in: shellcheck: quick initial variable values

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index c53d3ea..2999a96 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -203,7 +203,7 @@ _netmask2cidr()
;;
esac
 
-   local i= len=
+   local i='' len=''
local IFS=.
for i in $1; do
case $i in
@@ -220,7 +220,7 @@ _netmask2cidr()
 
 _configure_variables()
 {
-   local var= v= t=
+   local var='' v='' t=''
 
for var in ${_config_vars}; do
local v=



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: 5df0a442c2d33f80317d91ec3ce1933aa70acc52
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:27:33 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:36 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=5df0a442

init.d/net.lo.in: shellcheck: _run_if()

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 30ab7fd..e1a0cab 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -594,7 +594,7 @@ _run_if()
 {
local cmd=$1 iface=$2 ifr=${IFACE} ifv=${IFVAR}
# Ensure that we don't stamp on real values
-   local IFACE= IFVAR=
+   local IFACE='' IFVAR=''
shift
if [ -n "${iface}" ]; then
IFACE="${iface}"



[gentoo-commits] proj/netifrc:master commit in: init.d/

2019-04-20 Thread Robin H. Johnson
commit: c78662eeafaf5f9254f62ae1f40f7c058180af8a
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:24:46 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:33:35 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c78662ee

init.d/net.lo.in: shellcheck: _load_modules

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index a958598..c8af39f 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -430,13 +430,13 @@ _load_modules()
fi
 
MODULES=
-   if [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
+   if [ "${IFACE}" != "lo" ] && [ "${IFACE}" != "lo0" ]; then
eval mymods=\$modules_${IFVAR}
# shellcheck disable=SC2154
[ -z "${mymods}" ] && mymods=${modules}
fi
 
-   local i=-1 x= mod= f= provides=
+   local i=-1 x='' mod='' f='' provides=''
while true; do
: $(( i += 1 ))
eval mod=\$module_${i}
@@ -446,7 +446,7 @@ _load_modules()
eval set -- \$module_${i}_program
if [ -n "$1" ]; then
if ! _program_available "$@" >/dev/null; then
-   vewarn "Skipping module $mod due to missing 
program: $@"
+   vewarn "Skipping module $mod due to missing 
program: $*"
continue
fi
fi
@@ -457,7 +457,7 @@ _load_modules()
fi
if [ -n "$1" ]; then
if ! _program_available "$@" >/dev/null; then
-   vewarn "Skipping module $mod due to missing 
program: $@"
+   vewarn "Skipping module $mod due to missing 
program: $*"
continue
fi
fi
@@ -483,7 +483,8 @@ _load_modules()
# Wrap our provides
local f=
for f in pre_start start post_start; do
-   eval "${provides}_${f}() { [ "$(command -v 
"${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
+   inner=$(command -v "${mod}_${f}")
+   eval "${provides}_${f}() { [ '${inner}' = '${mod}_${f}' 
] || return 0; ${mod}_${f} \"\$@\"; }"
done
 
eval module_${mod}_provides="${provides}"
@@ -497,7 +498,8 @@ _load_modules()
eval x=\$module_${mod}_provides
[ -z "${x}" ] && continue
for f in pre_start start post_start; do
-   eval "${x}_${f}() { [ "$(command -v 
"${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
+   inner=$(command -v "${mod}_${f}")
+   eval "${x}_${f}() { [ '${inner}' = 
'${mod}_${f}' ] || return 0; ${mod}_${f} \"\$@\"; }"
done
eval module_${x}_providedby="${mod}"
;;



[gentoo-commits] proj/netifrc:master commit in: init.d/, doc/

2018-07-12 Thread Robin H. Johnson
commit: 6f261f1beec1ecbfe7ec39ae33b5a7f947292f6e
Author: Maciej S. Szmigiero  maciej  szmigiero  name>
AuthorDate: Wed Nov 29 19:49:27 2017 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Thu Jul 12 06:51:03 2018 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6f261f1b

init.d/net.lo: add a configurable presence timeout

Sometimes one may want to wait for a particular interface to show up
when starting its service.
For example if a "net.foo" service is in the "default" runlevel so it
provides (or co-provides) the "net" service and it takes a while for the
"foo" interface to initialize and show up in the system during boot this
interface initialization will race with starting of this "net.foo" service
by the service manager - if the interface hasn't shown up yet the service
won't be able to start (and so will services that depend on it).

This setting specifies how long we'll wait for an interface to show up
in this case (in seconds).
For backward-compatibility the default is 0 (don't wait at all) - this
matches the existing behavior of netifrc, so existing deployments aren't
affected by this change.

This new setting is similar to an already present "wait for carrier
timeout" setting.

Signed-off-by: Maciej S. Szmigiero  maciej.szmigiero.name>
(cherry picked from commit 64f33a2032b4972a25cad6405678f678a5a269ff)
Closes: https://github.com/gentoo/netifrc/pull/28

 doc/net.example.BSD.in   | 16 
 doc/net.example.Linux.in | 16 
 init.d/net.lo.in | 33 -
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.BSD.in b/doc/net.example.BSD.in
index 1df32e0..4c574b4 100644
--- a/doc/net.example.BSD.in
+++ b/doc/net.example.BSD.in
@@ -77,6 +77,22 @@
 # Some users may need to alter the MTU - here's how
 #mtu_eth0="1500"
 
+# Sometimes you may want to wait for a particular interface to show up
+# when starting its service.
+# For example if a net.foo service is in the "default" runlevel so it
+# provides (or co-provides) the "net" service and it takes a while for the
+# "foo" interface to initialize and show up in the system during a boot this
+# will race with starting of net.foo service by the service manager - if the
+# interface hasn't shown up yet the service won't be able start (and so
+# will services that depend on it).
+# This setting specifies how long we wait for an interface to show up
+# in this case (in seconds).
+# The current default is 0 - we need an interface to be already present
+# in the system when its service is started.
+#presence_timeout=0
+# This setting can be also adjusted on a per-interface basis:
+#presence_timeout_eth0=10
+
 # Most drivers that report carrier status function correctly, but some do not
 # One of these faulty drivers is for the Intel e1000 network card, but only
 # at boot time. To get around this you may alter the carrier_timeout value for

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index c0cfd38..3b414ba 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -126,6 +126,22 @@
 # tables you may have to set a global metric as the due to a simple read of
 # the routing table taking over a minute at a time.
 
+# Sometimes you may want to wait for a particular interface to show up
+# when starting its service.
+# For example if a net.foo service is in the "default" runlevel so it
+# provides (or co-provides) the "net" service and it takes a while for the
+# "foo" interface to initialize and show up in the system during a boot this
+# will race with starting of net.foo service by the service manager - if the
+# interface hasn't shown up yet the service won't be able start (and so
+# will services that depend on it).
+# This setting specifies how long we wait for an interface to show up
+# in this case (in seconds).
+# The current default is 0 - we need an interface to be already present
+# in the system when its service is started.
+#presence_timeout=0
+# This setting can be also adjusted on a per-interface basis:
+#presence_timeout_eth0=10
+
 # Most drivers that report carrier status function correctly, but some do not
 # One of these faulty drivers is for the Intel e1000 network card, but only
 # at boot time. To get around this you may alter the carrier_timeout value for

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index b78a342..472ed0c 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -118,6 +118,37 @@ _flatten_array()
_array_helper $1
 }
 
+_wait_for_presence()
+{
+   local timeout=
+   local rc=
+
+   _exists && return 0
+
+   eval timeout=\$presence_timeout_${IFVAR}
+   timeout=${timeout:-${presence_timeout:-0}}
+
+   [ ${timeout} -le 0 ] && return 1
+
+   einfon "Waiting for ${IFACE} to show up (${timeout} seconds)"
+   while [ ${timeout} -gt 0 ]; do
+   _exists
+   rc=$?
+   [ $rc -eq 0 ] && break
+
+

[gentoo-commits] proj/netifrc:master commit in: init.d/

2017-11-14 Thread Robin H. Johnson
commit: 66dc589e7478dc380c038c29073d8e438d80ed93
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Nov 14 19:14:12 2017 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Nov 14 19:14:12 2017 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=66dc589e

init.d/net.lo: atomically create moduleslist.

Bug: https://bugs.gentoo.org/637474
Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 33cc932..b78a342 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -353,21 +353,24 @@ _gen_module_list()
visit "${MODULE}"
done
 
-   printf "" > "${MODULESLIST}"
+   # Create atomically
+   TMPMODULESLIST=${MODULESLIST}.$$
+   printf "" > "${TMPMODULESLIST}"
i=0
for MODULE in ${SORTED}; do
eval PROGRAM=\$${MODULE}_program
eval PROGRAM_START=\$${MODULE}_program_start
eval PROGRAM_STOP=\$${MODULE}_program_stop
eval PROVIDE=\$${MODULE}_provide
-   echo "module_${i}='${MODULE}'" >> "${MODULESLIST}"
-   echo "module_${i}_program='${PROGRAM}'" >> "${MODULESLIST}"
-   echo "module_${i}_program_start='${PROGRAM_START}'" >> 
"${MODULESLIST}"
-   echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> 
"${MODULESLIST}"
-   echo "module_${i}_provide='${PROVIDE}'" >> "${MODULESLIST}"
+   echo "module_${i}='${MODULE}'" >> "${TMPMODULESLIST}"
+   echo "module_${i}_program='${PROGRAM}'" >> "${TMPMODULESLIST}"
+   echo "module_${i}_program_start='${PROGRAM_START}'" >> 
"${TMPMODULESLIST}"
+   echo "module_${i}_program_stop='${PROGRAM_STOP}'" >> 
"${TMPMODULESLIST}"
+   echo "module_${i}_provide='${PROVIDE}'" >> "${TMPMODULESLIST}"
: $(( i += 1 ))
done
-   echo "module_${i}=" >> "${MODULESLIST}"
+   echo "module_${i}=" >> "${TMPMODULESLIST}"
+   mv -f "${TMPMODULESLIST}" "${MODULESLIST}"
)
 
return 0



[gentoo-commits] proj/netifrc:master commit in: init.d/

2017-11-14 Thread Robin H. Johnson
commit: dbfe9a7fefa70150528a66aae380b7de52d15832
Author: Hagbard Celine  gmail  com>
AuthorDate: Tue Nov 14 19:11:32 2017 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Nov 14 19:11:40 2017 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=dbfe9a7f

init.d/net.lo: per-iface moduleslist

Avoid race conditions in generation of modules list (nettree), and allow
per-interface custom module work more easily.

Closes: https://bugs.gentoo.org/637474
Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index d7108a5..33cc932 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -5,7 +5,6 @@
 
 SHDIR="@LIBEXECDIR@/sh"
 MODULESDIR="@LIBEXECDIR@/net"
-MODULESLIST="${RC_SVCDIR}/nettree"
 _config_vars="config metric routes"
 
 [ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO"
@@ -26,6 +25,10 @@ else
exit 1
 fi
 
+# Create per-interface nettree ordering, avoids race conditions and allows
+# per-interface custom modules.
+MODULESLIST="${RC_SVCDIR}/nettree$(get_interface)"
+
 depend()
 {
local IFACE=$(get_interface)



[gentoo-commits] proj/netifrc:master commit in: init.d/

2016-10-24 Thread Robin H. Johnson
commit: 2af03b659eb8028bc0dc5101a22ed31e330073f5
Author: Sven Wegener  gentoo  org>
AuthorDate: Tue Oct  4 20:11:01 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Oct 24 20:52:32 2016 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2af03b65

net.lo: Add metric to supported config variables

This allows us to use metric_ for configuration.

Signed-off-by: Sven Wegener  gentoo.org>
(cherry picked from commit 3cd367c958e533bbeae011699eef0da2fdf1079e)

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 72a5427..d7108a5 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -6,7 +6,7 @@
 SHDIR="@LIBEXECDIR@/sh"
 MODULESDIR="@LIBEXECDIR@/net"
 MODULESLIST="${RC_SVCDIR}/nettree"
-_config_vars="config routes"
+_config_vars="config metric routes"
 
 [ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO"
 



[gentoo-commits] proj/netifrc:master commit in: init.d/

2016-10-23 Thread Robin H. Johnson
commit: 0eea80cc3955c2965368ef84cc521dc0b5edca7b
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Oct 24 00:14:29 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Oct 24 00:14:29 2016 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0eea80cc

net.lo: do not hide any _add_route output.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 1a8feaa..72a5427 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -735,7 +735,7 @@ ${routes}"
*:*/*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
-   _add_route ${fam} ${cmd} >/dev/null
+   _add_route ${fam} ${cmd}
eend $?
eoutdent
done



[gentoo-commits] proj/netifrc:master commit in: init.d/

2016-10-23 Thread Robin H. Johnson
commit: 1705b16b61bf00a1c610a34aebe112e8f28e85b6
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Oct 24 00:12:49 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Oct 24 00:12:53 2016 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1705b16b

net.lo: display ALL routes

For historical reasons, we used to suppress the first route for an
interface, but this make it unclear what was being done.

Display all routes instead.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index dbade70..1a8feaa 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -693,7 +693,7 @@ start()
return 1
fi
 
-   local hideFirstroute=false first=true routes=
+   local first=true routes=
if ${fallback}; then
routes="$(_get_array "fallback_routes_${IFVAR}")"
fi
@@ -704,7 +704,6 @@ start()
if [ "${config_0}" != "null" ]; then
routes="127.0.0.0/8 via 127.0.0.1
 ${routes}"
-   hideFirstroute=true
fi
fi
 
@@ -736,12 +735,7 @@ ${routes}"
*:*/*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
-   if ${hideFirstroute}; then
-   _add_route ${fam} ${cmd} >/dev/null 2>&1
-   hideFirstroute=false
-   else
-   _add_route ${fam} ${cmd} >/dev/null
-   fi
+   _add_route ${fam} ${cmd} >/dev/null
eend $?
eoutdent
done



[gentoo-commits] proj/netifrc:master commit in: init.d/

2016-10-23 Thread Robin H. Johnson
commit: e337a9906e526b4b60fea7d260a4b21badb89ca1
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Oct 23 23:41:00 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Oct 23 23:41:00 2016 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e337a990

net.lo: framework for error handling customization.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 28 
 1 file changed, 28 insertions(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index a8e19dd..3b47f1a 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -227,6 +227,34 @@ _show_address()
einfo "received address $(_get_inet_address "${IFACE}")"
 }
 
+# Allow custom error handling behavior to be set by the user.
+# Known used combinations, with defaults
+# errh_IFVAR_address_EEXIST=warn
+# errh_IFVAR_route_EEXIST=warn
+_get_errorhandler_behavior() {
+   IFVAR="$1"
+   object="$2"
+   error="$3"
+   fallback="$4"
+   value=
+   for key in \
+   "errh_${IFVAR}_${object}_${error}" \
+   "errh_${IFVAR}_${object}_DEFAULT" \
+   "errh_${IFVAR}_DEFAULT_${error}" \
+   "errh_${IFVAR}_DEFAULT_DEFAULT" \
+   "errh_DEFAULT_${object}_${error}" \
+   "errh_DEFAULT_${object}_DEFAULT" \
+   "errh_DEFAULT_DEFAULT_${error}" \
+   "errh_DEFAULT_DEFAULT_DEFAULT" \
+   "errh" \
+   "fallback" ; do
+   eval value="\${key}"
+   if [ -n "$value" ]; then
+   echo "$value" && break
+   fi
+   done
+}
+
 # Basically sorts our modules into order and saves the list
 _gen_module_list()
 {



[gentoo-commits] proj/netifrc:master commit in: init.d/

2016-07-05 Thread Robin H. Johnson
commit: 9b3dc52ac99397eec0be909ce87c4ecab028661a
Author: Thomas Deutschmann  whissi  de>
AuthorDate: Sun Jun 12 21:18:48 2016 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Jun 12 21:18:48 2016 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9b3dc52a

net.lo: use #!/sbin/openrc-run instead of #!/sbin/runscript

See: https://bugs.gentoo.org/573846

 init.d/net.lo.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 31a45e6..a8e19dd 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -1,6 +1,6 @@
-#!@SBINDIR@/runscript
+#!@SBINDIR@/openrc-run
 # Copyright (c) 2007-2009 Roy Marples 
-# Copyright (c) 2010-2015 Gentoo Foundation
+# Copyright (c) 2010-2016 Gentoo Foundation
 # Released under the 2-clause BSD license.
 
 SHDIR="@LIBEXECDIR@/sh"



[gentoo-commits] proj/netifrc:master commit in: init.d/

2015-11-08 Thread Robin H. Johnson
commit: e65e9b5065f6c11f89428ec3788c49ed1422d9ba
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Nov  8 14:08:09 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Nov  8 14:08:09 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e65e9b50

Update copyright on net.lo.in for significent gentoo changes.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index e883f98..2611e3e 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -1,5 +1,6 @@
 #!@SBINDIR@/runscript
 # Copyright (c) 2007-2009 Roy Marples 
+# Copyright (c) 2010-2015 Gentoo Foundation
 # Released under the 2-clause BSD license.
 
 SHDIR="@LIBEXECDIR@/sh"



[gentoo-commits] proj/netifrc:master commit in: init.d/

2015-11-08 Thread Robin H. Johnson
commit: 756591785d521af36a30b5a74d58be733a94e596
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Nov  8 14:09:33 2015 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Nov  8 14:09:33 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=75659178

New functions: set/get/is_interface_type to persistently track type of 
interfaces despite conf.d/net changes.

Signed-off-by: Robin H. Johnson  gentoo.org>

 init.d/net.lo.in | 12 
 1 file changed, 12 insertions(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 2611e3e..31a45e6 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -536,6 +536,18 @@ interface_down()
 {
_run_if _down "$@"
 }
+set_interface_type()
+{
+   service_set_value iface_type "$@"
+}
+get_interface_type()
+{
+   ( RC_SVCNAME="net.$IFACE" service_get_value iface_type )
+}
+is_interface_type()
+{
+   [ "$(get_interface_type)" = "$1" ]
+}
 
 start()
 {



[gentoo-commits] proj/netifrc:master commit in: init.d/

2015-05-25 Thread Mike Frysinger
commit: fb47f01605857f09614013d23014ad5a6899e9f7
Author: Patrick McLean patrickm AT gaikai DOT com
AuthorDate: Thu Jan 29 01:04:41 2015 +
Commit: Mike Frysinger vapier AT gentoo DOT org
CommitDate: Thu Jan 29 01:04:41 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=fb47f016

lo should not have a need dependency on localmount

 init.d/net.lo.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index e9e7f7c..bdb3747 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -30,9 +30,9 @@ depend()
local IFACE=$(get_interface)
local IFVAR=$(shell_var ${IFACE})
 
-   need localmount
if [ $RC_UNAME = Linux -a $IFACE != lo ]; then
need sysfs
+   after modules
fi
after bootmisc
keyword -jail -prefix -vserver
@@ -41,6 +41,7 @@ depend()
lo|lo0) ;;
*)
after net.lo net.lo0 dbus
+   need localmount
provide net
;;
esac



[gentoo-commits] proj/netifrc:master commit in: init.d/

2015-05-25 Thread Mike Frysinger
commit: 902d48c8bd46dd67565371cb5d2c84f91ad30b8e
Author: Thomas D whissi AT whissi DOT de
AuthorDate: Wed Apr 16 09:52:56 2014 +
Commit: Mike Frysinger vapier AT gentoo DOT org
CommitDate: Tue Mar 10 16:14:49 2015 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=902d48c8

_wait_for_carrier(): Workaround for output when using rc_parallel=YES is no 
longer needed

_wait_for_carrier() was using a workaround when rc_parallel is enabled.
This caused the following broken output:

  https://bugs.gentoo.org/attachment.cgi?id=361054

This patch fixes bug 488256 by removing the workaround, because this
workaround isn't needed anymore.

X-Gentoo-Bug: 488256
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488256

 init.d/net.lo.in | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index bdb3747..e883f98 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -116,7 +116,7 @@ _flatten_array()
 
 _wait_for_carrier()
 {
-   local timeout= efunc=einfon
+   local timeout=
 
_has_carrier   return 0
 
@@ -126,20 +126,19 @@ _wait_for_carrier()
# Incase users don't want this nice feature ...
[ ${timeout} -le 0 ]  return 0
 
-   yesno ${RC_PARALLEL}  efunc=einfo
-   ${efunc} Waiting for carrier (${timeout} seconds) 
+   einfon Waiting for carrier (${timeout} seconds) 
while [ ${timeout} -gt 0 ]; do
if _has_carrier; then
-   [ ${efunc} = einfon ]  echo
+   echo
eend 0
return 0
fi
sleep 1
: $(( timeout -= 1 ))
-   [ ${efunc} = einfon ]  printf .
+   printf .
done
 
-   [ ${efunc} = einfon ]  echo
+   echo
eend 1
return 1
 }



[gentoo-commits] proj/netifrc:master commit in: init.d/

2015-01-09 Thread Robin H. Johnson
commit: ecba7604cf633342162deb802cb18008c55b0382
Author: Rabi Shanker Guha guha.rabishankar AT gmail DOT com
AuthorDate: Fri Jan  9 15:08:13 2015 +
Commit: Robin H. Johnson robbat2 AT gentoo DOT org
CommitDate: Fri Jan  9 15:08:13 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=ecba7604

Update runscript to use functions.sh compatibility layer

---
 init.d/net.lo.in | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 6a0aefb..c79e7ff 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -2,6 +2,7 @@
 # Copyright (c) 2007-2009 Roy Marples r...@marples.name
 # Released under the 2-clause BSD license.
 
+SHDIR=@LIBEXECDIR@/sh
 MODULESDIR=@LIBEXECDIR@/net
 MODULESLIST=${RC_SVCDIR}/nettree
 _config_vars=config routes
@@ -13,9 +14,20 @@ description=Configures network interfaces.
 # Handy var so we don't have to embed new lines everywhere for array splitting
 __IFS=
 
+
+#  Set the INIT to be openrc if this file is called directly
+: ${INIT:=openrc}
+
+if [ -f $SHDIR/functions.sh ]; then
+   . $SHDIR/functions.sh
+else
+   echo $SHDIR/functions.sh missing. Exiting
+   exit -1
+fi
+
 depend()
 {
-   local IFACE=${RC_SVCNAME#*.}
+   local IFACE=$(get_interface)
local IFVAR=$(shell_var ${IFACE})
 
need localmount
@@ -526,7 +538,7 @@ interface_down()
 
 start()
 {
-   local IFACE=${RC_SVCNAME#*.} oneworked=false fallback=false module=
+   local IFACE=$(get_interface) oneworked=false fallback=false module=
local IFVAR=$(shell_var ${IFACE}) cmd= our_metric=
local metric=0 _up_before_preup
eval _up_before_preup=\$up_before_preup_${IFVAR}
@@ -721,7 +733,7 @@ stop()
# correctly if we go back to multiuser.
yesno ${keep_network:-YES}  yesno $RC_GOINGDOWN  return 0
 
-   local IFACE=${RC_SVCNAME#*.} module=
+   local IFACE=$(get_interface) module=
local IFVAR=$(shell_var ${IFACE}) opts=
 
einfo Bringing down interface ${IFACE}



[gentoo-commits] proj/netifrc:master commit in: init.d/

2014-10-11 Thread Robin H. Johnson
commit: 3a97f7c0dd702d55e1280c1153d44ee8747fe1f4
Author: mirabilos tg AT debian DOT org
AuthorDate: Fri Oct 10 21:58:11 2014 +
Commit: Robin H. Johnson robbat2 AT gentoo DOT org
CommitDate: Sat Oct 11 19:47:17 2014 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=3a97f7c0

Fix https://bugs.gentoo.org/show_bug.cgi?id=500942

“unset x” also removes the “local x” property, so the next assignment and/or 
read to/from $x will access the global variable “x”.

Signed-off-by: Robin H. Johnson robbat2 AT gentoo.org

---
 init.d/net.lo.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 01c1b20..6a0aefb 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -203,7 +203,7 @@ _program_available()
/*) [ -x ${x} ]  break;;
*) type ${x} /dev/null 21  break;;
esac
-   unset x
+   x=
done
[ -n ${x} ]  echo $x  return 0
return 1



[gentoo-commits] proj/netifrc:master commit in: init.d/

2014-07-17 Thread Robin H. Johnson
commit: e9212e5164877056cb44bd1be542f0ab8c1c0f1a
Author: Robin H. Johnson robbat2 AT gentoo DOT org
AuthorDate: Wed Jul 16 19:07:56 2014 +
Commit: Robin H. Johnson robbat2 AT gentoo DOT org
CommitDate: Wed Jul 16 19:16:39 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=e9212e51

net.lo: cached module list timing issue

Handle cached modulelist being newer than current time, as it would not
be recached even when needed; force recache.

Signed-off-by: Robin H. Johnson robbat2 AT gentoo.org
X-Gentoo-Bug: 506966
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=506966

---
 init.d/net.lo.in | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 5ea73c7..01c1b20 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -218,16 +218,20 @@ _show_address()
 _gen_module_list()
 {
local x= f= force=$1
-   if ! ${force}  [ -s ${MODULESLIST} -a ${MODULESLIST} -nt 
${MODULESDIR} ]; then
-   local update=false
-   for x in ${MODULESDIR}/*.sh; do
-   [ -e ${x} ] || continue
-   if [ ${x} -nt ${MODULESLIST} ]; then
-   update=true
-   break
-   fi
-   done
-   ${update} || return 0
+   if ! ${force} ; then
+   if [ -s ${MODULESLIST} -a ${MODULESLIST} -nt 
/proc/$$/status ]; then
+   ewarn Discarding cached module list ($MODULESLIST) as 
it's newer current time!
+   elif [ -s ${MODULESLIST} -a ${MODULESLIST} -nt 
${MODULESDIR} ]; then
+   local update=false
+   for x in ${MODULESDIR}/*.sh; do
+   [ -e ${x} ] || continue
+   if [ ${x} -nt ${MODULESLIST} ]; then
+   update=true
+   break
+   fi
+   done
+   ${update} || return 0
+   fi
fi
 
einfo Caching network module dependencies