[gentoo-commits] proj/netifrc:master commit in: net/

2024-05-23 Thread Patrick McLean
commit: 8bb61b90c1d791bafd5cd0b6c54093cccee425f4
Author: Alexander Zubkov  qrator  net>
AuthorDate: Thu May 23 14:56:42 2024 +
Commit: Patrick McLean  gentoo  org>
CommitDate: Thu May 23 18:12:13 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8bb61b90

net/wireguard.sh: make wireguard module to run before interface

Wireguard module was configured to run after interface module, that
caused interface-related settings like mtu not to apply, because
wireguard interfaces was not present by that time. It seems logical
that wireguard module should be run before interface module.

Credits to lmk  gmail.com> who proposed the solution and
to Louis Sautier (sbraz)  gentoo.org> who proposed the patch.

Closes: https://bugs.gentoo.org/678184
Closes: https://github.com/gentoo/netifrc/pull/54
Signed-off-by: Louis Sautier (sbraz)  gentoo.org>
Signed-off-by: Alexander Zubkov  qrator.net>
Signed-off-by: Patrick McLean  gentoo.org>

 net/wireguard.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireguard.sh b/net/wireguard.sh
index bb71d6f..f6ca69e 100644
--- a/net/wireguard.sh
+++ b/net/wireguard.sh
@@ -6,7 +6,7 @@
 wireguard_depend()
 {
program wg
-   after interface
+   before interface
 }
 
 wireguard_pre_start()



[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: mk/

2024-01-13 Thread Sam James
commit: a058cb072fcd8f2874513e4ca58f92482e2a191b
Author: Matoro Mahri  matoro  tk>
AuthorDate: Sat Jan 13 05:14:01 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 14 04:47:25 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a058cb07

mk/os.mk: don't use OS env var for overriding

If you want to override the OS or OS-detect command you can still use
_OS and _OS_SH, but OS is too common of an environment variable to
listen for.

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

 mk/os.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/os.mk b/mk/os.mk
index c306f05..cf089e7 100644
--- a/mk/os.mk
+++ b/mk/os.mk
@@ -5,7 +5,7 @@
 
 _OS_SH=uname -s
 _OS:=  $(shell ${_OS_SH})
-OS?=   ${_OS}
+OS=${_OS}
 include ${MK}/os-${OS}.mk
 
 RC_LIB=/$(LIBNAME)/rc



[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: net/, doc/

2024-01-07 Thread Sam James
commit: 7b1c09f80b94f01f670c8d487df361b3ddfebe0c
Author: Matoro Mahri  matoro  tk>
AuthorDate: Sun Jan  7 07:16:30 2024 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan  7 09:42:35 2024 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7b1c09f8

Remove support for treecleaned net-misc/pump

Bug: https://bugs.gentoo.org/694314
Closes: https://bugs.gentoo.org/921538
Signed-off-by: Matoro Mahri  matoro.tk>
Closes: https://github.com/gentoo/netifrc/pull/51
Signed-off-by: Sam James  gentoo.org>

 doc/net.example.Linux.in |  7 ++
 net/Makefile |  2 +-
 net/dhclient.sh  |  2 +-
 net/dhcpcd.sh|  2 +-
 net/pump.sh  | 63 
 5 files changed, 5 insertions(+), 71 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index cbd81e7..84e4b1c 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -493,11 +493,10 @@
 
 #-
 # DHCP
-# DHCP can be provided by dhclient, dhcpcd, pump or udhcpc.
+# DHCP can be provided by dhclient, dhcpcd, or udhcpc.
 #
 # dhclient: emerge net-misc/dhcp
 # dhcpcd:   emerge net-misc/dhcpcd
-# pump: emerge net-misc/pump
 # udhcpc:   emerge sys-apps/busybox
 
 # If you have more than one DHCP client installed, you need to specify which
@@ -508,7 +507,6 @@
 # - All clients send the current hostname to the DHCP server by default
 # - dhcpcd does not daemonize when the lease time is infinite
 # - udhcp-0.9.3-r3 and earlier do not support getting NTP servers
-# - pump does not support getting NIS servers
 # - DHCP tends to erase any existing device information - so add
 #   static addresses after dhcp if you need them
 # - dhclient and udhcpc can set other resolv.conf options such as "option"
@@ -524,11 +522,10 @@
 # default) to 10 seconds.
 #dhcpcd_eth0="-t 10"
 
-# dhclient, udhcpc and pump don't have many runtime options
+# dhclient and udhcpc don't have many runtime options
 # You can pass options to them in a similar manner to dhcpcd though
 #dhclient_eth0="..."
 #udhcpc_eth0="..."
-#pump_eth0="..."
 
 # GENERIC DHCP OPTIONS
 # Set generic DHCP options like so

diff --git a/net/Makefile b/net/Makefile
index f562d15..22bd8d1 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -12,7 +12,7 @@ INC-FreeBSD=  iwconfig.sh
 SRCS-Linux=iwconfig.sh.in udhcpc.sh.in
 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 \
+   ipppd.sh iwconfig.sh netplugd.sh pppd.sh tuntap.sh udhcpc.sh \
vlan.sh macvlan.sh ip6rd.sh firewalld.sh dummy.sh hsr.sh 
l2tp.sh \
iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh qmi.sh
 

diff --git a/net/dhclient.sh b/net/dhclient.sh
index 6fa4a92..ce964b0 100644
--- a/net/dhclient.sh
+++ b/net/dhclient.sh
@@ -9,7 +9,7 @@ dhclient_depend()
provide dhcp
 
# We prefer dhclient over these
-   after udhcpc pump
+   after udhcpc
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 2493f27..e159f0a 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -10,7 +10,7 @@ dhcpcd_depend()
provide dhcp
 
# We prefer dhcpcd over these
-   after udhcpc pump dhclient
+   after udhcpc dhclient
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/pump.sh b/net/pump.sh
deleted file mode 100644
index 144316f..000
--- a/net/pump.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (c) 2007-2008 Roy Marples 
-# Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
-
-pump_depend()
-{
-   program pump
-   after interface
-   provide dhcp
-
-   # We prefer pump over udhcpc
-   after udhcpc
-}
-
-_config_vars="$_config_vars dhcp pump"
-
-pump_start()
-{
-   local args= opt= opts=
-
-   # Get our options
-   eval opts=\$dhcp_${IFVAR}
-   [ -z "${opts}" ] && opts=${dhcp}
-
-   # Map some generic options to dhcpcd
-   for opt in ${opts}; do
-   case "${opt}" in
-   nodns) args="${args} --no-dns";;
-   nontp) args="${args} --no-ntp";;
-   nogateway) args="${args} --no-gateway";;
-   esac
-   done
-
-   # Add our route metric
-   [ "${metric:-0}" != "0" ] && args="${args} --route-metric ${metric}"
-
-   args="${args} --win-client-ident"
-   args="${args} --keep-up --interface ${IFACE}"
-
-   ebegin "Running pump"
-   eval pump "${args}"
-   eend $? || return 1
-
-   _show_address
-   return 0
-}
-
-pump_stop()
-{
-   # We check for a pump process first as querying for status
-   # causes pump to spawn a process
-   

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

2023-11-24 Thread Robin H. Johnson
commit: a0b69349707b4aaaefc01fd37f1b386935d75c90
Author: Alon Bar-Lev  gmail  com>
AuthorDate: Sun May 14 21:38:28 2023 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Nov 25 04:54:01 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a0b69349

net: add qmi interface support

qmi is useful for cellular modem connection, the management interface is
implemented using libqmi's qmicli utility.

Signed-off-by: Alon Bar-Lev  gmail.com>
Signed-off-by: Robin H. Johnson  gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/44

 doc/net.example.Linux.in |  13 +
 net/Makefile |   2 +-
 net/qmi.sh   | 133 +++
 3 files changed, 147 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 42b8071..cbd81e7 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1132,6 +1132,19 @@
 #l2tpsession_l2tpeth2="tunnel_id 2 session_id 1 peer_session_id 1"
 #config_l2tpeth2="10.100.2.1/24"
 
+#-
+# QMI
+# For QMI support, emerge net-libs/libqmi
+# QMI is used for some cellular modems.
+#
+# Each QMI interface may have the following configuration:
+#qmi_apn_wwan0=# The name of the APN
+#qmi_auth_wwan0=   # none, pop, chap, both, Default: none
+#qmi_username_wwan0=   # Default: dummy
+#qmi_password_wwan0=   # Default dummy
+#qmi_cdc_wwan0=# Default: /dev/cdc-wmiX where 
X is taken from IFACE
+#-
+
 #-
 # Advanced Routing
 # WARNING: For advanced routing you MUST be using sys-apps/iproute2

diff --git a/net/Makefile b/net/Makefile
index 58483cd..f562d15 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 iwd.sh wireguard.sh veth.sh dhclientv6.sh
+   iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh qmi.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=ifwatchd.sh

diff --git a/net/qmi.sh b/net/qmi.sh
new file mode 100644
index 000..ac1b2dd
--- /dev/null
+++ b/net/qmi.sh
@@ -0,0 +1,133 @@
+# Copyright (c) 2011 by Gentoo Foundation
+# Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
+
+_is_qmi() {
+   [ -d "/sys/class/net/${IFACE}/qmi" ]
+}
+
+_get_state() {
+   echo "/run/net.${IFACE}.qmi.state"
+}
+
+_get_device() {
+   echo "/dev/cdc-$(echo "${IFACE}" | sed 's/wwan/wdm/')"
+}
+
+qmi_depend()
+{
+   program qmicli
+   program ip
+   before interface
+}
+
+qmi_pre_start() {
+
+   _is_qmi || return 0
+
+   local device
+   local apn
+   local auth
+   local username
+   local password
+   local out
+   local rc
+
+   eval device=\$qmi_cdc_${IFVAR}
+   eval apn=\$qmi_apn_${IFVAR}
+   eval auth=\$qmi_auth_${IFVAR}
+   eval username=\$qmi_username_${IFVAR}
+   eval password=\$qmi_password_${IFVAR}
+
+   [ -n "${apn}" ] || return 0
+
+   [ -n "${device}" ] || device="$(_get_device)"
+   [ -n "${auth}" ] || auth="none"
+   [ -n "${username}" ] || username="dummy"
+   [ -n "${password}" ] || password="dummy"
+
+   if ! [ -c "${device}" ]; then
+   ewarn "Cannot open device ${device} for ${IFACE}, aborting 
configuration"
+   return 1
+   fi
+
+   if ! cat "/sys/class/net/${IFACE}/qmi/raw_ip" | grep -q Y; then
+   ebegin "Configuring QMI raw IP"
+
+   ip link set "${IFACE}" down
+   if ! echo Y > "/sys/class/net/${IFACE}/qmi/raw_ip"; then
+   eend 1 "Cannot set raw IP mode for ${IFACE}, aborting 
configuration"
+   return 1
+   else
+   eend 0
+   fi
+   fi
+
+   local 
wwan_connection="apn='${apn}',auth='${auth}',username='${username}',password='${password}',autoconnect=yes,ip-type=4"
+   local n
+   for n in 1 2 3; do
+   ebegin "Connecting QMI APN '${apn}' using '${username}'"
+
+   if out="$( \
+   qmicli \
+   --device="${device}" \
+   --wds-start-network="${wwan_connection}" \
+   --device-open-proxy \
+   --client-no-release-cid \
+   )"; then
+   eend 0
+  

[gentoo-commits] proj/netifrc:master commit in: net/

2023-11-24 Thread Robin H. Johnson
commit: acf5e9c1d505e14524dcc78a1433872ae273c491
Author: Violet Purcell  inventati  org>
AuthorDate: Wed Nov 22 23:35:01 2023 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Nov 25 04:52:47 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=acf5e9c1

iwd: depend on "program /usr/libexec/iwd" instead of "program iwd"

In iwd.sh, the iwd executable used is /usr/libexec/iwd, however in the
dependency block it depends on just "program iwd." Since iwd is not in
PATH, this will fail and cause iwd to not be started when it should be.
Correct this to /usr/libexec/iwd.

Signed-off-by: Violet Purcell  inventati.org>
Signed-off-by: Robin H. Johnson  gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/49

 net/iwd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iwd.sh b/net/iwd.sh
index d8be2d5..75edb8c 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -7,7 +7,7 @@ iwd_depend()
before interface
provide wireless
after iwconfig
-   program iwd
+   program /usr/libexec/iwd
 }
 
 _config_vars="$_config_vars iwd"



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

2023-10-19 Thread Sam James
commit: ed541fbe97fa22066030faaba051fe8d8a4b168a
Author: Sam James  gentoo  org>
AuthorDate: Fri Oct 20 00:20:20 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Fri Oct 20 00:20:20 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ed541fbe

Makefile.inc: prepare for 0.7.7

Signed-off-by: Sam James  gentoo.org>

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index 49ba250..811b0d4 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.6
+VERSION=   0.7.7
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: net/

2023-10-19 Thread Sam James
commit: bf02831a7a59f5552c916dde7dd47296a7bce0b1
Author: kmartin36  gtri  gatech  edu>
AuthorDate: Fri Sep 15 01:29:27 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Oct 19 22:57:19 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bf02831a

dhcpcd: Fixing the handling of dhcpcd arguments with spaces

Bug: https://bugs.gentoo.org/881039
Signed-off-by: Kevin Martin  gmail.com>
Fixes: bd8ff4aa89e1d56e9886dad32bb2406c8f43c747
Closes: https://github.com/gentoo/netifrc/pull/48
Signed-off-by: Sam James  gentoo.org>

 net/dhcpcd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 6bd44ba..2493f27 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -90,8 +90,8 @@ dhcpcd_stop()
eval opts=\$dhcp_${IFVAR}
[ -z "${opts}" ] && opts=${dhcp}
case " ${opts} " in
-   *" release "*) dhcpcd -k "${args}" "${IFACE}" ;;
-   *) dhcpcd -x "${args}" "${IFACE}" ;;
+   *" release "*) dhcpcd -k ${args} "${IFACE}" ;;
+   *) dhcpcd -x ${args} "${IFACE}" ;;
esac
[ -f "${argsfile}" ] && rm -f "${argsfile}"
eend $?



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

2023-09-10 Thread Sam James
commit: e5776f83258f38bb01312a909cdf57d0bdb8a4d2
Author: Sam James  gentoo  org>
AuthorDate: Sun Sep 10 15:17:49 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Sep 10 15:17:49 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5776f83

Makefile.inc: prepare for 0.7.6

Signed-off-by: Sam James  gentoo.org>

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index b1aba0f..49ba250 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.5
+VERSION=   0.7.6
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: sh/, net/

2023-09-10 Thread Sam James
commit: 75b7229ffa861c8472abe64733a657409b5d929d
Author: Mike Gilbert  gentoo  org>
AuthorDate: Tue May 30 20:12:12 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Sep 10 15:14:49 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=75b7229f

Remove absolute paths from commands

Bug: https://bugs.gentoo.org/889922
Bug: https://bugs.gentoo.org/893290
Signed-off-by: Mike Gilbert  gentoo.org>
Signed-off-by: Sam James  gentoo.org>

 net/adsl.sh  |  8 
 net/apipa.sh |  2 +-
 net/arping.sh|  4 ++--
 net/bonding.sh   |  4 ++--
 net/clip.sh  |  6 +++---
 net/dhclient.sh  |  8 
 net/dhclientv6.sh|  8 
 net/ifconfig.sh.BSD.in   |  2 +-
 net/ifconfig.sh.Linux.in |  2 +-
 net/ifplugd.sh   |  6 +++---
 net/ifwatchd.sh.BSD.in   |  8 
 net/ipppd.sh |  6 +++---
 net/iw.sh|  2 +-
 net/iwconfig.sh.BSD.in   |  2 +-
 net/iwconfig.sh.Linux.in |  2 +-
 net/macchanger.sh|  4 ++--
 net/netplugd.sh  |  6 +++---
 net/pppd.sh  | 12 ++--
 net/pump.sh  |  4 ++--
 net/system.sh|  2 +-
 net/udhcpc.sh.Linux.in   | 10 +-
 net/wireguard.sh |  6 +++---
 net/wpa_supplicant.sh| 13 ++---
 sh/udhcpc-hook.sh.in |  4 ++--
 24 files changed, 61 insertions(+), 70 deletions(-)

diff --git a/net/adsl.sh b/net/adsl.sh
index 7724710..fe48454 100644
--- a/net/adsl.sh
+++ b/net/adsl.sh
@@ -5,7 +5,7 @@
 
 adsl_depend()
 {
-   program /usr/sbin/adsl-start /usr/sbin/pppoe-start
+   program adsl-start pppoe-start
before dhcp
 }
 
@@ -13,11 +13,11 @@ adsl_setup_vars()
 {
local startstop="$1" cfgexe=
 
-   if [ -x /usr/sbin/pppoe-start ]; then
-   exe="/usr/sbin/pppoe-${startstop}"
+   if command -v pppoe-start >/dev/null; then
+   exe="pppoe-${startstop}"
cfgexe=pppoe-setup
else
-   exe="/usr/sbin/adsl-${startstop}"
+   exe="adsl-${startstop}"
cfgexe=adsl-setup
fi
 

diff --git a/net/apipa.sh b/net/apipa.sh
index a124b84..7ccdad0 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -3,7 +3,7 @@
 
 apipa_depend()
 {
-   program /sbin/arping /bin/arping
+   program arping
 }
 
 _random_uint16()

diff --git a/net/arping.sh b/net/arping.sh
index bdd8284..fbda9c8 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -4,7 +4,7 @@
 
 arping_depend()
 {
-   program /sbin/arping /bin/arping /usr/bin/arping /usr/sbin/arping 
/usr/sbin/arping2
+   program arping arping2
before interface
 }
 
@@ -26,7 +26,7 @@ arping_address()
eval w=\$arping_wait_${IFVAR}
[ -z "${w}" ] && w=${arping_wait:-5}
 
-   if type arping2 >/dev/null 2>&1; then
+   if command -v arping2 >/dev/null; then
if [ -n "${spoof}" ]; then
opts="${opts} -S ${spoof}"
else

diff --git a/net/bonding.sh b/net/bonding.sh
index 6db90fa..d8f48d8 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -6,11 +6,11 @@
 bonding_depend()
 {
before interface macchanger
-   program ip /sbin/ifconfig /bin/ifconfig
+   program ip ifconfig
# If you do not have sysfs, you MUST have this binary instead for ioctl
# Also you will loose some functionality that cannot be done via sysfs:
if [ ! -d /sys/class/net ]; then
-   program /sbin/ifenslave
+   program ifenslave
fi
 
local netns

diff --git a/net/clip.sh b/net/clip.sh
index 96bfe6e..e853e68 100644
--- a/net/clip.sh
+++ b/net/clip.sh
@@ -4,7 +4,7 @@
 
 clip_depend()
 {
-   program /usr/sbin/atmsigd
+program atmsigd
 before interface
 }
 
@@ -23,7 +23,7 @@ atmclip_svc_start()
 start-stop-daemon --start \
--background \
--make-pidfile --pidfile "/run/$1.pid" \
-   --exec "/usr/sbin/$1" -- -l syslog
+   --exec "$1" -- -l syslog
 eend $?
 }
 
@@ -51,7 +51,7 @@ atmclip_svc_stop()
 ebegin "Stopping $2 Daemon ($1)"
 start-stop-daemon --stop --quiet \
--pidfile "/run/$1.pid" \
-   --exec "/usr/sbin/$1"
+   --exec "$1"
 eend $?
 }
 

diff --git a/net/dhclient.sh b/net/dhclient.sh
index 24c3512..6fa4a92 100644
--- a/net/dhclient.sh
+++ b/net/dhclient.sh
@@ -5,7 +5,7 @@
 dhclient_depend()
 {
after interface
-   program start /sbin/dhclient
+   program start dhclient
provide dhcp
 
# We prefer dhclient over these
@@ -48,7 +48,7 @@ dhclient_start()
 
# Bring up DHCP for this interface
ebegin "Running dhclient"
-   echo "${dhconf}" | start-stop-daemon --start --exec /sbin/dhclient \
+   echo "${dhconf}" | start-stop-daemon --start --exec dhclient \
--pidfile "${pidfile}" \
-- ${args} -q -1 -pf "${pidfile}" 

[gentoo-commits] proj/netifrc:master commit in: net/

2023-09-10 Thread Sam James
commit: a509a86bbfe77db20d676caa5f3c421d5a781780
Author: Mike Gilbert  gentoo  org>
AuthorDate: Thu Jun  1 19:21:23 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Sep 10 15:15:45 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a509a86b

net/bonding.sh: fix spelling of "lose"

Signed-off-by: Mike Gilbert  gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/47
Signed-off-by: Sam James  gentoo.org>

 net/bonding.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index d8f48d8..e3fcaa7 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -8,7 +8,7 @@ bonding_depend()
before interface macchanger
program ip ifconfig
# If you do not have sysfs, you MUST have this binary instead for ioctl
-   # Also you will loose some functionality that cannot be done via sysfs:
+   # Also you will lose some functionality that cannot be done via sysfs:
if [ ! -d /sys/class/net ]; then
program ifenslave
fi



[gentoo-commits] proj/netifrc:master commit in: net/

2023-05-28 Thread Mike Gilbert
commit: 0ac293faa15b49f08830120e7b5fa1e4523f19e5
Author: Mike Gilbert  gentoo  org>
AuthorDate: Sun May 28 20:07:47 2023 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Sun May 28 22:49:02 2023 +
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  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 
 # 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}"



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

2023-05-28 Thread Mike Gilbert
commit: 52416b2f17e1e1700e4a41b43fd887f7e2cf317e
Author: Mike Gilbert  gentoo  org>
AuthorDate: Mon May 29 00:16:12 2023 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Mon May 29 00:16:12 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=52416b2f

Makefile.inc: version 0.7.5

Signed-off-by: Mike Gilbert  gentoo.org>

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index fe1eb33..b1aba0f 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.4
+VERSION=   0.7.5
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: net/

2023-04-19 Thread Robin H. Johnson
commit: baff1e37615921b37cfa166215d3d1c6531a81af
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Wed Apr 19 17:11:32 2023 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Wed Apr 19 17:14:32 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=baff1e37

net/Makefile: include iwd

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

 net/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/Makefile b/net/Makefile
index ee48294..58483cd 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 dhclientv6.sh
+   iw.sh iwd.sh wireguard.sh veth.sh dhclientv6.sh
 
 SRCS-NetBSD= ifwatchd.sh.in
 INC-NetBSD=ifwatchd.sh



[gentoo-commits] proj/netifrc:master commit in: doc/

2023-04-19 Thread Robin H. Johnson
commit: a6c76fb426877a1dc516a81c2278aa94da2a9604
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Wed Apr 19 17:11:12 2023 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Wed Apr 19 17:14:04 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a6c76fb4

doc/net.example.Linux.in: add hsr examples

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

 doc/net.example.Linux.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index e59ce52..42b8071 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -193,6 +193,8 @@
 #hsr_slave1_hsr0=eth0
 #hsr_slave2_hsr0=eth1
 #hsr_supervision_hsr0=99 # Byte value
+#hsr_version_hsr0=1 # 0=2010 spec, 1=2012 spec
+#hsr_proto_hsr0=1 # 0=HSR standard, 1=Parallel Redundancy Protocol (PRP)
 
 #-
 # WIRELESS (802.11 support)



[gentoo-commits] proj/netifrc:master commit in: mk/

2023-04-16 Thread Sam James
commit: eb7d352d007d15bb577a284a2663eb58129b8db5
Author: Sam James  gentoo  org>
AuthorDate: Mon Apr 17 04:36:30 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Apr 17 04:36:30 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=eb7d352d

mk/dist.mk: use gtar for --owners

Signed-off-by: Sam James  gentoo.org>

 mk/dist.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mk/dist.mk b/mk/dist.mk
index 383826a..7404f04 100644
--- a/mk/dist.mk
+++ b/mk/dist.mk
@@ -23,12 +23,12 @@ dist:
mkdir $${D}/${DISTPREFIX} && \
git checkout-index -f -a --prefix=$${D}/${DISTPREFIX}/ && \
git log >$${D}/${DISTPREFIX}/ChangeLog && \
-   tar cjf ${DISTFILE} --owner=0 --group=0 --format=posix --mode=a+rX -C 
$$D ${DISTPREFIX} && \
+   gtar cjf ${DISTFILE} --owner=0 --group=0 --format=posix --mode=a+rX -C 
$$D ${DISTPREFIX} && \
rm -rf $$D '
 
 distcheck: dist
rm -rf ${DISTPREFIX}
-   tar xf ${DISTFILE}
+   gtar xf ${DISTFILE}
MAKEFLAGS= $(MAKE) -C ${DISTPREFIX}
MAKEFLAGS= $(MAKE) -C ${DISTPREFIX} check
rm -rf ${DISTPREFIX}
@@ -39,7 +39,7 @@ snapshot:
cp -RPp * /tmp/${SNAPDIR}
(cd /tmp/${SNAPDIR}; make clean)
find /tmp/${SNAPDIR} -name .svn -exec rm -rf -- {} \; 2>/dev/null || 
true
-   tar -cvjpf ${SNAPFILE} -C /tmp ${SNAPDIR}
+   gtar -cvjpf ${SNAPFILE} -C /tmp ${SNAPDIR}
rm -rf /tmp/${SNAPDIR}
ls -l ${SNAPFILE}
 



[gentoo-commits] proj/netifrc:master commit in: mk/

2023-04-16 Thread Sam James
commit: addb593e370c7d8fd38f3eb81e15837306d576ff
Author: Sam James  gentoo  org>
AuthorDate: Mon Apr 17 04:37:19 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Apr 17 04:37:32 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=addb593e

mk/dist.mk: use xz

Signed-off-by: Sam James  gentoo.org>

 mk/dist.mk | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mk/dist.mk b/mk/dist.mk
index 7404f04..1625d7c 100644
--- a/mk/dist.mk
+++ b/mk/dist.mk
@@ -4,18 +4,18 @@
 
 GITREF?=   HEAD
 DISTPREFIX?=   ${NAME}-${VERSION}
-DISTFILE?= ${DISTPREFIX}.tar.bz2
+DISTFILE?= ${DISTPREFIX}.tar.xz
 
-CLEANFILES+=   ${NAME}-*.tar.bz2
+CLEANFILES+=   ${NAME}-*.tar.xz
 
 _SNAP_SH=  date -u +%Y%m%d%H%M
 _SNAP:=$(shell ${_SNAP_SH})
 SNAP=  ${_SNAP}
 SNAPDIR=   ${DISTPREFIX}-${SNAP}
-SNAPFILE=  ${SNAPDIR}.tar.bz2
+SNAPFILE=  ${SNAPDIR}.tar.xz
 
 gitdist:
-   git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE}
+   git archive --prefix=${DISTPREFIX}/ ${GITREF} | xz > ${DISTFILE}
 
 dist:
sh -c ' \



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

2023-04-16 Thread Sam James
commit: f24053e64e273fb42bfab0f93b2549015ac444ea
Author: Sam James  gentoo  org>
AuthorDate: Mon Apr 17 04:36:38 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Apr 17 04:37:32 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f24053e6

Makefile.inc: crank to 0.7.4

Signed-off-by: Sam James  gentoo.org>

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index 4c65f8c..fe1eb33 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.3
+VERSION=   0.7.4
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: net/

2023-04-16 Thread Sam James
commit: a43884bca4b34b8649574fb3ea85a2a658fd0a6f
Author: Greg Kubaryk  vt  edu>
AuthorDate: Mon Apr 17 04:34:36 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Mon Apr 17 04:35:08 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=a43884bc

net/dhcpcd.sh: adapt to dhcpcd-10 versioning

Closes: https://bugs.gentoo.org/904422
Signed-off-by: Greg Kubaryk  vt.edu>
Signed-off-by: Sam James  gentoo.org>

 net/dhcpcd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1380944..6bd44ba 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -32,7 +32,7 @@ dhcpcd_start()
[ -z "${opts}" ] && opts=${dhcp}
 
case "$(dhcpcd --version | head -n 1)" in
-   "dhcpcd "[123]*)
+   "dhcpcd "[123]\.*)
eerror 'The dhcpcd version is too old. Please upgrade.'
return 1
;;



[gentoo-commits] proj/netifrc:master commit in: net/

2023-02-11 Thread Sam James
commit: 8390af35cb89002b33acea91d2b2b641f0728398
Author: Sam James  gentoo  org>
AuthorDate: Sun Feb 12 06:54:09 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Feb 12 06:54:15 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8390af35

net/arping.sh: adapt to new arping path in /usr/bin

Bug: https://bugs.gentoo.org/893290
Signed-off-by: Sam James  gentoo.org>

 net/arping.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/arping.sh b/net/arping.sh
index 7e178b7..bdd8284 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -4,7 +4,7 @@
 
 arping_depend()
 {
-   program /sbin/arping /bin/arping /usr/sbin/arping /usr/sbin/arping2
+   program /sbin/arping /bin/arping /usr/bin/arping /usr/sbin/arping 
/usr/sbin/arping2
before interface
 }
 



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-19 Thread Sam James
commit: e6db37173cb70183ee983aa1aaa5224a2f8c49c3
Author: Kerin Millar  plushkava  net>
AuthorDate: Thu Jan 19 04:47:54 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Jan 19 18:49:22 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e6db3717

net/l2tp.sh: Don't try to evaluate l2tptunnel_${IFVAR} if unset

The "restructuring" commit went one step too far by combining the test for
whether l2tptunnel_${IFVAR} is defined with the test for whether the tunnel
exists, in a way that adversely affects the outer control flow. Fix it by
nesting the latter test.

Fixes: 0b8b9b13146c1eba04f2bd8d0b2b049c03891010
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index aa8e3fd..dde86af 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -28,12 +28,14 @@ l2tp_pre_start() {
eend 1 "${key} defines a \"name\" parameter, which is forbidden 
by netifrc"
elif ! modprobe l2tp_eth; then
eend 1 "Couldn't load the l2tp_eth module (perhaps the 
CONFIG_L2TP_ETH kernel option is disabled)"
-   elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]" && ! 
_l2tp_has_tunnel "${tunnel_id}"; then
+   elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]"; then
# A tunnel may incorporate more than one session (link). This
# module allows for the user not to define a tunnel for a given
# session. In that case, it will be expected that the required
# tunnel has already been created to satisfy some other session.
-   eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be 
required)"
+   if ! _l2tp_has_tunnel "${tunnel_id}"; then
+   eend 1 "Tunnel #${tunnel_id} not found (defining ${key} 
may be required)"
+   fi
elif eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
eend 1 "${key} is defined but its value is blank"
elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local 
peer_tunnel_id remote tunnel_id" "encap"); then



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-19 Thread Sam James
commit: 46f8a90fef9d9bff21760dab52124bfbbb62e064
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jul 17 09:53:36 2021 +
Commit: Sam James  gentoo  org>
CommitDate: Thu Jan 19 18:49:25 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=46f8a90f

net/iproute2.sh: Fix two regressions in _get_mac_address

Commit 4143e26 re-introduced the ip(8) parser in the course of adding
network namespace support. In doing so, it also introduced two
regressions. Firstly, in the case that no MAC address is successfully
discerned, the function will return 0. Secondly, FF:FF:FF:FF:FF:FF is
no longer handled as a special case.

This patch, once again, does away with the ip(8) parser and, instead,
collects the address from sysfs. The _netns function is used to ensure
that the procedure is carried out within the applicable network
namespace, if necessary. In the event that the address file cannot be
read, or that it contains nothing, the function will now return 1,
which addresses the first issue. The second issue is addressed by
uppercasing the applicable case pattern.

As an aside, this patch also addresses an issue whereby sed(1) was used
to match against a pattern containing \< and \>, which are GNU-specific
extensions.

Fixes: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32
Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/iproute2.sh | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index bd7333e..ea0a6f7 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -91,17 +91,15 @@ _set_flag()
 _get_mac_address()
 {
local mac=
-   mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
-   -e 'y/abcdef/ABCDEF/' \
-   -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
+   mac=$(_netns sed -e 'y/abcdef/ABCDEF/;q' 
/sys/class/net/"${IFACE}"/address) || return
 
case "${mac}" in
-   00:00:00:00:00:00) return 1 ;;
-   44:44:44:44:44:44) return 1 ;;
-   ff:ff:ff:ff:ff:ff) return 1 ;;
-   esac
-
-   printf '%s\n' "${mac}" | LC_ALL=C tr '[:lower:]' '[:upper:]'
+   '')false ;;
+   00:00:00:00:00:00) false ;;
+   44:44:44:44:44:44) false ;;
+   FF:FF:FF:FF:FF:FF) false ;;
+   esac &&
+   printf '%s\n' "${mac}"
 }
 
 _set_mac_address()



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-17 Thread Sam James
commit: e5a46f30deedabef5c18a587db2984a314f61071
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jan 17 09:11:22 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jan 17 15:05:51 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5a46f30

net/bonding.sh: Eliminate the bashism that is pattern substitution

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/bonding.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index 1757a89..6db90fa 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -92,7 +92,7 @@ bonding_pre_start()
if [ -n "${s}" ]; then
for i in $s; do
einfo "Adding ${n}: ${i}"
-   _netns echo "+${i/+/}" \>"${x}" || \
+   _netns echo "+${i#+}" \>"${x}" || \
eerror "Failed to add $i (${n}_${IFVAR})"
done
fi



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-17 Thread Sam James
commit: 9f752fd223ce8a2539874631008d9eda83aa5ba0
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jan 17 09:25:58 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jan 17 15:06:28 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9f752fd2

net/wpa_supplicant.sh: Properly expand the number of positional parameters

${#*} is undefined behaviour. Just write it as $#.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/wpa_supplicant.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index 3f8e1b1..9f024c0 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -57,7 +57,7 @@ wpa_supplicant_pre_start()
[ -z "${cliopts}" ] && cliopts=${wpa_cli}
set -- $opts
local opt_D
-   while [ ${#*} -gt 0 ]; do
+   while [ "$#" -gt 0 ]; do
local opt=$1 ; shift
case "$opt" in
-D) opt_D=${1} ; shift ;;



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-17 Thread Sam James
commit: f9c4602fec8b4a5bb6561dbf8bbeeff8447165bc
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Jan 17 09:14:37 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue Jan 17 15:06:12 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9c4602f

net/veth.sh: Eliminate the bashism that is the == test operator

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/veth.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/veth.sh b/net/veth.sh
index 80f9a8e..e18906c 100644
--- a/net/veth.sh
+++ b/net/veth.sh
@@ -132,7 +132,7 @@ veth_pre_start()
 
local createveth
eval createveth=\$veth_${IFVAR}_create
-   if [ "$createveth" == "no" ]; then
+   if [ "$createveth" = "no" ]; then
return 0
fi
 



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-15 Thread Sam James
commit: 315341e5af9dad09ca4e5c1ff8b16e3c0fc72898
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jan 15 19:30:35 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 20:36:57 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=315341e5

net/l2tp.sh: Really favour IFACE over IFVAR in an informational message

The previous commit intended to replace an instance of IFVAR with IFACE.
Instead, it replaced with IFNAME, which means nothing to netifrc.
Frustratingly, I had realised my error at the time of submitting the patch,
yet still managed to attach a bad one. Make it right.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 2221d26..aa8e3fd 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -39,7 +39,7 @@ l2tp_pre_start() {
elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local 
peer_tunnel_id remote tunnel_id" "encap"); then
eend 1 "${key} is missing at least one required parameter"
elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != 
"${tunnel_id}" ]; then
-   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFNAME}"
+   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFACE:?}"
elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set 
-- $?; [ "$1" -eq 2 ]; then
eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch 
those defined by ${key}"
elif [ "$1" -eq 1 ]; then



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-15 Thread Sam James
commit: 735b7e1b920874fe2f588f5b9385ff40d33c48c2
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jan 15 06:09:40 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 14:03:29 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=735b7e1b

net/l2tp.sh: Favour IFACE over IFVAR in an informational message

IFVAR is (supposed to be) requoted for injection, so it doesn't make any sense
to expand it within the second argument given to eend.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index ad459df..2221d26 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -39,7 +39,7 @@ l2tp_pre_start() {
elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local 
peer_tunnel_id remote tunnel_id" "encap"); then
eend 1 "${key} is missing at least one required parameter"
elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != 
"${tunnel_id}" ]; then
-   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFVAR}"
+   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFNAME}"
elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set 
-- $?; [ "$1" -eq 2 ]; then
eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch 
those defined by ${key}"
elif [ "$1" -eq 1 ]; then



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-15 Thread Sam James
commit: 0b8b9b13146c1eba04f2bd8d0b2b049c03891010
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jan 15 05:41:10 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 14:03:10 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0b8b9b13

net/l2tp.sh: Slightly improve the structure of l2tp_pre_start()

Restructure so as to avoid an unnecessary level of indentation. The behaviour
of the function remains the same.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 52b5733..ad459df 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -28,32 +28,30 @@ l2tp_pre_start() {
eend 1 "${key} defines a \"name\" parameter, which is forbidden 
by netifrc"
elif ! modprobe l2tp_eth; then
eend 1 "Couldn't load the l2tp_eth module (perhaps the 
CONFIG_L2TP_ETH kernel option is disabled)"
-   elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
-   if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
-   eend 1 "${key} is defined but its value is blank"
-   elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" 
"local peer_tunnel_id remote tunnel_id" "encap"); then
-   eend 1 "${key} is missing at least one required 
parameter"
-   elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" 
!= "${tunnel_id}" ]; then
-   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFVAR}"
-   elif _l2tp_should_add_tunnel "${tunnel_id}" 
"${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
-   eend 1 "Tunnel #${tunnel_id} exists but its properties 
mismatch those defined by ${key}"
-   elif [ "$1" -eq 1 ]; then
-   # The config matches an existing tunnel.
-   true
-   elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
-   eend 1 "Couldn't load the l2tp_ip module (perhaps the 
CONFIG_L2TP_IP kernel option is disabled)"
-   else
-   ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
-   printf %s "l2tp add tunnel ${l2tptunnel}" \
-   | xargs -E '' ip
-   eend $?
-   fi
-   elif ! _l2tp_has_tunnel "${tunnel_id}"; then
+   elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]" && ! 
_l2tp_has_tunnel "${tunnel_id}"; then
# A tunnel may incorporate more than one session (link). This
# module allows for the user not to define a tunnel for a given
# session. In that case, it will be expected that the required
# tunnel has already been created to satisfy some other session.
eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be 
required)"
+   elif eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
+   eend 1 "${key} is defined but its value is blank"
+   elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local 
peer_tunnel_id remote tunnel_id" "encap"); then
+   eend 1 "${key} is missing at least one required parameter"
+   elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" != 
"${tunnel_id}" ]; then
+   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFVAR}"
+   elif _l2tp_should_add_tunnel "${tunnel_id}" "${declared_tunnel}"; set 
-- $?; [ "$1" -eq 2 ]; then
+   eend 1 "Tunnel #${tunnel_id} exists but its properties mismatch 
those defined by ${key}"
+   elif [ "$1" -eq 1 ]; then
+   # The config matches an existing tunnel.
+   true
+   elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
+   eend 1 "Couldn't load the l2tp_ip module (perhaps the 
CONFIG_L2TP_IP kernel option is disabled)"
+   else
+   ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
+   printf %s "l2tp add tunnel ${l2tptunnel}" \
+   | xargs -E '' ip
+   eend $?
fi || return
 
ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id 
${tunnel_id})"



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-14 Thread Sam James
commit: bd50c2ce076f2a6a5b0f884287a7940cd29cc6db
Author: 7e3f <122086774+7e3f  users  noreply  github  
com>
AuthorDate: Fri Jan  6 10:20:09 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 01:52:46 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bd50c2ce

net/macchanger.sh: Update path to macchanger to /usr

Proposing changes in diff from bug #889922, net-analyzer/macchanger-1.7.0_p5_p4
to net-analyzer/macchanger-1.7.0_p5_p4-r1 changed softlink and binary location 
due
to #886121.

There was a temporary tidy up in net-analyzer/macchanger-1.7.0_p5_p4-r2, but
proposing macchanger.sh change to allow netifrc to work with macchanger
binary location.

Bug: https://bugs.gentoo.org/886121
Bug: https://bugs.gentoo.org/889922
Closes: https://github.com/gentoo/netifrc/pull/42
Signed-off-by: Sam James  gentoo.org>

 net/macchanger.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/macchanger.sh b/net/macchanger.sh
index d87d96e..5b32b80 100644
--- a/net/macchanger.sh
+++ b/net/macchanger.sh
@@ -64,7 +64,7 @@ macchanger_pre_start()
*) opts="${opts} -m ${mac}";;
esac
 
-   if [ ! -x /sbin/macchanger ]; then
+   if [ ! -x /usr/bin/macchanger ]; then
eerror "For changing MAC addresses, emerge 
net-analyzer/macchanger"
return 1
fi
@@ -72,7 +72,7 @@ macchanger_pre_start()
for try in 1 2; do
# Sometimes the interface needs to be up
[ "${try}" -eq 2 ] && _up
-   output=$(/sbin/macchanger ${opts} "${IFACE}")
+   output=$(/usr/bin/macchanger ${opts} "${IFACE}")
rc=$?
[ "${rc}" -eq 0 ] && break
done



[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-14 Thread Sam James
commit: 1601d0dbed5d0373f0e19f90f07612bf60c59184
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jan 14 22:58:41 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 01:51:20 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1601d0db

net/l2tp.sh: Rewrite to address issues of POSIX conformance (and more besides)

Ensure that awk(1) is used portably throughout.

Eliminate the use of ${parameter^^} expansion syntax, which is a bashism.

Delegate netfirc parameter parsing to xargs(1) and awk(1). The potential for
code injection is thus eliminated, to the extent that is currently possible in
netifrc. It also eliminates potential issues pertaining to word splitting and
unintentional pathname expansion.

Add additional sanity checks and increase the rigour of those that exist. For
instance, blank values are no longer permitted and the tunnel_id parameter must
match that of l2tpsession_*, in the case that l2tptunnel_* is defined.

Add additional diagnostic messages while improving the clarity of those that
already existed. This is achieved in some instances by being more precise and,
in others, through the use of English that exhibits greater formality and
consistency. At least one grammatical error was rectified.

Simplify and refine the code in terms of both structure and syntax, and greatly
reduce the number of (local) variables. As a byproduct, all complaints 
previously
raised by shellcheck have been eliminated, save for the use of local, whose
behaviour is not defined by POSIX. I have not attempted to eliminate the use of
local because, for now, it continues to be used extensively throughout the
netifrc codebase.

Honour the exit status value of ip(8) for the "add" and "del" verbs, rather
than parse STDERR.

Optimise l2tp_post_stop() by refraining from executing ip(8) and awk(8) in the
case that the interface cannot be identifed as a virtual one. Further, do not
attempt to destroy the tunnels associated with an identified session in the
case that the attempt to destroy the session has failed.

Signed-off-by: Kerin Millar  plushkava.net>
Bug: https://bugs.gentoo.org/890238
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 349 +++-
 1 file changed, 206 insertions(+), 143 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 82649b9..51a2331 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -1,6 +1,11 @@
 # Copyright (c) 2016 Emeric Verschuur 
+# Copyright (c) 2023 Kerin Millar 
 # All rights reserved. Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
+
+# Don't complain about local, even though POSIX does not define its behaviour.
+# This is unwise but, as things stand, it is being used extensively by netifrc.
+# Also, SC2034 and SC2316 are muted because they produce false-positives.
+# shellcheck shell=sh disable=SC3043,SC2034,SC2316
 
 l2tp_depend()
 {
@@ -8,166 +13,224 @@ l2tp_depend()
before bridge interface macchanger
 }
 
-# Extract parameter list to shell vars
-#   1. variable prefix
-#   2. string to parse
-_l2tp_eval_props() {
-   local prop_pref=$1
-   local prop_list=$2
-   eval set -- "$3"
-   while [ -n "$1" ]; do
-   eval "case $1 in
-   $prop_list)
-   $prop_pref$1=\"$2\"
-   shift
-   shift
-   ;;
-   *)
-   l2tp_err=\"invalid property $1\"
-   return 1
-   ;;
-   
-   esac" || return 1
-   done
-   return 0
+_l2tp_parse_opts()
+{
+   # Parses lt2psession or l2tptunnel options using xargs(1), conveying
+   # them as arguments to awk(1). The awk program interprets the arguments
+   # as a series of key/value pairs and safely prints those specified as
+   # being required as variable declarations for evaluation by sh(1).
+   # Other keys are handled similarly, only in a way that renders them a
+   # no-op. For the program to exit successfully, all key names must be
+   # well-formed, all required keys must be seen, and all values must be
+   # non-blank. Note that assigning 1 to ARGC prevents awk from treating
+   # its arguments as the names of files to be opened.
+   printf %s "$1" \
+   | LC_CTYPE=C xargs -E '' awk -v q="'" -v required_keys="$2" -v 
other_keys="$3" '
+   function shquote(str) {
+   gsub(q, q "\\" q q, str)
+   return q str q
+   }
+   BEGIN {
+   argc = ARGC
+   ARGC = 1
+   gsub(" ", "|", required_keys)
+   gsub(" ", "|", other_keys)
+   re = "^(" required_keys "|" other_keys ")$"
+   

[gentoo-commits] proj/netifrc:master commit in: net/

2023-01-14 Thread Sam James
commit: b6c67a56b566b0a178fc8eb7cac761e0f6521356
Author: Kerin Millar  plushkava  net>
AuthorDate: Sat Jan 14 23:04:46 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sun Jan 15 01:51:26 2023 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b6c67a56

net/l2tp.sh: Re-order function declarations and use a consistent brace style

This is how I would initially have submitted it, only I wanted for the initial
set of changes to be legible as a unified diff.

Signed-off-by: Kerin Millar  plushkava.net>
Bug: https://bugs.gentoo.org/890238
Signed-off-by: Sam James  gentoo.org>

 net/l2tp.sh | 168 +---
 1 file changed, 82 insertions(+), 86 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 51a2331..52b5733 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -7,14 +7,92 @@
 # Also, SC2034 and SC2316 are muted because they produce false-positives.
 # shellcheck shell=sh disable=SC3043,SC2034,SC2316
 
-l2tp_depend()
-{
+l2tp_depend() {
program ip
before bridge interface macchanger
 }
 
-_l2tp_parse_opts()
-{
+l2tp_pre_start() {
+   local declared_session declared_tunnel l2tpsession l2tptunnel
+   local name peer_session_id session_id tunnel_id
+   local encap local peer_tunnel_id remote
+   local key
+
+   if key="l2tpsession_${IFVAR:?}"; ! eval "[ \${${key}+set} ]"; then
+   return
+   elif eval "l2tpsession=\$${key}"; _is_blank "${l2tpsession}"; then
+   eend 1 "${key} is defined but its value is blank"
+   elif ! declared_session=$(_l2tp_parse_opts "${l2tpsession}" 
"peer_session_id session_id tunnel_id" "name"); then
+   eend 1 "${key} is missing at least one required parameter"
+   elif eval "${declared_session}"; [ "${name+set}" ]; then
+   eend 1 "${key} defines a \"name\" parameter, which is forbidden 
by netifrc"
+   elif ! modprobe l2tp_eth; then
+   eend 1 "Couldn't load the l2tp_eth module (perhaps the 
CONFIG_L2TP_ETH kernel option is disabled)"
+   elif key="l2tptunnel_${IFVAR}"; eval "[ \${${key}+set} ]"; then
+   if eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
+   eend 1 "${key} is defined but its value is blank"
+   elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" 
"local peer_tunnel_id remote tunnel_id" "encap"); then
+   eend 1 "${key} is missing at least one required 
parameter"
+   elif set -- "${tunnel_id}"; eval "${declared_tunnel}"; [ "$1" 
!= "${tunnel_id}" ]; then
+   eend 1 "${key} defines a \"tunnel_id\" parameter that 
contradicts l2tpsession_${IFVAR}"
+   elif _l2tp_should_add_tunnel "${tunnel_id}" 
"${declared_tunnel}"; set -- $?; [ "$1" -eq 2 ]; then
+   eend 1 "Tunnel #${tunnel_id} exists but its properties 
mismatch those defined by ${key}"
+   elif [ "$1" -eq 1 ]; then
+   # The config matches an existing tunnel.
+   true
+   elif [ "${encap}" = ip ] && ! modprobe l2tp_ip; then
+   eend 1 "Couldn't load the l2tp_ip module (perhaps the 
CONFIG_L2TP_IP kernel option is disabled)"
+   else
+   ebegin "Creating L2TPv3 tunnel (tunnel_id ${tunnel_id})"
+   printf %s "l2tp add tunnel ${l2tptunnel}" \
+   | xargs -E '' ip
+   eend $?
+   fi
+   elif ! _l2tp_has_tunnel "${tunnel_id}"; then
+   # A tunnel may incorporate more than one session (link). This
+   # module allows for the user not to define a tunnel for a given
+   # session. In that case, it will be expected that the required
+   # tunnel has already been created to satisfy some other session.
+   eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be 
required)"
+   fi || return
+
+   ebegin "Creating L2TPv3 session (session_id ${session_id} tunnel_id 
${tunnel_id})"
+   printf %s "l2tp add session ${l2tpsession} name ${IFACE:?}" \
+   | xargs -E '' ip && _up
+   eend $?
+}
+
+l2tp_post_stop() {
+   local existing_session session_id tunnel_id
+
+   # This function may be invoked for every interface. If not a virtual
+   # interface, it can't possibly be one that's managed by this module, in
+   # which case running ip(8) and awk(1) would be a needless expense.
+   [ -e /sys/devices/virtual/net/"${IFACE:?}" ] \
+   && existing_session=$(_l2tp_parse_existing_session 2>/dev/null) \
+   || return 0
+
+   eval "${existing_session}"
+   set -- session_id "${session_id}" tunnel_id "${tunnel_id}"
+   ebegin "Destroying L2TPv3 session ($*)"
+   ip l2tp del session "$@"
+   eend $? &&
+   if ! _l2tp_in_session "${tunnel_id}"; then
+   shift 2

[gentoo-commits] proj/netifrc:master commit in: net/

2022-12-25 Thread Robin H. Johnson
commit: d877a5aa5b105b17ced7be467fb4412a9ddd05aa
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Dec 25 19:14:04 2022 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Dec 25 19:14:04 2022 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=d877a5aa

net/hsr: add Parallel Redundancy Protocol (PRP) support

Signed-off-by: Robin H. Johnson  gentoo.org>
Reference: https://github.com/gentoo/netifrc/pull/38

 net/hsr.sh | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/hsr.sh b/net/hsr.sh
index f5a427f..cbe35e9 100644
--- a/net/hsr.sh
+++ b/net/hsr.sh
@@ -21,6 +21,8 @@ hsr_pre_start()
eval hsr_slave1=\$hsr_slave1_${IFVAR}
eval hsr_slave2=\$hsr_slave2_${IFVAR}
eval hsr_supervision=\$hsr_supervision_${IFVAR}
+   eval hsr_version=\$hsr_version_${IFVAR}
+   eval hsr_proto=\$hsr_proto_${IFVAR}
if [ -z "${hsr_slave1}" ] || [ -z "${hsr_slave2}" ]; then
eerror "HSR interfaces require two slave interfaces to be set"
return 1
@@ -35,7 +37,10 @@ hsr_pre_start()
fi
 
ebegin "Creating HSR interface ${IFACE}"
-   cmd="ip link add name "${IFACE}" type hsr slave1 ${hsr_slave1} slave2 
${hsr_slave2} ${hsr_supervision:+supervision }${hsr_supervision}"
+   cmd="ip link add name "${IFACE}" type hsr slave1 ${hsr_slave1} slave2 
${hsr_slave2}"
+   test -n "${hsr_supervision}" && cmd="${cmd} supervision 
${hsr_supervision}"
+   test -n "${hsr_version}" && cmd="${cmd} version ${hsr_version}"
+   test -n "${hsr_proto}" && cmd="${cmd} proto ${hsr_proto}"
veinfo $cmd
if $cmd ; then
eend 0 && _up && set_interface_type hsr



[gentoo-commits] proj/netifrc:master commit in: net/

2022-12-25 Thread Robin H. Johnson
commit: bd8ff4aa89e1d56e9886dad32bb2406c8f43c747
Author: kmartin36  gtri  gatech  edu>
AuthorDate: Sat Dec 17 08:26:21 2022 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Dec 25 19:06:36 2022 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bd8ff4aa

Adding the saved args to the stop command

Closes: https://bugs.gentoo.org/881039
Signed-off-by: Kevin Martin  gmail.com>
(cherry picked from commit 0e1c19959a6d82accdb57fa7a1f5b0036037a001)
Signed-off-by: Robin H. Johnson  gentoo.org>
Closes: https://github.com/gentoo/netifrc/pull/41

 net/dhcpcd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1e1bbe0..1380944 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -90,8 +90,8 @@ dhcpcd_stop()
eval opts=\$dhcp_${IFVAR}
[ -z "${opts}" ] && opts=${dhcp}
case " ${opts} " in
-   *" release "*) dhcpcd -k "${IFACE}" ;;
-   *) dhcpcd -x "${IFACE}" ;;
+   *" release "*) dhcpcd -k "${args}" "${IFACE}" ;;
+   *) dhcpcd -x "${args}" "${IFACE}" ;;
esac
[ -f "${argsfile}" ] && rm -f "${argsfile}"
eend $?



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

2021-04-05 Thread Robin H. Johnson
commit: 0dc79645173fad82e0d437a6569b7ea7fa356197
Author: Arseni Nimera  yandex  by>
AuthorDate: Sat May 30 22:20:25 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 07:28:27 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=0dc79645

Added macvtap support

Bug: https://bugs.gentoo.org/691372
Signed-off-by: Arseni Nimera  yandex.by>

 doc/net.example.Linux.in | 3 +++
 net/macvlan.sh   | 8 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 8896acf..f169670 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -664,6 +664,9 @@
 # MAC-VLAN mode (private, vepa, bridge, passtru)
 #mode_macvlan0="private"
 
+# MAC-VLAN type (macvlan, macvtap)
+#type_macvlan0="macvtap"
+
 # IP address, MAC address, ... are configured as a normal interface
 #config_macvlan0="192.168.20.20/24"
 #mac_macvlan0="00:50:06:20:20:20"

diff --git a/net/macvlan.sh b/net/macvlan.sh
index 8d55717..6243858 100644
--- a/net/macvlan.sh
+++ b/net/macvlan.sh
@@ -34,8 +34,12 @@ macvlan_pre_start()
eval mode=\$mode_${IFVAR}
[ -z "${mode}" ] && mode="private"
 
+   local type=
+   eval type=\$type_${IFVAR}
+   [ -z "${type}" ] && type="macvlan"
+
ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}"
-   e="$(ip link add link "${macvlan}" name "${IFACE}" type macvlan mode 
"${mode}" 2>&1 1>/dev/null)"
+   e="$(ip link add link "${macvlan}" name "${IFACE}" type "${type}" mode 
"${mode}" 2>&1 1>/dev/null)"
if [ -n "${e}" ]; then
eend 1 "${e}"
else
@@ -49,6 +53,6 @@ macvlan_post_stop()
_is_macvlan || return 0
 
ebegin "Removing MAC-VLAN ${IFACE}"
-   ip link delete "${IFACE}" type macvlan >/dev/null
+   ip link delete "${IFACE}" >/dev/null
eend $?
 }



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

2021-04-05 Thread Robin H. Johnson
commit: e860f40ffd07a41e47a6b49d9400ad20e6a8b7ca
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Apr  5 20:01:29 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Apr  5 20:01:29 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e860f40f

Merge remote-tracking branch 'github/pr/32'

Closes: https://github.com/gentoo/netifrc/pull/32
Signed-off-by: Robin H. Johnson  gentoo.org>




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

2021-04-05 Thread Robin H. Johnson
commit: 4bd8be5f43d07a9e92b73174c7fbef8b989aaa55
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Apr  5 19:54:47 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Apr  5 20:00:28 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4bd8be5f

net/ethtool: support more ethtool config knobs

Additional options now supported:
--set-channels
--set-dump
--set-fec
--set-phy-tunable
--set-priv-flags
--set-rxfh-indir
--per-queue
--features

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

 doc/net.example.Linux.in |  6 +++---
 net/ethtool.sh   | 15 +--
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index b2c0f82..e59ce52 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1318,10 +1318,10 @@
 # flash change-eeprom change pause eee coalesce ring offload tunable identify 
nfc rxfh-indir ntuple
 
 # Set global order to default
-#ethtool_order="flash change-eeprom change pause eee coalesce ring offload 
tunable identify nfc rxfh-indir ntuple"
+#ethtool_order="flash change-eeprom change priv-flags channels dump pause eee 
fec coalesce per-queue ring offload features phy-tunable tunable identify nfc 
rxfh-indir ntuple"
 
-# Hypothetical network card that requires a change-eeprom toggle to enable 
flashing
-#ethtool_order_eth0="change-eeprom flash change pause eee coalesce ring 
offload tunable nfc rxfh-indir ntuple"
+# Hypothetical network card that requires a change-eeprom or priv-flags toggle 
to enable flashing
+#ethtool_order_eth0="priv-flags change-eeprom flash channels dump pause eee 
fec coalesce per-queue ring offload features phy-tunable tunable identify nfc 
rxfh-indir ntuple"
 
 #-
 # Firewalld support

diff --git a/net/ethtool.sh b/net/ethtool.sh
index 0bcceff..ee595a2 100644
--- a/net/ethtool.sh
+++ b/net/ethtool.sh
@@ -17,7 +17,7 @@ ethtool_pre_start() {
local order opt OFS="${OIFS}"
eval order=\$ethtool_order_${IFVAR}
[ -z "${order}" ] && eval order=\$ethtool_order
-   [ -z "${order}" ] && order="flash change-eeprom change pause eee 
coalesce ring offload tunable identify nfc rxfh-indir ntuple"
+   [ -z "${order}" ] && order="flash change-eeprom change priv-flags 
channels dump pause eee fec coalesce per-queue ring offload features 
phy-tunable tunable identify nfc rxfh-indir ntuple"
# ethtool options not used: --driver, --register-dump, --eeprom-dump, 
--negotiate, --test, --statistics
eindent
for opt in ${order} ; do
@@ -36,7 +36,18 @@ ethtool_pre_start() {
local args_pretty="$(_trim "${p}")"
# Do nothing if empty
[ -z "${args_pretty}" ] && continue
-   [ "${opt}" = "eee" -o "${opt}" = "ring" -o "${opt}" = 
"tunable" ] && opt="set-${opt}"
+   case "$opt" in
+   # Cleaner to patch in future for new options
+   channels) opt="set-${opt}" ;;
+   dump) opt="set-${opt}" ;;
+   eee) opt="set-${opt}" ;;
+   fec) opt="set-${opt}" ;;
+   phy-tunable) opt="set-${opt}" ;;
+   priv-flags) opt="set-${opt}" ;;
+   ring) opt="set-${opt}" ;;
+   rxfh-indir) opt="set-${opt}" ;;
+   tunable) opt="set-${opt}" ;;
+   esac
args_pretty="--${opt} $IFACE ${args_pretty}"
args="--${opt} $IFACE ${args}"
ebegin "ethtool ${args_pretty}"



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

2021-04-05 Thread Robin H. Johnson
commit: 4abb45240570e754dc17106302b714b4d7de3da5
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Mon Apr  5 19:59:55 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Mon Apr  5 19:59:55 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4abb4524

Merge remote-tracking branch 'github/pr/36'

Closes: https://github.com/gentoo/netifrc/pull/36
Signed-off-by: Robin H. Johnson  gentoo.org>

 doc/net.example.Linux.in | 14 ++
 net/ethtool.sh   |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)



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

2021-04-05 Thread Robin H. Johnson
commit: b8373edc844297fb54333ffab69d0cd0a7b5e0b8
Author: Maciej S. Szmigiero  maciej  szmigiero  name>
AuthorDate: Sat Mar 27 22:32:35 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Mar 27 22:34:02 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b8373edc

net/ethtool.sh: add "eee" and "tunable" setting operations

This adds an ability to set "eee" and "tunable" ethtool parameters of a
network interface.

Signed-off-by: Maciej S. Szmigiero  maciej.szmigiero.name>

 doc/net.example.Linux.in | 12 +---
 net/ethtool.sh   |  4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 3bd2ee1..b2c0f82 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1275,12 +1275,18 @@
 #ethtool_pause_eth0="autoneg off
 #rx on tx on"
 
+# Enable Energy-Efficient Ethernet
+#ethtool_eee_eth0="eee on"
+
 # Enable adaptive RX and TX coalescing
 #ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on"
 
 # Change ring buffer settings
 #ethtool_ring_eth0=""
 
+# Set RX copy-break at 1500 bytes
+#ethtool_tunable_eth0="rx-copybreak 1500"
+
 # Enable all offload settings
 #ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on"
 
@@ -1309,13 +1315,13 @@
 
 # Additionally, there is a special control variable, if you need to change the
 # order of option processing. The default order is:
-# flash change-eeprom change pause coalesce ring offload identify nfc 
rxfh-indir ntuple
+# flash change-eeprom change pause eee coalesce ring offload tunable identify 
nfc rxfh-indir ntuple
 
 # Set global order to default
-#ethtool_order="flash change-eeprom change pause coalesce ring offload 
identify nfc rxfh-indir ntuple"
+#ethtool_order="flash change-eeprom change pause eee coalesce ring offload 
tunable identify nfc rxfh-indir ntuple"
 
 # Hypothetical network card that requires a change-eeprom toggle to enable 
flashing
-#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload 
nfc rxfh-indir ntuple"
+#ethtool_order_eth0="change-eeprom flash change pause eee coalesce ring 
offload tunable nfc rxfh-indir ntuple"
 
 #-
 # Firewalld support

diff --git a/net/ethtool.sh b/net/ethtool.sh
index 57c98f7..0bcceff 100644
--- a/net/ethtool.sh
+++ b/net/ethtool.sh
@@ -17,7 +17,7 @@ ethtool_pre_start() {
local order opt OFS="${OIFS}"
eval order=\$ethtool_order_${IFVAR}
[ -z "${order}" ] && eval order=\$ethtool_order
-   [ -z "${order}" ] && order="flash change-eeprom change pause coalesce 
ring offload identify nfc rxfh-indir ntuple"
+   [ -z "${order}" ] && order="flash change-eeprom change pause eee 
coalesce ring offload tunable identify nfc rxfh-indir ntuple"
# ethtool options not used: --driver, --register-dump, --eeprom-dump, 
--negotiate, --test, --statistics
eindent
for opt in ${order} ; do
@@ -36,7 +36,7 @@ ethtool_pre_start() {
local args_pretty="$(_trim "${p}")"
# Do nothing if empty
[ -z "${args_pretty}" ] && continue
-   [ "${opt}" = "ring" ] && opt="set-ring"
+   [ "${opt}" = "eee" -o "${opt}" = "ring" -o "${opt}" = 
"tunable" ] && opt="set-${opt}"
args_pretty="--${opt} $IFACE ${args_pretty}"
args="--${opt} $IFACE ${args}"
ebegin "ethtool ${args_pretty}"



[gentoo-commits] proj/netifrc:master commit in: doc/

2021-04-05 Thread Robin H. Johnson
commit: bcfa92b5e7c4c1f7455dac1e49f7cfab633544bf
Author: Maciej S. Szmigiero  maciej  szmigiero  name>
AuthorDate: Sat Mar 27 22:29:02 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Mar 27 22:29:02 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=bcfa92b5

doc/net.example.Linux: fix typo in "ethtool_coalesce_eth0" description

Signed-off-by: Maciej S. Szmigiero  maciej.szmigiero.name>

 doc/net.example.Linux.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 427b2da..3bd2ee1 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1275,7 +1275,7 @@
 #ethtool_pause_eth0="autoneg off
 #rx on tx on"
 
-# Enasble adaptive RX and TX coalescing
+# Enable adaptive RX and TX coalescing
 #ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on"
 
 # Change ring buffer settings



[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: net/

2021-03-30 Thread Patrick McLean
commit: 4143e26dd4a56c08fbb99e18913eaafaf2a04f32
Author: Patrick McLean  gentoo  org>
AuthorDate: Wed Mar 31 01:07:57 2021 +
Commit: Patrick McLean  gentoo  org>
CommitDate: Wed Mar 31 01:11:03 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=4143e26d

net/iproute2.sh: in _get_mac_address, don't return multiple addresses

Currently if a device has virtual functions configured, ip will list the mac
addresses for the virtual functions on a device as well as the device itself.
This makes _get_mac_address return these addresses as well, causing functions
that consume this output to fail in "interesting" ways. This makes sure it only
returns 1 address.

Also don't set the mac variable to the address of the interface from sysfs, then
proceed to overwrite it with a call to "ip".

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

 net/iproute2.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 46f0e48..bd7333e 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -91,10 +91,9 @@ _set_flag()
 _get_mac_address()
 {
local mac=
-   read -r mac < /sys/class/net/"${IFACE}"/address || return 1
-   local mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
+   mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
-e 'y/abcdef/ABCDEF/' \
-   -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+   -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p' | head -n1)
 
case "${mac}" in
00:00:00:00:00:00) return 1 ;;



[gentoo-commits] proj/netifrc:master commit in: sh/

2021-03-24 Thread Patrick McLean
commit: 7ff5d213660e5df80aba8782e5cfe4373416ed86
Author: Patrick McLean  gentoo  org>
AuthorDate: Thu Mar 25 00:42:40 2021 +
Commit: Patrick McLean  gentoo  org>
CommitDate: Thu Mar 25 00:45:41 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7ff5d213

functions.sh: Fix non-netns case for ip command

Attempt to wrap ip commands with a netns would fail sometimes when
there is no netns defined. This fixes to not use the variable when
it is not needed.

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

 sh/functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sh/functions.sh b/sh/functions.sh
index d4a514b..96df289 100644
--- a/sh/functions.sh
+++ b/sh/functions.sh
@@ -164,7 +164,7 @@ _netns()
case "${1}" in
ip)
shift
-   "${ip}" "${@}"
+   ip "${@}"
;;
glob)
shift



[gentoo-commits] proj/netifrc:master commit in: net/

2021-03-11 Thread Lars Wendler
commit: 2eca000593194ef3bcf099b8bb1003bb5ea4292f
Author: Patrick McLean  gentoo  org>
AuthorDate: Sat Nov 21 06:52:48 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Thu Mar 11 16:53:33 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2eca0005

net/bonding.sh: Add support for network namespaces

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

 net/bonding.sh | 57 +++--
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/net/bonding.sh b/net/bonding.sh
index 880f69b..1757a89 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -12,13 +12,18 @@ bonding_depend()
if [ ! -d /sys/class/net ]; then
program /sbin/ifenslave
fi
+
+   local netns
+   eval netns="\$netns_${IFVAR}"
+   [ -n "${netns}" ] && program ip
+   return 0
 }
 
 _config_vars="$_config_vars slaves"
 
 _is_bond()
 {
-   [ -f "/proc/net/bonding/${IFACE}" ]
+   _netns [ -f "/proc/net/bonding/${IFACE}" ]
 }
 
 bonding_pre_start()
@@ -52,7 +57,7 @@ bonding_pre_start()
# We can create the interface name we like now, but this
# requires sysfs
if ! _exists && [ -d /sys/class/net ]; then
-   echo "+${IFACE}" > /sys/class/net/bonding_masters
+   _netns echo "+${IFACE}" \> /sys/class/net/bonding_masters
fi
_exists true || return 1
 
@@ -68,13 +73,13 @@ bonding_pre_start()
# we configure all other options
# mode needs to be done before all other options.
# miimon needs to be done BEFORE downdelay
-   [ -d /sys/class/net ] && for n in mode miimon; do
+   _netns [ -d /sys/class/net ] && for n in mode miimon; do
x=/sys/class/net/"${IFACE}"/bonding/$n
-   [ -f "${x}" ] || continue
+   _netns [ -f "${x}" ] || continue
eval s=\$${n}_${IFVAR}
if [ -n "${s}" ]; then
einfo "Setting ${n}: ${s}"
-   echo "${s}" >"${x}" || \
+   _netns echo "${s}" \>"${x}" || \
eerror "Failed to configure $n (${n}_${IFVAR})"
fi
done
@@ -82,19 +87,19 @@ bonding_pre_start()
# With a leading '+' as a prefix.
n=arp_ip_target
x=/sys/class/net/"${IFACE}"/bonding/$n
-   [ -d /sys/class/net ] && if [ -f "$x" ]; then
+   _netns [ -d /sys/class/net ] && if _netns [ -f "$x" ]; then
eval s=\$${n}_${IFVAR}
if [ -n "${s}" ]; then
for i in $s; do
einfo "Adding ${n}: ${i}"
-   echo "+${i/+/}" >"${x}" || \
+   _netns echo "+${i/+/}" \>"${x}" || \
eerror "Failed to add $i (${n}_${IFVAR})"
done
fi
fi
# Nice and dynamic for remaining options:)
-   [ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/*; 
do
-   [ -f "${x}" ] || continue
+   _netns [ -d /sys/class/net ] && for x in $(_netns glob 
/sys/class/net/"${IFACE}"/bonding/\*); do
+   _netns [ -f "${x}" ] || continue
n=${x##*/}
# These entries are already handled above.
case "$n" in
@@ -106,7 +111,7 @@ bonding_pre_start()
eval s=\$${n}_${IFVAR}
if [ -n "${s}" ]; then
einfo "Setting ${n}: ${s}"
-   echo "${s}" >"${x}" || \
+   _netns echo "${s}" \>"${x}" || \
eerror "Failed to configure $n (${n}_${IFVAR})"
fi
done
@@ -145,9 +150,9 @@ bonding_pre_start()
unset oiface
eoutdent
# subsume (presumably kernel auto-)configured IP
-   if [ -x "$(command -v ip)" ]; then
-   ip link set ${IFACE} up
-   ip address add ${addr} dev ${IFACE}
+   if [ -x "$(command -v ip 2>/dev/null)" ]; then
+   _netns ip link set ${IFACE} up
+   _netns ip address add ${addr} dev ${IFACE}
else
ifconfig ${IFACE} ${addr} up
fi
@@ -171,7 +176,7 @@ bonding_pre_start()
# set mtu: ifenslave, kernel
# set slave MAC: ifenslave, kernel
eoutdent
-   if [ -d /sys/class/net ]; then
+   if _netns [ -d /sys/class/net ]; then
sys_bonding_path=/sys/class/net/"${IFACE}"/bonding
local oiface
oiface=$IFACE
@@ -179,20 +184,20 @@ bonding_pre_start()
IFACE=$primary
_down
IFACE=$oiface
-   echo "+${primary}" >$sys_bonding_path/slaves
-   echo "${primary}" >$sys_bonding_path/primary
+ 

[gentoo-commits] proj/netifrc:master commit in: net/

2021-03-11 Thread Lars Wendler
commit: b581c3f76b95bd2173a13d08054120f284ac06e7
Author: Patrick McLean  gentoo  org>
AuthorDate: Sat Nov 21 06:53:31 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Thu Mar 11 16:53:33 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b581c3f7

net/bridge.sh: Add support for network namespaces when using iproute2

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

 net/bridge.sh | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/bridge.sh b/net/bridge.sh
index 4166215..a380f6a 100644
--- a/net/bridge.sh
+++ b/net/bridge.sh
@@ -12,19 +12,19 @@ _config_vars="$_config_vars bridge bridge_add brctl"
 
 _is_bridge()
 {
-   [ -d /sys/class/net/"${1:-${IFACE}}"/bridge ]
+   _netns [ -d /sys/class/net/"${1:-${IFACE}}"/bridge ]
return $?
 }
 
 _is_bridge_port()
 {
-   [ -d /sys/class/net/"${1:-${IFACE}}"/brport ]
+   _netns [ -d /sys/class/net/"${1:-${IFACE}}"/brport ]
return $?
 }
 
 _bridge_ports()
 {
-   for x in /sys/class/net/"${1:-${IFACE}}"/brif/*; do
+   for x in $(_netns glob /sys/class/net/"${1:-${IFACE}}"/brif/\*); do
n=${x##*/}
echo $n
done
@@ -82,7 +82,7 @@ bridge_pre_start()
if ! _is_bridge ; then
ebegin "Creating bridge ${IFACE}"
if ${do_iproute2}; then
-   ip link add "${IFACE}" type bridge
+   _netns ip link add "${IFACE}" type bridge
rc=$?
elif ${do_brctl}; then
brctl addbr "${IFACE}"
@@ -123,7 +123,7 @@ bridge_pre_start()
fi
 
# New configuration set mechanism, matches bonding
-   for x in /sys/class/net/"${IFACE}"/bridge/*; do
+   for x in $(_netns glob /sys/class/net/"${IFACE}"/bridge/\*); do
[ -f "${x}" ] || continue
n=${x##*/}
# keep no prefix for backward compatibility
@@ -132,7 +132,7 @@ bridge_pre_start()
if [ -n "${s}" ]; then
[ -z "${prefix}" ] && ewarn "sysfs key 
'${n}_${IFVAR}' should be prefixed, please add bridge_ prefix."
einfo "Setting ${n}: ${s}"
-   echo "${s}" >"${x}" || \
+   _netns echo "${s}" \>"${x}" || \
eerror "Failed to configure $n (${n}_${IFVAR})"
fi
done
@@ -154,7 +154,7 @@ bridge_pre_start()
# The interface is known to exist now
_up
if ${do_iproute2}; then
-   ip link set "${x}" master "${BR_IFACE}"
+   _netns ip link set "${x}" master "${BR_IFACE}"
elif ${do_brctl}; then
brctl addif "${BR_IFACE}" "${x}"
fi
@@ -163,7 +163,7 @@ bridge_pre_start()
return 1
fi
# Per-interface bridge settings
-   for x in /sys/class/net/"${IFACE}"/brport/*; do
+   for x in $(_netns glob 
/sys/class/net/"${IFACE}"/brport/\*); do
[ -f "${x}" ] || continue
n=${x##*/}
for prefix in "" brport_; do
@@ -171,7 +171,7 @@ bridge_pre_start()
if [ -n "${s}" ]; then
[ -z "${prefix}" ] && ewarn 
"sysfs key '${n}_${IFVAR}' should be prefixed, please add brport_ prefix."
einfo "Setting ${n}@${IFACE}: 
${s}"
-   echo "${s}" >"${x}" || \
+   _netns echo "${s}" \>"${x}" || \
eerror "Failed to configure $n 
(${n}_${IFVAR})"
fi
done
@@ -194,7 +194,7 @@ bridge_post_stop()
if _is_bridge "${IFACE}"; then
ebegin "Destroying bridge ${IFACE}"
_down
-   for x in /sys/class/net/"${IFACE}"/brif/*; do
+   for x in $(_netns glob /sys/class/net/"${IFACE}"/brif/\*); do
[ -s $x ] || continue
n=${x##*/}
ports="${ports} ${n}"
@@ -206,8 +206,8 @@ bridge_post_stop()
# We are taking down an interface that is part of a bridge maybe
ports="${IFACE}"
local brport_dir="/sys/class/net/${IFACE}/brport"
-   [ -d ${brport_dir} ] || return 0
-   iface=$(readlink ${brport_dir}/bridge)
+   _netns [ -d ${brport_dir} ] || return 0
+   iface=$(_netns readlink 

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

2021-03-11 Thread Lars Wendler
commit: 1e807ce5e4dacf3fd491844588192f8ebb74f3a2
Author: Patrick McLean  gentoo  org>
AuthorDate: Fri Nov 20 17:21:18 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Thu Mar 11 16:53:29 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1e807ce5

net/iproute2.sh: Add initial support for network namespaces

This adds initial support for network namespaces. An interface can be
assigned to a network namespace with `netns_${IFACE}`. The script will
move the interface to the namespace if it is not already there.

This adds a helper functions to `functions.sh` called `_netns`, this
function facilitates scripts working withing network namespaces. It
allows eching to sysfs etc files, globbing, and arbitrary commands
within a network namespace.

This uses a wrapper for the `ip` command so all calls to it will add
`-n ${netns}` so it's operating in the netns. Basic interface
configuration is tested and working.

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

 init.d/net.lo.in |   6 +++
 net/iproute2.sh  | 148 +--
 sh/functions.sh  |  41 +++
 3 files changed, 148 insertions(+), 47 deletions(-)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index fb55788..06304e1 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -660,6 +660,12 @@ start()
_load_modules true
fi
 
+   for module in ${MODULES}; do
+   if [ "$(command -v "${module}_pre_up")" = "${module}_pre_up" ]; 
then
+   ${module}_pre_up || exit $?
+   fi
+   done
+
# We up the iface twice if we have a preup to ensure it's up if
# available in preup and afterwards incase the user inadvertently
# brings it down

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 2289587..46f0e48 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -9,36 +9,56 @@ iproute2_depend()
after ifconfig
 }
 
-# This helper exists for the common pattern of 'veinfo $CMD ; $CMD'
-_cmd()
-{
-   veinfo "${@}"
-   "${@}"
-}
-
 _up()
 {
-   _cmd ip link set dev "${IFACE}" up
+   _ip -v link set dev "${IFACE}" up
 }
 
 _down()
 {
-   _cmd ip link set dev "${IFACE}" down
+   _ip -v link set dev "${IFACE}" down
 }
 
 _exists()
 {
-   [ -e /sys/class/net/"$IFACE" ]
+   _netns [ -e /sys/class/net/"$IFACE" ]
+}
+
+_set_netns()
+{
+   eval netns="\$netns_${IFVAR}"
+}
+
+_ip()
+{
+   local v
+   if [ "${1}" = -v ]; then
+   v=1
+   shift
+   fi
+
+   local ip
+   if ! ip=$(command -v ip 2>/dev/null) || [ ! -x "${ip}" ]; then
+   eerror "Please make sure that iproute2 is installed"
+   exit 1
+   fi
+
+   local netns
+   _set_netns
+   # make sure the netns exists
+   [ -n "${netns}" ] && [ -e /run/netns/"${netns}" ] && set -- -n 
"${netns}" "${@}"
+   [ -n "${v}" ] && veinfo ip "${@}"
+   "${ip}" "${@}"
 }
 
 _ifindex()
 {
local index=-1
local f v
-   if [ -e /sys/class/net/"${IFACE}"/ifindex ]; then
-   index=$(cat /sys/class/net/"${IFACE}"/ifindex)
+   if _netns [ -e /sys/class/net/"${IFACE}"/ifindex ]; then
+   index=$(_netns cat /sys/class/net/"${IFACE}"/ifindex)
else
-   for f in /sys/class/net/*/ifindex ; do
+   for f in $(_netns glob /sys/class/net/\*/ifindex); do
v=$(cat $f)
[ $v -gt $index ] && index=$v
done
@@ -51,11 +71,11 @@ _ifindex()
 _is_wireless()
 {
# Support new sysfs layout
-   [ -d /sys/class/net/"${IFACE}"/wireless -o \
+   _netns [ -d /sys/class/net/"${IFACE}"/wireless -o \
-d /sys/class/net/"${IFACE}"/phy80211 ] && return 0
 
-   [ ! -e /proc/net/wireless ] && return 1
-   grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
+   _netns [ ! -e /proc/net/wireless ] && return 1
+   _netns grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
 }
 
 _set_flag()
@@ -65,13 +85,16 @@ _set_flag()
flag=${flag#-}
opt="off"
fi
-   _cmd ip link set dev "${IFACE}" "${flag}" "${opt}"
+   _ip -v link set dev "${IFACE}" "${flag}" "${opt}"
 }
 
 _get_mac_address()
 {
local mac=
read -r mac < /sys/class/net/"${IFACE}"/address || return 1
+   local mac=$(LC_ALL=C _ip link show "${IFACE}" | sed -n \
+   -e 'y/abcdef/ABCDEF/' \
+   -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
 
case "${mac}" in
00:00:00:00:00:00) return 1 ;;
@@ -84,7 +107,7 @@ _get_mac_address()
 
 _set_mac_address()
 {
-   _cmd ip link set dev "${IFACE}" address "$1"
+   _ip -v link set dev "${IFACE}" address "$1"
 }
 
 _get_inet_addresses()
@@ -93,7 +116,7 @@ _get_inet_addresses()
if [ -z "$family" ]; then
   

[gentoo-commits] proj/netifrc:master commit in: net/

2021-03-11 Thread Lars Wendler
commit: f56e5753063e4d461b3e140e50bcbd6a60b0c1eb
Author: Patrick McLean  gentoo  org>
AuthorDate: Sat Nov 21 06:53:54 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Thu Mar 11 16:53:33 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f56e5753

net/dummy.sh: Add support for network namespaces

Closes: https://github.com/gentoo/netifrc/pull/35
Signed-off-by: Lars Wendler  gentoo.org>

 net/dummy.sh | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/net/dummy.sh b/net/dummy.sh
index 421d951..091e08c 100644
--- a/net/dummy.sh
+++ b/net/dummy.sh
@@ -13,16 +13,20 @@ _is_dummy() {
is_interface_type dummy
 }
 
+_ip()
+{
+   veinfo ip "${@}"
+   _netns ip "${@}"
+}
+
 dummy_pre_start()
 {
local dummy=
-   eval dummy=\$type_${IFVAR}
+   eval dummy="\$type_${IFVAR}"
[ "${dummy}" = "dummy" ] || return 0
 
ebegin "Creating dummy interface ${IFACE}"
-   cmd="ip link add name "${IFACE}" type dummy"
-   veinfo $cmd
-   if $cmd ; then
+   if _ip link add name "${IFACE}" type dummy ; then
eend 0 && _up && set_interface_type dummy
else
eend 1
@@ -35,8 +39,6 @@ dummy_post_stop()
_is_dummy || return 0
 
ebegin "Removing dummy ${IFACE}"
-   cmd="ip link delete "${IFACE}" type dummy"
-   veinfo "$cmd"
-   $cmd
+   _ip link delete "${IFACE}" type dummy
eend $?
 }



[gentoo-commits] proj/netifrc:master commit in: doc/

2021-03-11 Thread Lars Wendler
commit: 407f763feb33955ddd4a2ef3219960270a8e43bf
Author: Patrick McLean  gentoo  org>
AuthorDate: Wed Nov 25 03:24:21 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Thu Mar 11 16:53:33 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=407f763f

net.example: Add example for network namespace support

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

 doc/net.example.Linux.in | 9 +
 1 file changed, 9 insertions(+)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 2dc05c1..427b2da 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1333,6 +1333,15 @@
 # Wireguard can also be configured by passing explicit settings
 #wireguard_wg0="private-key /path/to/whatever listen-port 1234 peer ABCDEF= 
endpoint 1.2.3.4:2468"
 
+# Network namespace support 
+# If an interface is configured with a network namespace, it will be moved
+# in to that namespace before being started. This does not have any 
functionality
+# to move interfaces out of network namespaces. The next time the interfaces is
+# started, it will simply start the interface inside the namespace.
+#
+# Note that not all functionality has been updated to work with network 
namespace
+#netns_eth0="mynetns"
+
 ##
 # ADVANCED CONFIGURATION
 #



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

2021-02-10 Thread Lars Wendler
commit: 3067e568abbf803e8f47a6e16bc39412a4539b1c
Author: Lars Wendler  gentoo  org>
AuthorDate: Wed Feb 10 13:05:37 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Wed Feb 10 13:05:37 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=3067e568

Makefile.inc: tag a new release

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

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index 1cc2b49..4c65f8c 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.2
+VERSION=   0.7.3
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: net/

2021-02-02 Thread Lars Wendler
commit: b60fd3319a254dfacf0051dc0e5343a8fe6e87f1
Author: Kerin Millar  plushkava  net>
AuthorDate: Tue Feb  2 03:47:13 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Feb  2 08:27:02 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b60fd331

net/apipa.sh: Simplify and address the remaining portability issues

Re-factor the over-generalised seeding function into a _random_uint16
function. Have it use a simpler, faster method to collect entropy, with
the aid of od(1). Shorten the previously rambling comment.

Simplify the _random_apipa_octets function. Clamp the seed to the range
0-32767 for maximal portability. Convey the seed as a formal parameter,
rather then inject it. Use a simpler method to produce the octets, running
awk(1) only once. Format the random float, so that awk(1) is prevented
from using scientific notation to represent certain numbers.

Change a variable name in the subshell responsible for reading the list of
octet pairs, so as to be less confusing to future readers.

Note that the portability issue mentioned by commit 31a05f1 is addressed.
The code should now be fully POSIX-compliant, save for the continued use
of the local keyword, upon which it does not rely.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Lars Wendler  gentoo.org>

 net/apipa.sh | 63 
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index 41274fa..a124b84 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -6,47 +6,42 @@ apipa_depend()
program /sbin/arping /bin/arping
 }
 
-_random_bytes_as_int()
+_random_uint16()
 {
-   local hex num_bytes="$1"
-
-   # While POSIX does not require that /dev/urandom exist, it is a
-   # de-facto standard. Therefore, the following approach should be
-   # highly portable in practice. In the case of Linux, and unlike BSD
-   # this interface does not block in the event that the CSRNG has not
-   # yet been seeded. Still, this is acceptable because we do not
-   # require a guarantee that the entropy be cryptographically secure.
-   # It's also worth noting that Linux >=5.4 is faster at seeding in
-   # the absence of RDRAND/RDSEED than previous versions were.
+   # While POSIX does not require that /dev/urandom exist, it is a de-facto
+   # standard. In the case of Linux, and unlike BSD, this interface does
+   # not block in the event that the CSRNG has not yet been seeded.
+   # Still, this is acceptable because we do not require a guarantee that
+   # the entropy be cryptographically secure.
test -e /dev/urandom &&
-   hex=$(
-   LC_ALL=C tr -dc '[:xdigit:]' < /dev/urandom |
-   dd bs="$(( num_bytes * 2 ))" count=1 2>/dev/null) &&
-   test "${#hex}" = "$(( num_bytes * 2 ))" &&
-   printf '%d\n' "0x${hex}"
+   printf %d 0x"$(LC_ALL=C od -vAn -N2 -tx1 /dev/urandom | tr -d 
'[:space:]')"
 }
 
 _random_apipa_octets()
 {
local seed
 
-   # Obtain a highly random 16-bit seed for use by awk's RNG. In the
-   # unlikely event that the seed ends up being empty, awk will seed
-   # based on the time of day, with a granularity of one second.
-   seed=$(_random_bytes_as_int 2)
+   # Attempt to generate a random uint16 to seed awk's RNG. The maximum
+   # value of RAND_MAX known to be portable is 32767. Clamp accordingly by
+   # discarding one bit's worth of data. Should the seed turn out to be
+   # empty, we instruct awk to seed based on the time of day, in seconds.
+   seed=$(_random_uint16) && : $(( seed >>= 1 ))
 
# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
# reserved. This provides 65024 addresses, having accounted for the
# fact that the first and last /24 are reserved for future use.
-   awk "BEGIN {
-   srand($seed)
-   for (i=256; i<65280; i++) print rand() \" \" i
-   }" |
-   sort -k 1,1 -n |
-   POSIXLY_CORRECT=1 awk '{
-   hex = sprintf("%04x",$2)
-   printf("%d %d\n", "0x" substr(hex,1,2), "0x" substr(hex,3,2))
-   }'
+   awk -v seed="$seed" 'BEGIN {
+   if (seed != "") {
+   srand(seed)
+   } else {
+   srand()
+   }
+   for (i = 1; i < 255; i++) {
+   for (j = 0; j < 256; j++) {
+   printf("%f %d %d\n", rand(), i, j)
+   }
+   }
+   }' | sort -k 1,1 -n
 }
 
 apipa_start()
@@ -62,11 +57,11 @@ apipa_start()
addr=$(
_random_apipa_octets |
{
-   while read -r i1 i2; do
-   addr="169.254.${i1}.${i2}"
-   vebegin "${addr}/16" >&3
-   if ! 

[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-27 Thread Lars Wendler
commit: e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a
Author: Kerin Millar  plushkava  net>
AuthorDate: Wed Jan 27 16:25:05 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Wed Jan 27 16:55:21 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5c3bb95

net/apipa.sh: Account for the first and last /24 being reserved

While the 169.254/16 prefix is used to define IPv4 link-local addresses,
RFC 3927 states that the first 256 and last 256 addresses are reserved for
future use. Therefore, the number of available addresses amounts to neither
64516 nor 65534, but actually 65024.

Signed-off-by: Kerin Millar  plushkava.net>
Signed-off-by: Lars Wendler  gentoo.org>

 net/apipa.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index f3ec534..41274fa 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -36,11 +36,11 @@ _random_apipa_octets()
seed=$(_random_bytes_as_int 2)
 
# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
-   # reserved. This provides 65534 addresses, having accounted for the
-   # network and broadcast address. Note that we must count from 1.
+   # reserved. This provides 65024 addresses, having accounted for the
+   # fact that the first and last /24 are reserved for future use.
awk "BEGIN {
srand($seed)
-   for (i=1; i<65535; i++) print rand() \" \" i
+   for (i=256; i<65280; i++) print rand() \" \" i
}" |
sort -k 1,1 -n |
POSIXLY_CORRECT=1 awk '{



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-27 Thread Lars Wendler
commit: b89e0687fb4facfc7f36fc137944856cf331271c
Author: Lars Wendler  gentoo  org>
AuthorDate: Wed Jan 27 14:16:39 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Wed Jan 27 14:16:39 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b89e0687

net/iwd.sh: Removed non-working "need dbus" call

This is a copy-paste remnant from net/wpa_supplicant.sh which never
worked with standalone netifrc.

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

 net/iwd.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/iwd.sh b/net/iwd.sh
index e3f64b2..d8be2d5 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -3,7 +3,6 @@
 
 iwd_depend()
 {
-   need dbus
after macnet plug
before interface
provide wireless



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-27 Thread Lars Wendler
commit: 31a05f1b3fb90a3b4e9c0e587bdd5a39e8236f6b
Author: Kerin Millar  plushkava  net>
AuthorDate: Mon Jan 25 02:40:29 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Wed Jan 27 14:05:54 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=31a05f1b

net/apipa.sh: fix broken implementation by way of a rewrite

Sadly, the present implementation has never functioned correctly. The
original author employed incorrect syntax for what was intended to be a
command substitution. As a result, the _random() function is never called.
What actually happens is that arping is needlessly executed exactly 64516
times, with no address ever being considered as a valid candidate.

Furthermore, this module has other bugs and is poorly designed. Here are the
reasons as to why:-

  • the 169.254.0.0/16 block offers 65534 addresses, not 64516
  • the main loop is horrendously slow at enumerating the address block
  • it counts to 64516 but doesn't ensure that each address is unique!
  • it prefers bash for generating entropy (fine, but non-standard)
  • it falls back to a non-standard utility for generating entropy

Therefore, I decided to re-write most of it. The fundamental difference is
that all 65534 octet pairs are generated up front before being processed by
the main loop. At most, every possible address will now be tested exactly
once.

In fact, this approach turns out to be faster by an order of magnitude. The
following synthetic tests - which calculate the time taken to enumerate the
entire address space - demonstrate the tremendous difference between the
existing code and mine. Of course, to ensure that the comparison was
meaningful, I rectified the command substitution bug in the existing code.

  # time bash apipa-old-test.sh
  real2m34.367s
  user1m9.959s
  sys 1m37.502s

  # time bash apipa-new-test.sh
  real0m1.119s
  user0m0.965s
  sys 0m0.182s

Note that the new _random_apipa_octets() function is responsible for
generating all 65534 combinations of octet pairs in a random order. It
mainly relies on awk(1) and sort(1). Where possible, a seed is obtained from
/dev/urandom for the benefit of awk's RNG, but this is not required.

I have isolated and tested the new functions on GNU/Linux, macOS, FreeBSD,
NetBSD, OpenBSD and MirBSD. I have individually tested gawk, mawk, nawk,
busybox awk and the awk implementations provided by the previously mentioned
operating systems in the case that they are distinct. The only
incompatiblity that I was personally able to find was with the awk
implementation of MirBSD, which affects the final invocation of awk in the
_random_apipa_octets function.  However, MirBSD was forked from an old
version of OpenBSD and seems sufficiently obscure so as not to be worth
worrying about. If someone should try to integrate netifrc into MirBSD one
day then the matter can be dealt with then.

Finally, I want to thank Steve Arnold for bringing the original bug to my
attention. Congratulations, Steve. You may be the only known user of
net/apipa.sh on the planet.

Signed-off-by: Kerin Millar  plushkava.net>
Reported-by: Steve Arnold  gentoo.org>
Closes: https://bugs.gentoo.org/766890
Signed-off-by: Lars Wendler  gentoo.org>

 net/apipa.sh | 94 +++-
 1 file changed, 67 insertions(+), 27 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index 849728b..f3ec534 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -1,49 +1,89 @@
 # Copyright (c) 2007-2008 Roy Marples 
 # Released under the 2-clause BSD license.
-# shellcheck shell=sh disable=SC1008
 
 apipa_depend()
 {
program /sbin/arping /bin/arping
 }
 
-_random()
+_random_bytes_as_int()
 {
-   local r=${RANDOM} # checkbashisms: false positive, we handle it 
AFTERWARDS
-   if [ -n "${r}" ]; then
-   echo "${r}"
-   else
-   uuidgen | sed -n -e 's/[^[:digit:]]//g' -e 
's/\(^.\{1,7\}\).*/\1/p'
-   fi
+   local hex num_bytes="$1"
+
+   # While POSIX does not require that /dev/urandom exist, it is a
+   # de-facto standard. Therefore, the following approach should be
+   # highly portable in practice. In the case of Linux, and unlike BSD
+   # this interface does not block in the event that the CSRNG has not
+   # yet been seeded. Still, this is acceptable because we do not
+   # require a guarantee that the entropy be cryptographically secure.
+   # It's also worth noting that Linux >=5.4 is faster at seeding in
+   # the absence of RDRAND/RDSEED than previous versions were.
+   test -e /dev/urandom &&
+   hex=$(
+   LC_ALL=C tr -dc '[:xdigit:]' < /dev/urandom |
+   dd bs="$(( num_bytes * 2 ))" count=1 2>/dev/null) &&
+   test "${#hex}" = "$(( num_bytes * 2 ))" &&
+   printf '%d\n' "0x${hex}"
+}
+
+_random_apipa_octets()
+{
+   local seed
+
+   # Obtain a highly random 16-bit seed for use by awk's RNG. 

[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-24 Thread Lars Wendler
commit: 6632c348cce8be19c7a960cabb2f6f41ec4c6d51
Author: Kerin Millar  plushkava  net>
AuthorDate: Sun Jan 24 02:49:43 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Sun Jan 24 10:21:20 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6632c348

Use sysfs to obtain the MAC address in net/iproute2.sh

Dispense with the hideous ip-link(8) parser. Instead, collect the MAC
address by reading from the relevant sysfs file. While at it, tidy up
the remainder of the function so that the control flow is easier to
ascertain at a glance. Note that the address will be rendered in upper
case, just as it was before.

Signed-off-by: Kerin Millar  plushkava.net>
Closes: https://bugs.gentoo.org/766758
Signed-off-by: Lars Wendler  gentoo.org>

 net/iproute2.sh | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 4c32acc..2289587 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -70,19 +70,16 @@ _set_flag()
 
 _get_mac_address()
 {
-   local mac=$(LC_ALL=C ip link show "${IFACE}" | sed -n \
-   -e 'y/abcdef/ABCDEF/' \
-   -e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
+   local mac=
+   read -r mac < /sys/class/net/"${IFACE}"/address || return 1
 
case "${mac}" in
-   00:00:00:00:00:00);;
-   44:44:44:44:44:44);;
-   FF:FF:FF:FF:FF:FF);;
-   "");;
-   *) echo "${mac}"; return 0;;
+   00:00:00:00:00:00) return 1 ;;
+   44:44:44:44:44:44) return 1 ;;
+   ff:ff:ff:ff:ff:ff) return 1 ;;
esac
 
-   return 1
+   printf '%s\n' "${mac}" | LC_ALL=C tr '[:lower:]' '[:upper:]'
 }
 
 _set_mac_address()



[gentoo-commits] proj/netifrc:master commit in: udev_helper/

2021-01-18 Thread Lars Wendler
commit: 6d8ec90ad901b7406b0b23878de112296d9e16ac
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 14:47:34 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 14:49:14 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=6d8ec90a

udev_helper/net.sh: Ignore wireguard interfaces

Bug: https://bugs.gentoo.org/758938
Signed-off-by: Lars Wendler  gentoo.org>

 udev_helper/net.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/udev_helper/net.sh b/udev_helper/net.sh
index f1c4f20..0c114a5 100644
--- a/udev_helper/net.sh
+++ b/udev_helper/net.sh
@@ -17,7 +17,7 @@ fi
 
 # ignore interfaces that are registered after being "up" (?)
 case ${IFACE} in
-   
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*|br*|macvtap*|ipvl*|vlan*|vxlan*|peth*|ifb*|veth*|gre*|vrf*)
+   
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*|br*|macvtap*|ipvl*|vlan*|vxlan*|peth*|ifb*|veth*|gre*|vrf*|wg*)
exit 0 ;;
 esac
 



[gentoo-commits] proj/netifrc:master commit in: doc/

2021-01-18 Thread Lars Wendler
commit: ebc70a9cead6790b0ef337dc0c3c1ea77d9164dd
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 14:30:07 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 14:30:07 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ebc70a9c

doc/net.example.Linux.in: Document wpa_supplicant's dbus dependency

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

 doc/net.example.Linux.in | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index bafde42..2dc05c1 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -451,6 +451,10 @@
 # pre/post user functions below (although it's not available in preup as you
 # won't have associated then)
 
+# If wpa_supplicant has been compiled with dbus support, it is necessary to
+# make the corresponding interface depend on the dbus daemon:
+#rc_net_wlan0_need="dbus"
+
 # If you're using anything else to configure wireless on your interface AND
 # you have installed wpa_supplicant, you need to disable wpa_supplicant.
 # Please see the note about hostapd in the MODULES section.



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-18 Thread Lars Wendler
commit: 60bd853443f8e01c4309aeb2f3198f959c62cfdf
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 14:21:31 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 14:26:11 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=60bd8534

net/wpa_supplicant.sh: Removed non-working "need dbus" call

This is a remnant from when netifrc was part of openrc.
After netifrc became it's own standalone project, the call "need dbus"
got caught by the need() function from openrc's sh/openrc-run.sh script
which does a simple echo on every input it receives.

Bug: https://bugs.gentoo.org/622730
Signed-off-by: Lars Wendler  gentoo.org>

 net/wpa_supplicant.sh | 8 
 1 file changed, 8 deletions(-)

diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
index d5e2013..3f8e1b1 100644
--- a/net/wpa_supplicant.sh
+++ b/net/wpa_supplicant.sh
@@ -4,14 +4,6 @@
 
 wpa_supplicant_depend()
 {
-   wpas=/usr/sbin/wpa_supplicant
-   [ -x ${wpas} ] || wpas=/sbin/wpa_supplicant
-   if [ -x ${wpas} ]; then
-   program start ${wpas}
-   # bug 345281: if wpa_supplicant is built w/ USE=dbus, we need 
to start
-   # dbus before we can start wpa_supplicant.
-   ${wpas} -h | grep -Fsq DBus && need dbus
-   fi
after macnet plug
before interface
provide wireless



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-18 Thread Lars Wendler
commit: 72b3a820214fc50d50b8ac0f031491106d8d8634
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 13:01:54 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 13:01:54 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=72b3a820

net/pppd.sh: Completely overhauled pppd version check

Thanks-to: Kerin Millar  plushkava.net>
Bug: https://bugs.gentoo.org/729920

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

 net/pppd.sh | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 2182497..22644f2 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -23,28 +23,10 @@ requote()
 
 pppd_is_ge_248()
 {
-   local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ 
{print $3}')"
-   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)"
+   local ver_str="$(/usr/sbin/pppd --version 2>&1 | awk '/pppd version/ 
{print $3}' | tr '.' ' ')"
 
-   if [ "${maj_ver}" -gt 2 ] ; then
-   return 0
-   elif [ "${maj_ver}" -eq 2 ] ; then
-   if [ "${min_ver}" -gt 4 ] ; then
-   return 0
-   elif [ "${min_ver}" -eq 4 ] ; then
-   if [ "${patch_ver}" -ge 8 ] ; then
-   return 0
-   else
-   return 1
-   fi
-   else
-   return 1
-   fi
-   else
-   return 1
-   fi
+   # 002004008 is v2.4.8
+   [ "$(printf '%03d' ${ver_str})" -ge 002004008 ]
 }
 
 pppd_pre_start()



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

2021-01-18 Thread Lars Wendler
commit: f9951f7d42f1f5ad57e14a29a0be85a80d9a863a
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 10:45:36 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 12:32:31 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9951f7d

Convert many "grep" calls to "grep -F"

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

 doc/net.example.Linux.in | 6 +++---
 net/ifconfig.sh.Linux.in | 2 +-
 net/iproute2.sh  | 6 +++---
 net/iw.sh| 4 ++--
 net/iwconfig.sh.Linux.in | 5 ++---
 net/wpa_supplicant.sh| 3 +--
 6 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index b404329..bafde42 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -1365,7 +1365,7 @@
 #  # Test for link on the interface prior to bringing it up.  This
 #  # only works on some network adapters and requires the
 #  # sys-apps/net-tools package to be installed.
-#  if mii-tool "${IFACE}" 2> /dev/null | grep -q 'no link'; then
+#  if mii-tool "${IFACE}" 2> /dev/null | grep -Fq 'no link'; then
 #  ewarn "No link on ${IFACE}, aborting configuration"
 #  return 1
 #  fi
@@ -1373,14 +1373,14 @@
 #  # Test for link on the interface prior to bringing it up.  This
 #  # only works on some network adapters and requires the ethtool
 #  # package to be installed.
-#  if ethtool "${IFACE}" | grep -q 'Link detected: no'; then
+#  if ethtool "${IFACE}" | grep -Fq 'Link detected: no'; then
 #  ewarn "No link on ${IFACE}, aborting configuration"
 #  return 1
 #  fi
 #
 #  # Test to see if we're docked or not and configure like so
 #  # config_docked="dhcp"
-#  if grep -q "1" /sys/devices/platform/dock.0/docked; then
+#  if grep -Fq "1" /sys/devices/platform/dock.0/docked; then
 #   einfo "${IFACE} is docked - configuring"
 #  _configure_variables "docked"
 #  fi

diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
index 960b239..b0a4551 100644
--- a/net/ifconfig.sh.Linux.in
+++ b/net/ifconfig.sh.Linux.in
@@ -47,7 +47,7 @@ _is_wireless()
-d /sys/class/net/"${IFACE}"/phy80211 ] && return 0
 
[ ! -e /proc/net/wireless ] && return 1
-   grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/wireless
+   grep -q "^[[:space:]]*${IFACE}:" /proc/net/wireless
 }
 
 _set_flag()

diff --git a/net/iproute2.sh b/net/iproute2.sh
index d19f79d..4c32acc 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -192,7 +192,7 @@ _add_address()
 
# Check for address already existing:
ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 
2>/dev/null | \
-   fgrep -sq "${address}"
+   grep -Fsq "${address}"
address_already_exists=$?
 
# This must appear on a single line, continuations cannot be used
@@ -265,7 +265,7 @@ _add_route()
 
# Check for route already existing:
ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \
-   fgrep -sq "${cmd%% *}"
+   grep -Fsq "${cmd%% *}"
route_already_exists=$?
 
_cmd ip ${family} route append ${cmd} dev "${IFACE}"
@@ -304,7 +304,7 @@ _delete_addresses()
 
 _has_carrier()
 {
-   LC_ALL=C ip link show dev "${IFACE}" | grep -q "LOWER_UP"
+   LC_ALL=C ip link show dev "${IFACE}" | grep -Fq "LOWER_UP"
 }
 
 # Used by iproute2, ip6rd & ip6to4

diff --git a/net/iw.sh b/net/iw.sh
index 029b9d6..1f8b068 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -212,7 +212,7 @@ iw_wait_for_association()
# carrier on or buggy madwifi drivers that
# sometimes have carrier on and ssid set
# without being associated.  :/
-   [ -n "$(iw dev "${IFACE}" info |grep ssid)" ] 
&& [ "${station_mac}" != "00:00:00:00:00:00" ] && return 0
+   [ -n "$(iw dev "${IFACE}" info | grep -F ssid)" 
] && [ "${station_mac}" != "00:00:00:00:00:00" ] && return 0
fi
else
local atest=
@@ -704,7 +704,7 @@ iw_pre_start()
 
# Store the fact that tx-power was off so we default to a longer
# wait if our scan returns nothing
-   LC_ALL=C iw dev "${IFACE}" info | sed -e '1d' | grep -q "txpower 0.00"
+   LC_ALL=C iw dev "${IFACE}" info | sed -e '1d' | grep -Fq "txpower 0.00"
local txpowerwasoff=$?
 
iw_defaults

diff --git a/net/iwconfig.sh.Linux.in b/net/iwconfig.sh.Linux.in
index 02f748d..98044a9 100644
--- a/net/iwconfig.sh.Linux.in
+++ b/net/iwconfig.sh.Linux.in
@@ -17,9 +17,8 @@ iwconfig_get_wep_status()
 {
local mode= status="disabled"
 
-   # No easy way of doing this grep in bash regex :/
if LC_ALL=C iwconfig "${IFACE}" | \
-   grep -qE "^ +Encryption 

[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-18 Thread Lars Wendler
commit: 90482eddc3e792809bb220320672816000f727e3
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 11:23:12 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 12:32:31 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=90482edd

net/l2tp.sh: dash doesn't know "&>/dev/null" redirect

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

 net/l2tp.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 9644e32..82649b9 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -34,8 +34,7 @@ _l2tp_eval_props() {
 
 _is_l2tp() {
# Check for L2TP support in kernel
-   ip l2tp show session &>/dev/null
-   [ $? -ne 0 ] && return 1
+   ip l2tp show session 2>/dev/null 1>/dev/null || return 1
 
eval "$(ip l2tp show session | \
awk "match(\$0, /^Session ([0-9]+) in tunnel ([0-9]+)\$/, ret) 
{sid=ret[1]; tid=ret[2]} 



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-18 Thread Lars Wendler
commit: e08ad3fd1aa2fca27ddf0ad7dfeedb82db4a3666
Author: Lars Wendler  gentoo  org>
AuthorDate: Mon Jan 18 11:44:10 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Mon Jan 18 12:32:31 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e08ad3fd

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  wildgooses.com>
Closes: https://github.com/gentoo/netifrc/pull/33
Signed-off-by: Lars Wendler  gentoo.org>

 net/pppd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 42495a7..2182497 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -23,7 +23,7 @@ requote()
 
 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 | awk '/pppd version/ 
{print $3}')"
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)"



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

2021-01-05 Thread Robin H. Johnson
commit: fe392e55295c1b459df1a70b0521c887d6567344
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Jan  5 18:18:41 2021 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jan  5 18:18:41 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=fe392e55

Makefile.inc: tag new release

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

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index 37087b4..1cc2b49 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.7.1
+VERSION=   0.7.2
 PKG=   ${NAME}-${VERSION}



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

2021-01-05 Thread Lars Wendler
commit: 750d89eaf772551588c460a0c8425579e7d49677
Author: Lars Wendler  gentoo  org>
AuthorDate: Tue Jan  5 12:51:41 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Jan  5 14:26:56 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=750d89ea

net/pppd.sh: ppp-2.4.9 has renamed rp-pppoe.so to pppoe.so

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

 doc/net.example.Linux.in | 5 +++--
 net/pppd.sh  | 7 +++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index d88302b..b404329 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -805,9 +805,10 @@
 #link_ppp0="pty 'your_link_command'"   # PPP links over ssh, rsh, etc
 #
 # Here you should specify what pppd plugins you want to use
-# Available plugins are: pppoe, pppoa, capi, dhcpc, minconn, radius,
+# Available plugins are: pppoe, rp-pppoe, pppoa, capi, dhcpc, minconn, radius,
 #   radattr, radrealms and winbind
-#plugins_ppp0="pppoe"  # Required plugin for PPPoE
+#plugins_ppp0="pppoe"  # Required plugin for PPPoE with 
>=ppp-2.4.9
+#plugins_ppp0="rp-pppoe"   # Required plugin for PPPoE with 


[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-05 Thread Lars Wendler
commit: 2658f44bb04e117043d1466fcd8e65c1e321db01
Author: Lars Wendler  gentoo  org>
AuthorDate: Tue Jan  5 12:57:51 2021 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Jan  5 14:26:56 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2658f44b

net/pppd.sh: prefer defaultroute-metric

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

 net/pppd.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index c6a6a8a..42495a7 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -65,10 +65,10 @@ pppd_pre_start()
return 0
fi
 
-   local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultmetric
+   local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultroute-metric
 
# 
https://github.com/paulusmack/ppp/commit/35e5a569c988b1ff865b02a24d9a727a00db4da9
-   pppd_is_ge_248 && routemetric=defaultroute-metric
+   pppd_is_ge_248 || routemetric=defaultmetric
 
# PPP requires a link to communicate over - normally a serial port
# PPPoE communicates over Ethernet



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-05 Thread Lars Wendler
commit: 86879b6bfd4f6d8ce26945a5570e579bf28249f5
Author: Lars Wendler  gentoo  org>
AuthorDate: Tue Dec 15 20:47:15 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Jan  5 12:44:05 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=86879b6b

Add code style fixes and missing copyright headers

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

 net/dhcpcd.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index e3410d8..1e1bbe0 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -1,4 +1,5 @@
 # Copyright (c) 2007-2008 Roy Marples 
+# Copyright (c) 2020 Gentoo Authors
 # Released under the 2-clause BSD license.
 # shellcheck shell=sh disable=SC1008
 
@@ -55,9 +56,9 @@ dhcpcd_start()
done
 
# Add our route metric if not given
-   case " $args " in
+   case " ${args} " in
*" -m "*) ;;
-   *) [ "${metric:-0}" != 0 ] && args="$args -m $metric";;
+   *) [ "${metric:-0}" != 0 ] && args="${args} -m ${metric}";;
esac
 
# Bring up DHCP for this interface



[gentoo-commits] proj/netifrc:master commit in: net/

2021-01-05 Thread Lars Wendler
commit: 04e6565b185fd3066822333e1b1932284ec1f6b7
Author: Lars Wendler  gentoo  org>
AuthorDate: Tue Dec 15 19:53:27 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Jan  5 12:44:05 2021 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=04e6565b

net/dhcpcd.sh: Remove support for ancient dhcpcd versions

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

 net/dhcpcd.sh | 27 +--
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 548a503..e3410d8 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -20,7 +20,7 @@ dhcpcd_start()
# alter the pidfile's name (#718114)
# Save the args into a file so dhcpcd_stop can later re-use the very
# same args later.
-   local args= opt= pidfile= opts= new=true 
argsfile=/run/netifrc_dhcpcd_${IFACE}_args
+   local args= opt= pidfile= opts= 
argsfile=/run/netifrc_dhcpcd_${IFACE}_args
eval args=\$dhcpcd_${IFVAR}
[ -z "${args}" ] && args=${dhcpcd}
echo "${args}" > ${argsfile}
@@ -30,33 +30,24 @@ dhcpcd_start()
eval opts=\$dhcp_${IFVAR}
[ -z "${opts}" ] && opts=${dhcp}
 
-   case "$(dhcpcd --version)" in
-   "dhcpcd "[123]*) new=false;;
+   case "$(dhcpcd --version | head -n 1)" in
+   "dhcpcd "[123]*)
+   eerror 'The dhcpcd version is too old. Please upgrade.'
+   return 1
+   ;;
esac
 
# Map some generic options to dhcpcd
for opt in ${opts}; do
case "${opt}" in
nodns)
-   if ${new}; then
-   args="${args} -C resolv.conf"
-   else
-   args="${args} -R"
-   fi
+   args="${args} -C resolv.conf"
;;
nontp)
-   if ${new}; then
-   args="${args} -C ntp.conf"
-   else
-   args="${args} -N"
-   fi
+   args="${args} -C ntp.conf"
;;
nonis)
-   if ${new}; then
-   args="${args} -C yp.conf"
-   else
-   args="${args} -Y"
-   fi
+   args="${args} -C yp.conf"
;;
nogateway) args="${args} -G";;
nosendhost) args="${args} -h ''";



[gentoo-commits] proj/netifrc:master commit in: net/

2020-12-15 Thread Lars Wendler
commit: ee7316e32ecd90384f05f77ddb29abbdf97fa6a2
Author: Brian Evans  gentoo  org>
AuthorDate: Tue Dec 15 19:39:21 2020 +
Commit: Lars Wendler  gentoo  org>
CommitDate: Tue Dec 15 20:10:51 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ee7316e3

net/dhcpcd.sh: Don't run dhcpcd on stop if it's not installed

Bug: https://bugs.gentoo.org/760093
Signed-off-by: Lars Wendler  gentoo.org>

 net/dhcpcd.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index dcc6817..548a503 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -5,7 +5,7 @@
 dhcpcd_depend()
 {
after interface
-   program start dhcpcd
+   program dhcpcd
provide dhcp
 
# We prefer dhcpcd over these



[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: net/, doc/

2020-06-02 Thread Robin H. Johnson
commit: 589d7374dc5c023304f6226cb458d5346bdd3a0b
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Jun  2 21:51:00 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jun  2 21:53:50 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=589d7374

net/iw: implement 802.11s mesh

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

 doc/net.example.Linux.in |  7 ++-
 net/iw.sh| 25 +
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 4fc603b..d88302b 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -231,7 +231,7 @@
 # do require the SSID to be set - do this here
 #essid_eth0="any"
 
-# Set the mode of the interface (managed, ad-hoc, master or auto)
+# Set the mode of the interface (managed, ad-hoc, master, mesh or auto)
 # The default is auto
 # If it's ad-hoc or master you also may need to specify the channel below
 #mode_eth0="auto"
@@ -409,6 +409,11 @@
 # NOTE: preferred_aps  list ignores blacklisted_aps - so if you have
 # the same SSID in both, well, you're a bit silly :p
 
+# 802.11s mesh support
+# Requires CONFIG_MAC80211_MESH in kernel and hardware support
+#mode_wlan0="mesh"
+#mesh_wlan0="MyMeshNetworkID"
+
 
 
 # wpa_supplicant

diff --git a/net/iw.sh b/net/iw.sh
index dcdbb79..029b9d6 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -5,6 +5,7 @@
 
 _config_vars="$_config_vars ssid mode associate_timeout sleep_scan"
 _config_vars="$_config_vars preferred_aps blacklist_aps"
+_config_vars="$_config_vars mesh"
 
 iw_depend()
 {
@@ -170,6 +171,26 @@ iw_setup_adhoc()
return 0
 }
 
+iw_setup_mesh()
+{
+   if [ -z "${MESH}" ]; then
+   eerror "${IFACE} requires a MESH to be set to operate in mesh 
mode"
+   eerror "adjust the mesh_${IFVAR} setting in /etc/conf.d/net"
+   return 1
+   fi
+
+   iw_set_mode 'mesh'
+
+   veinfo "Joining mesh '$MESH' with $IFACE"
+   iw ${IFACE} mesh join "${MESH}" || return 1
+
+   # Finally apply the user Config
+   iw_user_config
+
+   iw_report
+   return 0
+}
+
 iw_wait_for_association()
 {
local timeout= i=0
@@ -600,6 +621,10 @@ iw_configure()
managed)
# Fall through
;;
+   mesh)
+   iw_setup_mesh
+   return $?
+   ;;
*)
eerror "Only managed and ad-hoc are supported"
return 1



[gentoo-commits] proj/netifrc:master commit in: net/

2020-06-02 Thread Robin H. Johnson
commit: 1c846d9d8e23d94046df471c7ccbb88228537188
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Jun  2 21:44:26 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jun  2 21:44:57 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1c846d9d

net/iw: refactor iw mode setup

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

 net/iw.sh | 37 -
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/net/iw.sh b/net/iw.sh
index 82b9ba9..dcdbb79 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -585,27 +585,30 @@ iw_configure()
[ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
 
# Setup ad-hoc mode?
-   eval x=\$mode_${IFVAR}
-   x=${x:-managed}
+   eval _mode=\$mode_${IFVAR}
+   _mode=${_mode:-managed}
 
-   if [ "${x}" = "master" ]; then
-   eerror "Please use hostapd to make this interface an access 
point"
-   return 1
-   fi
-
-   if [ "${x}" = "ad-hoc" ]; then
-   iw_setup_adhoc
-   return $?
-   fi
-
-   if [ "${x}" != "managed" ]; then
-   eerror "Only managed and ad-hoc are supported"
-   return 1
-   fi
+   case "${_mode}" in
+   master)
+   eerror "Please use hostapd to make this interface an 
access point"
+   return 1
+   ;;
+   ad-hoc|adhoc)
+   iw_setup_adhoc
+   return $?
+   ;;
+   managed)
+   # Fall through
+   ;;
+   *)
+   eerror "Only managed and ad-hoc are supported"
+   return 1
+   ;;
+   esac
 
# Has an SSID been forced?
if [ -n "${SSID}" ]; then
-   iw_set_mode "${x}"
+   iw_set_mode "${_mode}"
iw_associate && return 0
[ "${SSID}" = "any" ] && iw_force_preferred && return 0
 



[gentoo-commits] proj/netifrc:master commit in: doc/

2020-06-02 Thread Robin H. Johnson
commit: 51a7c4fae619a05b8f179f5f03b3e8a556df7205
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Tue Jun  2 21:35:31 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Tue Jun  2 21:35:31 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=51a7c4fa

doc/net.example.Linux: document !wireless better

Users that used layer2 wireless configuration external to netifrc and
had previously configured netifrc with:
`modules="!iwconfig !wpa_supplicant"`
were surprised by the introduction of the iw & iwd modules, because the
modules tries to auto-configure the wireless interfaces.

Document that `modules="!wireless"` is a better configuration knob for
this situation.

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

 doc/net.example.Linux.in | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 53d9e84..4fc603b 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -43,8 +43,20 @@
 # You can also specify which modules not to use - for example you may be
 # using a supplicant or linux-wlan-ng to control wireless configuration but
 # you still want to configure network settings per SSID associated with.
-#modules="!iwconfig !wpa_supplicant"
-# IMPORTANT: If you need the above, please disable modules in that order
+#
+# A common case here may be using hostapd or other external configuration of
+# the wireless hardware at layer 2, but leaving netifrc to configure the layer
+# 3 networking
+#
+# Best practice for this situation is to disable ALL netifrc wireless modules:
+#modules="!wireless"
+#
+# This supersedes older cases where each module was disabled seperately:
+# If new modules are introduced that provide wireless support, they may be used
+# automatically otherwise, causing situations like
+# https://bugs.gentoo.org/717226
+# Do not use a line like this anymore:
+#modules="!iwconfig !wpa_supplicant !iw !iwd"
 
 
 ##
@@ -435,9 +447,8 @@
 # won't have associated then)
 
 # If you're using anything else to configure wireless on your interface AND
-# you have installed wpa_supplicant, you need to disable wpa_supplicant
-#modules="!iwconfig !wpa_supplicant"
-#or
+# you have installed wpa_supplicant, you need to disable wpa_supplicant.
+# Please see the note about hostapd in the MODULES section.
 #modules="!wireless"
 
 ##



[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: udev_helper/

2020-05-31 Thread Robin H. Johnson
commit: db98502979abd91749cdede8e096fe3b814441a7
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun May 31 23:20:59 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 23:20:59 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=db985029

udev_helper: recognize more interface types

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

 udev_helper/net.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/udev_helper/net.sh b/udev_helper/net.sh
index b15b187..f1c4f20 100644
--- a/udev_helper/net.sh
+++ b/udev_helper/net.sh
@@ -17,7 +17,7 @@ fi
 
 # ignore interfaces that are registered after being "up" (?)
 case ${IFACE} in
-   ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*|br*)
+   
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*|br*|macvtap*|ipvl*|vlan*|vxlan*|peth*|ifb*|veth*|gre*|vrf*)
exit 0 ;;
 esac
 



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

2020-05-31 Thread Robin H. Johnson
commit: ffa5a9e830c609fec987efac5723781e889ae67c
Author: Arseni Nimera  yandex  by>
AuthorDate: Sat May 30 22:20:25 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 23:15:20 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ffa5a9e8

Added macvtap support

Bug: https://bugs.gentoo.org/691372
Signed-off-by: Arseni Nimera  yandex.by>
(cherry picked from commit 0dc79645173fad82e0d437a6569b7ea7fa356197)
Signed-off-by: Robin H. Johnson  gentoo.org>

 doc/net.example.Linux.in | 3 +++
 net/macvlan.sh   | 8 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index c211ca7..a2993c0 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -664,6 +664,9 @@
 # MAC-VLAN mode (private, vepa, bridge, passtru)
 #mode_macvlan0="private"
 
+# MAC-VLAN type (macvlan, macvtap)
+#type_macvlan0="macvtap"
+
 # IP address, MAC address, ... are configured as a normal interface
 #config_macvlan0="192.168.20.20/24"
 #mac_macvlan0="00:50:06:20:20:20"

diff --git a/net/macvlan.sh b/net/macvlan.sh
index 8d55717..6243858 100644
--- a/net/macvlan.sh
+++ b/net/macvlan.sh
@@ -34,8 +34,12 @@ macvlan_pre_start()
eval mode=\$mode_${IFVAR}
[ -z "${mode}" ] && mode="private"
 
+   local type=
+   eval type=\$type_${IFVAR}
+   [ -z "${type}" ] && type="macvlan"
+
ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}"
-   e="$(ip link add link "${macvlan}" name "${IFACE}" type macvlan mode 
"${mode}" 2>&1 1>/dev/null)"
+   e="$(ip link add link "${macvlan}" name "${IFACE}" type "${type}" mode 
"${mode}" 2>&1 1>/dev/null)"
if [ -n "${e}" ]; then
eend 1 "${e}"
else
@@ -49,6 +53,6 @@ macvlan_post_stop()
_is_macvlan || return 0
 
ebegin "Removing MAC-VLAN ${IFACE}"
-   ip link delete "${IFACE}" type macvlan >/dev/null
+   ip link delete "${IFACE}" >/dev/null
eend $?
 }



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-31 Thread Robin H. Johnson
commit: dea30db8062977dc9b8a2c8611f09cf8c891d36f
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun May 31 05:52:43 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:52:47 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=dea30db8

net/ip6to4: partial fix for bug #528314

netifrc has never clearly documented exactly what shell is targeted, and
this bug does not occur on any shell that supports the 'local' keyword.

Reference: https://bugs.gentoo.org/528314
Signed-off-by: Robin H. Johnson  gentoo.org>

 net/ip6to4.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ip6to4.sh b/net/ip6to4.sh
index 21acd71..6b573d1 100644
--- a/net/ip6to4.sh
+++ b/net/ip6to4.sh
@@ -103,8 +103,8 @@ ip6to4_pre_start()
 
 ip6to4_start()
 {
-   local config_ip6to4=$(service_get_value "config_ip6to4_$IFVAR")
-   local routes_ip6to4=$(service_get_value "routes_ip6to4_$IFVAR")
+   local config_ip6to4="$(service_get_value "config_ip6to4_$IFVAR")"
+   local routes_ip6to4="$(service_get_value "routes_ip6to4_$IFVAR")"
 
# Now apply our config
eval config_${config_index}=\'"${config_ip6to4}"\'



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-30 Thread Robin H. Johnson
commit: 626cfdad15f9740208807bc436cb3915056c87b4
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun May 31 05:42:22 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:42:22 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=626cfdad

net/iproute2: support containers without /proc/sys/net/ipv4/route/flush

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

 net/iproute2.sh | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 5f65f1c..ca6c0f8 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -438,8 +438,18 @@ _iproute2_link_delete() {
eend $?
 }
 
+_iproute2_route_flush_supported() {
+   case $FAMILY in
+   -6) p='/proc/sys/net/ipv6/route/flush' ;;
+   -4|*) p='/proc/sys/net/ipv4/route/flush' ;;
+   esac
+   test -f $p
+}
+
 _iproute2_route_flush() {
-   _cmd ip $FAMILY route flush table cache dev "${IFACE}"
+   if _iproute2_route_flush_supported; then
+   _cmd ip $FAMILY route flush table cache dev "${IFACE}"
+   fi
 }
 
 _iproute2_ipv6_tentative_output() {



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-30 Thread Robin H. Johnson
commit: c0f36e9995b6e07b6691fa0c2d5c3a13223f9815
Author: Hans Fernhout  fernhout  info>
AuthorDate: Sun May 31 05:27:16 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:29:36 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=c0f36e99

net/iwd: add iwd helper

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

 net/iwd.sh | 53 +
 1 file changed, 53 insertions(+)

diff --git a/net/iwd.sh b/net/iwd.sh
new file mode 100644
index 000..afb5b22
--- /dev/null
+++ b/net/iwd.sh
@@ -0,0 +1,53 @@
+# Original copyright (c) 2007-2009 Roy Marples 
+# Released under the 2-clause BSD license.
+
+iwd_depend()
+{
+   need dbus
+   after macnet plug
+   before interface
+   provide wireless
+   after iwconfig
+}
+
+_config_vars="$_config_vars iwd"
+
+iwd_pre_start()
+{
+   local iwds=/usr/libexec/iwd
+   local args= opt= opts=
+   eval opts=\$iwd_${IFVAR}
+
+   #set a "safe" default in case phy was not defined
+   PHY="phy0"
+
+   for opt in ${opts}; do
+   case "${opt}" in
+   phy* )  PHY="${opt}"
+   einfo "Assigned PHY to be ${PHY}"
+   ;;
+   *)  ;;
+   esac
+   done
+   ebegin "Starting iwd on ${PHY} and ${IFVAR}"
+   pidfile="/run/iwd-${IFVAR}.pid"
+   start-stop-daemon --start --exec "${iwds}" --pidfile "${pidfile}" 
--background --verbose --make-pidfile -- -p ${PHY} -i "${IFVAR}"
+   return $?
+}
+
+
+iwd_post_stop()
+{
+   local iwds=/usr/libexec/iwd
+   pidfile="/run/iwd-${IFVAR}.pid"
+   if [ -f ${pidfile} ]; then
+   ebegin "Stopping iwd on ${IFACE}"
+   start-stop-daemon --stop --exec "${iwds}" --pidfile "${pidfile}"
+   eend $?
+   fi
+
+   # If iwd exits uncleanly, we need to remove the stale dir
+   [ -S "/run/iwd/${IFACE}" ] \
+   && rm -f "/run/iwd/${IFACE}"
+}
+



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-30 Thread Robin H. Johnson
commit: 8d16b31bfc457f03e0e761df19529749ffa1f0d8
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun May 31 05:29:07 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:29:40 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=8d16b31b

net/iwd: ensure program is present

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

 net/iwd.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/iwd.sh b/net/iwd.sh
index afb5b22..e3f64b2 100644
--- a/net/iwd.sh
+++ b/net/iwd.sh
@@ -8,6 +8,7 @@ iwd_depend()
before interface
provide wireless
after iwconfig
+   program iwd
 }
 
 _config_vars="$_config_vars iwd"



[gentoo-commits] proj/netifrc:master commit in: doc/

2020-05-30 Thread Robin H. Johnson
commit: 869d41ee7501ab6a2832c6e8cf232eb4b5060d93
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun May 31 05:23:37 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:23:37 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=869d41ee

doc: Document bridge_forward_delay/bridge_hello_time

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

 doc/net.example.Linux.in | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 8896acf..c211ca7 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -943,6 +943,7 @@
 # Bridging (802.1d)
 # Preferred: iproute2, emerge sys-apps/iproute2
 # Legacy: brctl, emerge net-misc/bridge-utils
+# # See https://wiki.gentoo.org/wiki/Network_bridge#OpenRC for further notes
 
 # To add ports to bridge br0
 #bridge_br0="eth0 eth1"
@@ -984,6 +985,15 @@
 #bridge_forward_delay_br0="10"
 #brport_hairpin_mode_eth0="1"
 
+# It is important to include bridge_forward_delay_br0=0 and
+# bridge_hello_time_br0=1000 in the /etc/conf.d/net file in order to bring the
+# bridge interface up quickly. Other values will cause network packets to be
+# dropped for the first 30 seconds after the bridge has become active. This, in
+# turn, could prevent DHCP from working as intended.
+#bridge_forward_delay_br0=0
+#bridge_hello_time_br0=1000
+
+
 #-
 # RFC 2684 Bridge Support
 # For RFC 2684 bridge support emerge net-misc/br2684ctl



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-30 Thread Robin H. Johnson
commit: b3848b828d4f1cabe9bda54a0d9da473e5df3e9a
Author: Lars Wendler  gentoo  org>
AuthorDate: Fri May 22 08:09:22 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:13:18 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b3848b82

net/dhcpcd.sh: Put user args into a temp file

So we still use the correct PID even if the user has changed his
configuration between start and stop.

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

 net/dhcpcd.sh | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index c0639e0..dcc6817 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -16,11 +16,14 @@ _config_vars="$_config_vars dhcp dhcpcd"
 
 dhcpcd_start()
 {
-   # check for pidfile after we gathered the user's opts because they can
+   # check for pidfile after we gathered the user's args because they can
# alter the pidfile's name (#718114)
-   local args= opt= pidfile= opts= new=true
+   # Save the args into a file so dhcpcd_stop can later re-use the very
+   # same args later.
+   local args= opt= pidfile= opts= new=true 
argsfile=/run/netifrc_dhcpcd_${IFACE}_args
eval args=\$dhcpcd_${IFVAR}
[ -z "${args}" ] && args=${dhcpcd}
+   echo "${args}" > ${argsfile}
pidfile="$(dhcpcd -P ${args} ${IFACE})"
 
# Get our options
@@ -78,12 +81,16 @@ dhcpcd_start()
 
 dhcpcd_stop()
 {
-   local args= pidfile= opts= sig=SIGTERM
+   local args= pidfile= opts= sig=SIGTERM 
argsfile=/run/netifrc_dhcpcd_${IFACE}_args
 
-   # check for pidfile after we gathered the user's opts because they can
+   # check for pidfile after we gathered the user's args because they can
# alter the pidfile's name (#718114)
-   eval args=\$dhcpcd_${IFVAR}
-   [ -z "${args}" ] && args=${dhcpcd}
+   if [ -f "${argsfile}" ] ; then
+   args="$(cat ${argsfile})"
+   else
+   eval args=\$dhcpcd_${IFVAR}
+   [ -z "${args}" ] && args=${dhcpcd}
+   fi
pidfile="$(dhcpcd -P ${args} ${IFACE})"
[ ! -f "${pidfile}" ] && return 0
 
@@ -94,5 +101,6 @@ dhcpcd_stop()
*" release "*) dhcpcd -k "${IFACE}" ;;
*) dhcpcd -x "${IFACE}" ;;
esac
+   [ -f "${argsfile}" ] && rm -f "${argsfile}"
eend $?
 }



[gentoo-commits] proj/netifrc:master commit in: net/

2020-05-30 Thread Robin H. Johnson
commit: dd5a41de524cfdebe47425e70513f95f9937e406
Author: Lars Wendler  gentoo  org>
AuthorDate: Thu May 21 16:35:32 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun May 31 05:13:17 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=dd5a41de

net/dhcpcd.sh: fetch pidfile location from dhcpcd

There's a -P switch for this but we also need to take into account the
-4 and -6 switches as they both alter the pidfile's name.

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

 net/dhcpcd.sh | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 0a306b8..c0639e0 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -16,9 +16,12 @@ _config_vars="$_config_vars dhcp dhcpcd"
 
 dhcpcd_start()
 {
-   local args= opt= opts= pidfile="/run/dhcpcd-${IFACE}.pid" new=true
+   # check for pidfile after we gathered the user's opts because they can
+   # alter the pidfile's name (#718114)
+   local args= opt= pidfile= opts= new=true
eval args=\$dhcpcd_${IFVAR}
[ -z "${args}" ] && args=${dhcpcd}
+   pidfile="$(dhcpcd -P ${args} ${IFACE})"
 
# Get our options
eval opts=\$dhcp_${IFVAR}
@@ -75,7 +78,13 @@ dhcpcd_start()
 
 dhcpcd_stop()
 {
-   local pidfile="/run/dhcpcd-${IFACE}.pid" opts= sig=SIGTERM
+   local args= pidfile= opts= sig=SIGTERM
+
+   # check for pidfile after we gathered the user's opts because they can
+   # alter the pidfile's name (#718114)
+   eval args=\$dhcpcd_${IFVAR}
+   [ -z "${args}" ] && args=${dhcpcd}
+   pidfile="$(dhcpcd -P ${args} ${IFACE})"
[ ! -f "${pidfile}" ] && return 0
 
ebegin "Stopping dhcpcd on ${IFACE}"



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

2020-01-04 Thread Robin H. Johnson
commit: ae59d8a6d448f96a53105dadccf8f0c9e01e91f3
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Jan  4 08:07:42 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Jan  4 08:07:42 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=ae59d8a6

Makefile: bump

This was missed for 0.7.0 tag, so introduce as 0.7.1 tag.

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

 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index b856105..37087b4 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -1,3 +1,3 @@
 NAME=  netifrc
-VERSION=   0.6.1
+VERSION=   0.7.1
 PKG=   ${NAME}-${VERSION}



[gentoo-commits] proj/netifrc:master commit in: net/

2020-01-04 Thread Robin H. Johnson
commit: 01704754311ada2c2154f501aebfda50710a185d
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sat Jan  4 08:02:40 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Jan  4 08:02:40 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=01704754

shellcheck: fix Double quote array expansions to avoid re-splitting elements. 
[SC2068]

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

 net/l2tp.sh | 2 +-
 net/pppd.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index 7c5b064..9644e32 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -81,7 +81,7 @@ _l2tp_get_tunnel_info() {
 
 _ip_l2tp_add() {
local e
-   e="$(LC_ALL=C ip l2tp add $@ 2>&1 1>/dev/null)"
+   e="$(LC_ALL=C ip l2tp add "$@" 2>&1 1>/dev/null)"
case $e in
"")
return 0

diff --git a/net/pppd.sh b/net/pppd.sh
index 796722e..e3c4d43 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -163,7 +163,7 @@ pppd_pre_start()
# We need to flatten the useless array
set -- $(_get_array "chat_${IFVAR}")
if [ $# != 0 ]; then
-   opts="${opts} connect '$(echo ${chatprog} $@ | sed -e 
"s:':''':g")'"
+   opts="${opts} connect '$(echo ${chatprog} "$@" | sed -e 
"s:':''':g")'"
fi
 
# Add plugins



[gentoo-commits] proj/netifrc:master commit in: net/

2020-01-04 Thread Robin H. Johnson
commit: 9472b0e2fd402819963f492fe9ba37c82c0de277
Author: Lars Wendler  gentoo  org>
AuthorDate: Fri Jan  3 20:30:28 2020 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sat Jan  4 07:58:21 2020 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=9472b0e2

pppd.sh: ppp-2.4.8 introduced "defaultroute-metric" option

That option name differs from the one we patched into previous pppd releases
so check if we are on >=2.4.8 version and use the correct option name
accordingly

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

 net/pppd.sh | 34 --
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/net/pppd.sh b/net/pppd.sh
index 6ca1396..796722e 100644
--- a/net/pppd.sh
+++ b/net/pppd.sh
@@ -21,6 +21,32 @@ requote()
printf "'%s' " "$@"
 }
 
+pppd_is_ge_248()
+{
+   local ver_str="$(/usr/sbin/pppd --version 2>&1 | 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)"
+
+   if [ "${maj_ver}" -gt 2 ] ; then
+   return 0
+   elif [ "${maj_ver}" -eq 2 ] ; then
+   if [ "${min_ver}" -gt 4 ] ; then
+   return 0
+   elif [ "${min_ver}" -eq 4 ] ; then
+   if [ "${patch_ver}" -ge 8 ] ; then
+   return 0
+   else
+   return 1
+   fi
+   else
+   return 1
+   fi
+   else
+   return 1
+   fi
+}
+
 pppd_pre_start()
 {
# Interface has to be called ppp
@@ -39,7 +65,10 @@ pppd_pre_start()
return 0
fi
 
-   local link= i= unit="${IFACE#ppp}" opts=
+   local link= i= unit="${IFACE#ppp}" opts= routemetric=defaultmetric
+
+   # 
https://github.com/paulusmack/ppp/commit/35e5a569c988b1ff865b02a24d9a727a00db4da9
+   pppd_is_ge_248 && routemetric=defaultroute-metric
 
# PPP requires a link to communicate over - normally a serial port
# PPPoE communicates over Ethernet
@@ -76,6 +105,7 @@ pppd_pre_start()
return 1
;;
defaultmetric) hasdefaultmetric=true;;
+   defaultroute-metric) hasdefaultmetric=true;;
mtu) hasmtu=true;;
mru) hasmru=true;;
maxfail) hasmaxfail=true;;
@@ -98,7 +128,7 @@ pppd_pre_start()
local m=
eval m=\$metric_${IFVAR}
[ -z "${m}" ] && : $(( m = metric + $(_ifindex) ))
-   opts="${opts} defaultmetric ${m}"
+   opts="${opts} ${routemetric} ${m}"
fi
if [ -n "${mtu}" ]; then
${hasmtu} || opts="${opts} mtu ${mtu}"



[gentoo-commits] proj/netifrc:master commit in: net/

2019-07-09 Thread Ben Kohler
commit: 43f0190924f8c721ebccd75a2d6b99671905bedf
Author: Ben Kohler  gentoo  org>
AuthorDate: Tue Jul  9 19:42:16 2019 +
Commit: Ben Kohler  gentoo  org>
CommitDate: Tue Jul  9 19:42:16 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=43f01909

net/*: fix ordering of dhcp clients

We want to prefer dhclient over busybox udhcpc if it's available.  This
commit also adds deps to the other services which will guarantee the
priority dhcpcd > dhclient > pump > udhcpc.

Signed-off-by: Ben Kohler  gentoo.org>

 net/dhclient.sh | 3 +++
 net/dhcpcd.sh   | 4 ++--
 net/pump.sh | 3 +++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/dhclient.sh b/net/dhclient.sh
index fd27308..24c3512 100644
--- a/net/dhclient.sh
+++ b/net/dhclient.sh
@@ -7,6 +7,9 @@ dhclient_depend()
after interface
program start /sbin/dhclient
provide dhcp
+
+   # We prefer dhclient over these
+   after udhcpc pump
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/dhcpcd.sh b/net/dhcpcd.sh
index 1812b45..0a306b8 100644
--- a/net/dhcpcd.sh
+++ b/net/dhcpcd.sh
@@ -8,8 +8,8 @@ dhcpcd_depend()
program start dhcpcd
provide dhcp
 
-   # We prefer dhcpcd over the others
-   after dhclient pump udhcpc
+   # We prefer dhcpcd over these
+   after udhcpc pump dhclient
 }
 
 _config_vars="$_config_vars dhcp dhcpcd"

diff --git a/net/pump.sh b/net/pump.sh
index 270b37d..864b6cf 100644
--- a/net/pump.sh
+++ b/net/pump.sh
@@ -7,6 +7,9 @@ pump_depend()
program /sbin/pump
after interface
provide dhcp
+
+   # We prefer pump over udhcpc
+   after udhcpc
 }
 
 _config_vars="$_config_vars dhcp pump"



[gentoo-commits] proj/netifrc:master commit in: net/

2019-07-09 Thread Ben Kohler
commit: 3392e908a2e3afceb399a1eb56e05c479aad42da
Author: Ben Kohler  gentoo  org>
AuthorDate: Tue Jul  9 19:59:09 2019 +
Commit: Ben Kohler  gentoo  org>
CommitDate: Tue Jul  9 19:59:09 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=3392e908

net/iw.sh: minor whitespace fix

Signed-off-by: Ben Kohler  gentoo.org>

 net/iw.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/iw.sh b/net/iw.sh
index 5462244..82b9ba9 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -12,8 +12,8 @@ iw_depend()
after plug
before interface
provide wireless
-# Prefer us over iwconfig
-after iwconfig
+   # Prefer us over iwconfig
+   after iwconfig
 }
 
 _get_ssid()



[gentoo-commits] proj/netifrc:master commit in: net/

2019-07-09 Thread Ben Kohler
commit: b8be61112499d3fc1681edb21f240bfeb9eeafe1
Author: Ben Kohler  gentoo  org>
AuthorDate: Tue Jul  9 17:38:37 2019 +
Commit: Ben Kohler  gentoo  org>
CommitDate: Tue Jul  9 17:38:37 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b8be6111

net/system.sh: change net-scripts to netifrc in output

Signed-off-by: Ben Kohler  gentoo.org>

 net/system.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/system.sh b/net/system.sh
index 1f81493..0b65379 100644
--- a/net/system.sh
+++ b/net/system.sh
@@ -34,7 +34,7 @@ _system_dns()
[ -z "${servers}" -a -z "${domain}" -a -z "${search}" \
-a -z "${sortlist}" -a -z "${options}" ] && return 0
 
-   local buffer="# Generated by net-scripts for interface ${IFACE}\n"
+   local buffer="# Generated by netifrc for interface ${IFACE}\n"
[ -n "${domain}" ] && buffer="${buffer}domain ${domain}\n"
[ -n "${search}" ] && buffer="${buffer}search ${search}\n"
 
@@ -67,7 +67,7 @@ _system_ntp()
[ -z "${servers}" ] && servers=${ntp_servers}
[ -z "${servers}" ] && return 0
 
-   buffer="# Generated by net-scripts for interface ${IFACE}\n"
+   buffer="# Generated by netifrc for interface ${IFACE}\n"
buffer="${buffer}restrict default noquery notrust nomodify\n"
buffer="${buffer}restrict 127.0.0.1\n"
 
@@ -92,7 +92,7 @@ _system_nis()
 
[ -z "${servers}" -a -z "${domain}" ] && return 0
 
-   buffer="# Generated by net-scripts for interface ${iface}\n"
+   buffer="# Generated by netifrc for interface ${iface}\n"
 
if [ -n "${domain}" ]; then
hostname -y "${domain}"



[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: sh/

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

sh/udhcpc-hook.sh: shellcheck fixes

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

 sh/udhcpc-hook.sh.in | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sh/udhcpc-hook.sh.in b/sh/udhcpc-hook.sh.in
index 13ea336..e4300c1 100644
--- a/sh/udhcpc-hook.sh.in
+++ b/sh/udhcpc-hook.sh.in
@@ -68,7 +68,7 @@ update_classless_routes()
max_routes=128
metric=
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"
-   while [ -n "$1" -a -n "$2" -a $max_routes -gt 0 ]; do
+   while [ -n "$1" ] && [ -n "$2" ] && [ $max_routes -gt 0 ]; do
gw_arg=
if [ "$2" != '0.0.0.0' ]; then
gw_arg="gw $2"
@@ -76,7 +76,7 @@ update_classless_routes()
 
[ ${1##*/} -eq 32 ] && type=host || type=net
route add -$type "$1" ${gw_arg} ${metric} dev 
"${interface}"
-   max=$(($max-1))
+   max=$((max-1))
shift 2
done
fi
@@ -90,7 +90,7 @@ update_routes()
 
# If the DHCP server returns both a Classless Static Routes option and
# a Router option, the DHCP client MUST ignore the Router option.
-   if [ -n "${router}" -a -z "${staticroutes}" ] ; then
+   if [ -n "${router}" ] && [ -z "${staticroutes}" ] ; then
metric=
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"
for i in ${router} ; do
@@ -115,6 +115,7 @@ deconfig()
 }
 
 if [ -r "/run/udhcpc-${interface}.conf" ]; then
+   # shellcheck disable=SC1090
. "/run/udhcpc-${interface}.conf"
 fi
 



[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: mk/

2019-04-20 Thread Robin H. Johnson
commit: 7a7e77357cca8d3e530cb96cf7a6ea0d879ba8e6
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 05:16:49 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 05:16:49 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=7a7e7735

shellcheck: turn off some checks to start

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

 mk/scripts.mk | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mk/scripts.mk b/mk/scripts.mk
index 7e512f0..d278ac1 100644
--- a/mk/scripts.mk
+++ b/mk/scripts.mk
@@ -14,7 +14,13 @@ _LCL_SED:=   $(shell ${_LCL_SED_SH})
 
 SED_REPLACE=   -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 
's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@CONFDIR@:${CONFDIR}:g' -e 
's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 
's:@BINDIR@:${BINDIR}:g' -e 's:@SBINDIR@:${SBINDIR}:g' -e 
's:@INITDIR@:${INITDIR}:g' ${_PKG_SED} ${_LCL_SED}
 
-SHELLCHECK_CMD = shellcheck -s sh --exclude SC1008 -f gcc
+# SC1008: shebang
+# SC2039: warning: In POSIX sh, 'local' is undefined.
+# SC2086: splitting
+# SC2155: declare/assign
+# warning: domain is referenced but not assigned. [SC2154]
+# note: Don't use variables in the printf format string. Use printf "..%s.." 
"$foo". [SC2059]
+SHELLCHECK_CMD = shellcheck -s sh --exclude 
SC1008,SC2039,SC2086,SC2155,SC2154,SC2059 -f gcc
 
 # Tweak our shell scripts
 %.sh: %.sh.in
@@ -57,7 +63,8 @@ CLEANFILES+=  ${OBJS}
 clean:
@if test -n "${CLEANFILES}"; then echo "rm -f ${CLEANFILES}"; rm -f 
${CLEANFILES}; fi
 
-shellcheck: ${SRCS}
-   @$(SHELLCHECK_CMD) $<
+shellcheck: $(filter net.lo.in net.example.in %.sh.in, ${SRCS}) $(filter %.sh, 
${INC})
+   @${ECHO} CHECKING $^
+   @$(SHELLCHECK_CMD) $^
 
 include ${MK}/gitignore.mk



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

2019-04-20 Thread Robin H. Johnson
commit: eab4e8b40431c0162a6dadd7cd3c020072b83280
Author: Robin H. Johnson  gentoo  org>
AuthorDate: Sun Apr 21 04:29:40 2019 +
Commit: Robin H. Johnson  gentoo  org>
CommitDate: Sun Apr 21 04:29:40 2019 +
URL:https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=eab4e8b4

Add shellcheck tooling

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

 init.d/net.lo.in| 1 +
 mk/scripts.mk   | 5 +
 mk/subdir.mk| 2 ++
 net/adsl.sh | 1 +
 net/apipa.sh| 1 +
 net/arping.sh   | 1 +
 net/bonding.sh  | 1 +
 net/br2684ctl.sh| 1 +
 net/bridge.sh   | 1 +
 net/ccwgroup.sh | 1 +
 net/clip.sh | 1 +
 net/dhclient.sh | 1 +
 net/dhcpcd.sh   | 1 +
 net/dummy.sh| 1 +
 net/ethtool.sh  | 1 +
 net/firewalld.sh| 1 +
 net/hsr.sh  | 1 +
 net/ifconfig.sh.BSD.in  | 1 +
 net/ifconfig.sh.Linux.in| 1 +
 net/ifplugd.sh  | 1 +
 net/ifwatchd.sh.BSD.in  | 1 +
 net/ip6rd.sh| 1 +
 net/ip6to4.sh   | 1 +
 net/ipppd.sh| 1 +
 net/iproute2.sh | 1 +
 net/iw.sh   | 1 +
 net/iwconfig.sh.BSD.in  | 1 +
 net/iwconfig.sh.Linux.in| 1 +
 net/l2tp.sh | 1 +
 net/macchanger.sh   | 1 +
 net/macnet.sh   | 1 +
 net/macvlan.sh  | 1 +
 net/netplugd.sh | 1 +
 net/pppd.sh | 1 +
 net/pump.sh | 1 +
 net/ssidnet.sh  | 1 +
 net/system.sh   | 1 +
 net/tuntap.sh   | 1 +
 net/udhcpc.sh.Linux.in  | 1 +
 net/veth.sh | 1 +
 net/vlan.sh | 1 +
 net/wireguard.sh| 1 +
 net/wpa_supplicant.sh   | 1 +
 sh/functions.sh | 1 +
 sh/ifwatchd-carrier.sh.in   | 1 +
 sh/ifwatchd-nocarrier.sh.in | 1 +
 sh/systemd-wrapper.sh.in| 1 +
 sh/udhcpc-hook.sh.in| 1 +
 48 files changed, 53 insertions(+)

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 472ed0c..3afe046 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -1,4 +1,5 @@
 #!@SBINDIR@/openrc-run
+# shellcheck shell=sh disable=SC1008
 # Copyright (c) 2007-2009 Roy Marples 
 # Copyright (c) 2010-2016 Gentoo Foundation
 # Released under the 2-clause BSD license.

diff --git a/mk/scripts.mk b/mk/scripts.mk
index 736132a..7e512f0 100644
--- a/mk/scripts.mk
+++ b/mk/scripts.mk
@@ -14,6 +14,8 @@ _LCL_SED:=$(shell ${_LCL_SED_SH})
 
 SED_REPLACE=   -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 
's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@CONFDIR@:${CONFDIR}:g' -e 
's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 
's:@BINDIR@:${BINDIR}:g' -e 's:@SBINDIR@:${SBINDIR}:g' -e 
's:@INITDIR@:${INITDIR}:g' ${_PKG_SED} ${_LCL_SED}
 
+SHELLCHECK_CMD = shellcheck -s sh --exclude SC1008 -f gcc
+
 # Tweak our shell scripts
 %.sh: %.sh.in
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
@@ -55,4 +57,7 @@ CLEANFILES+=  ${OBJS}
 clean:
@if test -n "${CLEANFILES}"; then echo "rm -f ${CLEANFILES}"; rm -f 
${CLEANFILES}; fi
 
+shellcheck: ${SRCS}
+   @$(SHELLCHECK_CMD) $<
+
 include ${MK}/gitignore.mk

diff --git a/mk/subdir.mk b/mk/subdir.mk
index 7f198f8..4224b5f 100644
--- a/mk/subdir.mk
+++ b/mk/subdir.mk
@@ -29,3 +29,5 @@ depend:
${_SUBDIR}
 ignore:
${_SUBDIR}
+shellcheck:
+   ${_SUBDIR}

diff --git a/net/adsl.sh b/net/adsl.sh
index 4bfe51f..7724710 100644
--- a/net/adsl.sh
+++ b/net/adsl.sh
@@ -1,6 +1,7 @@
 # Copyright (c) 2004-2007 Gentoo Foundation
 # Copyright (c) 2007-2008 Roy Marples 
 # Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
 
 adsl_depend()
 {

diff --git a/net/apipa.sh b/net/apipa.sh
index 6f3f910..849728b 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -1,5 +1,6 @@
 # Copyright (c) 2007-2008 Roy Marples 
 # Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
 
 apipa_depend()
 {

diff --git a/net/arping.sh b/net/arping.sh
index b03b8a9..7e178b7 100644
--- a/net/arping.sh
+++ b/net/arping.sh
@@ -1,5 +1,6 @@
 # Copyright (c) 2007-2008 Roy Marples 
 # Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
 
 arping_depend()
 {

diff --git a/net/bonding.sh b/net/bonding.sh
index 6e5d810..880f69b 100644
--- a/net/bonding.sh
+++ b/net/bonding.sh
@@ -1,6 +1,7 @@
 # Copyright (c) 2007-2008 Roy Marples 
 #   2017  Marc Schiffbauer 
 # Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
 
 bonding_depend()
 {

diff --git a/net/br2684ctl.sh b/net/br2684ctl.sh
index 8e48016..c3c9d41 100644
--- a/net/br2684ctl.sh
+++ b/net/br2684ctl.sh
@@ -1,5 +1,6 @@
 # Copyright (c) 2007-2008 Roy Marples 
 # Released under the 2-clause BSD license.
+# shellcheck shell=sh disable=SC1008
 
 br2684ctl_depend()
 {

diff --git 

[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}"
)



  1   2   3   >