diff options
author | 2005-11-22 13:39:09 +0000 | |
---|---|---|
committer | 2005-11-22 13:39:09 +0000 | |
commit | c88e338f00648357db221147be2c39cabdbd5dc7 (patch) | |
tree | 03f0d4bd79d12b4982e67f26df15bbdcf16a12a5 | |
parent | Merging uberlord's latest changes of baselayout (r1613). (diff) | |
download | baselayout-vserver-c88e338f00648357db221147be2c39cabdbd5dc7.tar.gz baselayout-vserver-c88e338f00648357db221147be2c39cabdbd5dc7.tar.bz2 baselayout-vserver-c88e338f00648357db221147be2c39cabdbd5dc7.zip |
Merging latest changes from baselayout (r1621).
svn path=/baselayout-vserver/trunk/; revision=68
35 files changed, 742 insertions, 555 deletions
@@ -1,9 +1,29 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2 + 21 Nov 2005; Roy Marples <uberlord@gentoo.org>: + + Fix wpa_suppicant error when auth is IEEE 802.1X (NO WPA) #112938. + + 20 Nov 2005; Mike Frysinger <vapier@gentoo.org>: + + Call reboot with -k to support people who want to use kexec #80220. + + Source /etc/profile.d/*.sh files in /etc/profile #4854. + + 18 Nov 2005; Roy Marples <uberlord@gentoo.org>: + + Changed from eval foo=\"\$config_$ifvar\" to foo=config_$ivar; foo=$!foo + This is to avoid using the eval statement to extract user configured vars. + + Enhanced pppd module so that it obeys metric routes, does not mess + with the system resolv.conf and works with updetach a bit better, #112049. + + Fixed pointotpoint, #112757 thanks to Felix Braun. + 10 Nov 2005; Martin Schlemmer <azarah@gentoo.org>: - Fix for bug #104288. + Fix module-update searching for System.map in /usr/src/linux #104288. 10 Nov 2005; Roy Marples <uberlord@gentoo.org>: diff --git a/ChangeLog.vserver b/ChangeLog.vserver index c7b2e8e..5fb9124 100644 --- a/ChangeLog.vserver +++ b/ChangeLog.vserver @@ -1,6 +1,45 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2 + 22 Nov 2005; Christian Heim <phreak@gentoo.org>: + Merging latest changes from baselayout (r1621). + + ChangeLog | 22 + + ChangeLog.vserver | 40 + + etc/profile | 7 + net-scripts/init.d/net.lo | 35 + + net-scripts/net.modules.d/adsl | 4 + net-scripts/net.modules.d/arping | 20 + net-scripts/net.modules.d/bonding | 15 + net-scripts/net.modules.d/bridge | 31 - + net-scripts/net.modules.d/dhclient | 36 - + net-scripts/net.modules.d/dhcpcd | 33 - + net-scripts/net.modules.d/essidnet | 4 + net-scripts/net.modules.d/helpers.d/dhclient-wrapper | 2 + net-scripts/net.modules.d/helpers.d/dhcp | 22 - + net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper | 18 + net-scripts/net.modules.d/helpers.d/functions | 30 - + net-scripts/net.modules.d/helpers.d/pump-wrapper | 9 + net-scripts/net.modules.d/ifconfig | 63 ++- + net-scripts/net.modules.d/ifplugd | 12 + net-scripts/net.modules.d/ipppd | 22 - + net-scripts/net.modules.d/iproute2 | 68 ++- + net-scripts/net.modules.d/iptunnel | 6 + net-scripts/net.modules.d/iwconfig | 123 +++-- + net-scripts/net.modules.d/macchanger | 6 + net-scripts/net.modules.d/macnet | 2 + net-scripts/net.modules.d/netplugd | 3 + net-scripts/net.modules.d/pppd | 394 ++++++++++--------- + net-scripts/net.modules.d/pump | 32 - + net-scripts/net.modules.d/rename | 18 + net-scripts/net.modules.d/system | 66 +-- + net-scripts/net.modules.d/tuntap | 4 + net-scripts/net.modules.d/udhcpc | 21 - + net-scripts/net.modules.d/vlan | 19 + net-scripts/net.modules.d/wpa_supplicant | 14 + src/env_whitelist | 7 + 34 files changed, 677 insertions(+), 531 deletions(-) + 10 Nov 2005; Christian Heim <phreak@gentoo.org>: Merging uberlord's latest changes of baselayout (r1613). @@ -15,7 +54,6 @@ net-scripts/net.modules.d/wpa_supplicant | 27 +++++++++----- 8 files changed, 96 insertions(+), 46 deletions(-) - 08 Nov 2005; Christian Heim <phreak@gentoo.org>: Merging uberlord's latest changes of baselayout (r1604). diff --git a/etc/profile b/etc/profile index 835b0ab..f347430 100644 --- a/etc/profile +++ b/etc/profile @@ -56,3 +56,10 @@ else # understand sequences such as \h, don't put anything special in it. PS1="`whoami`@`uname -n | cut -f1 -d.` \$ " fi + +for sh in /etc/profile.d/*.sh ; do + if [ -r "$sh" ] ; then + . "$sh" + fi +done +unset sh diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo index a02fb85..feae34e 100755 --- a/net-scripts/init.d/net.lo +++ b/net-scripts/init.d/net.lo @@ -179,7 +179,8 @@ modules_check_user() { local i j k l nmods="${#MODULES[@]}" # Has the interface got any specific modules? - eval umods=( \"\$\{modules_${iface}\[@\]\}\" ) + umods="modules_${iface}[@]" + umods=( "${!umods}" ) # Global setting follows interface-specific setting umods=( "${umods[@]}" "${modules[@]}" ) @@ -415,8 +416,8 @@ modules_load() { local -a PROVIDES WRAP_MODULES if [[ ${iface} != "lo" ]]; then - eval x=( \"\$\{modules_force_${iface}\[@\]\}\" ) - [[ -n ${x} ]] && modules_force=( "${x[@]}" ) + x="modules_force_${iface}[@]" + [[ -n ${!x} ]] && modules_force=( "${!x}" ) if [[ -n ${modules_force} ]]; then ewarn "WARNING: You are forcing modules!" ewarn "Do not complain or file bugs if things start breaking" @@ -516,8 +517,8 @@ iface_start() { local ifvar=$( bash_variable "$1" ) i j # Try and work out a metric for the interface if we're on auto - eval x=\"\$\{metric_${ifvar}\}\" - if [[ -z ${x} ]]; then + x="metric_${ifvar}" + if [[ -z ${!x} ]]; then if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then eval "metric_${ifvar}=\""$( calculate_metric ${iface} )"\"" else @@ -535,20 +536,23 @@ iface_start() { # We now expand the configuration parameters and pray that the # fallbacks expand to the same number as config or there will be # trouble! - eval a=( \"\$\{config_${ifvar}\[@\]\}\" ) + a="config_${ifvar}[@]" + a=( "${!a}" ) for (( i=0; i<${#a[@]}; i++ )); do local -a b=( $( expand_parameters "${a[i]}" ) ) config=( "${config[@]}" "${b[@]}" ) done - eval a=( \"\$\{fallback_${ifvar}\[@\]\}\" ) + a="fallback_${ifvar}[@]" + a=( "${!a}" ) for (( i=0; i<${#a[@]}; i++ )); do local -a b=( $( expand_parameters "${a[i]}" ) ) fallback=( "${fallback[@]}" "${b[@]}" ) done # We don't expand routes - eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" ) + fallback_route="fallback_route_${ifvar}[@]" + fallback_route=( "${!fallback_route}" ) # We must support old configs if [[ -z ${config} ]]; then @@ -635,7 +639,8 @@ iface_start() { # Do we have a fallback route? if [[ -n ${fallback_route[config_counter]} ]]; then - eval "routes_${ifvar}=( "\"\$\{fallback_route\[${config_counter}\]\[@\]\}\"" )" + x="fallback_route[config_counter]" + eval "routes_${ifvar}=( ${!x} )" fallback_route[config_counter]="" fi @@ -762,17 +767,19 @@ run_start() { # If config is set to noop and the interface is up with an address # then we don't start it local config - eval config=( \"\$\{config_${IFVAR}\[@\]\}\" ) + config="config_${IFVAR}[@]" + config=( "${!config}" ) if [[ ${config[0]} == "noop" ]] && interface_is_up "${iface}" true ; then einfo "Keeping current configuration for ${iface}" eend 0 else # Remove noop from the config var [[ ${config[0]} == "noop" ]] \ - && eval "config_${IFVAR}=( "\"\$\{config\[@\]:1\}\"" )" + && eval "config_${IFVAR}=( "\"\$\{config\[@\]:1\}\"" )" # There may be existing ip address info - so we strip it - interface_del_addresses "${iface}" + [[ ${RC_INTERFACE_KEEP_CONFIG} != "yes" ]] \ + && interface_del_addresses "${iface}" # Start the interface if ! iface_start "${iface}" ; then @@ -937,8 +944,8 @@ start() { # If we've been called by hotplug, check if we have # a policy for the interface for not starting local x ifvar=$( bash_variable "${IFACE}" ) - eval x=\"\$\{hotplug_${ifvar}\}\" - if [[ ${x} == "no" || ${x} == "false" ]]; then + x="hotplug_${ifvar}" + if [[ ${!x} == "no" || ${!x} == "false" ]]; then eerror "Not starting interface ${IFACE} due to hotplug policy" unset -f exit mark_service_stopped "net.${IFACE}" diff --git a/net-scripts/net.modules.d/adsl b/net-scripts/net.modules.d/adsl index dbf6be7..facf9fd 100644 --- a/net-scripts/net.modules.d/adsl +++ b/net-scripts/net.modules.d/adsl @@ -59,14 +59,14 @@ adsl_start() { adsl_setup_vars "${iface}" start || return 1 # Might or might not be set in conf.d/net - eval user=\"\$\{adsl_user_${ifvar}\}\" + user="adsl_user_${ifvar}" # Start ADSL with the cfgfile, but override ETH and PIDFILE einfo "Starting ADSL for ${iface}" ${exe} <(cat "${cfgfile}"; \ echo "ETH=${iface}"; \ echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid"; \ - [[ -n ${user} ]] && echo "USER=${user}") \ + [[ -n ${!user} ]] && echo "USER=${!user}") \ >/dev/null eend $? } diff --git a/net-scripts/net.modules.d/arping b/net-scripts/net.modules.d/arping index aed04e7..1f2323b 100644 --- a/net-scripts/net.modules.d/arping +++ b/net-scripts/net.modules.d/arping @@ -63,15 +63,15 @@ arping_start() { einfo "Pinging gateways on ${iface} for configuration" - eval gateways=\"\$\{arping_${ifvar}\}\" - if [[ -z ${gateways} ]]; then + gateways="gateways_${ifvar}" + if [[ -z ${!gateways} ]]; then eerror "No gateways have been defined (gateways_${ifvar}=\"...\")" return 1 fi eindent - for x in ${gateways}; do + for x in "${!gateways}"; do vebegin "${x}" if arping_address_exists "${iface}" "${x}" ; then for i in ${x//./ } ; do @@ -87,9 +87,17 @@ arping_start() { eoutdent veinfo "Configuring ${iface} for ${x}" configure_variables "${iface}" "${conf}" - eval config=( \"\$\{config_${ifvar}\[@\]\}\" ) - eval fallback_config=( \"\$\{fallback_config_${ifvar}\[@\]\}\" ) - eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" ) + + # Call the system module as we've aleady passed it by .... + # And it *has* to be pre_start for other things to work correctly + system_pre_start "${iface}" + + t="config_${ifvar}[@]" + config=( "${!t}" ) + t="fallback_config_${ifvar}[@]" + fallback_config=( "${!t}" ) + t="fallback_route_${ifvar}[@]" + fallback_route=( "${!t}" ) config_counter=-1 return 0 fi diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding index 8a9b13f..9b93ef9 100644 --- a/net-scripts/net.modules.d/bonding +++ b/net-scripts/net.modules.d/bonding @@ -28,10 +28,11 @@ bonding_check_installed() { # # Bonds the interface bonding_pre_start() { - local iface="$1" slaves s ifvar=$( bash_variable "$1" ) + local iface="$1" s ifvar=$( bash_variable "$1" ) + local -a slaves - eval slaves=\"\$\{slaves_${ifvar}\[@\]\}\" - [[ -z ${slaves} ]] && return 0 + slaves="slaves_${ifvar}[@]" + [[ -z ${!slaves} ]] && return 0 interface_exists "${iface}" true || return 1 @@ -42,17 +43,17 @@ bonding_pre_start() { ebegin "Adding slaves to ${iface}" eindent - einfo "${slaves}" + einfo "${!slaves}" # Check that our slaves exist - for s in ${slaves}; do + for s in "${!slaves}" ; do interface_exists "${s}" && continue ewarn "interface ${s} does not exist" return 1 done # Must force the slaves to a particular state before adding them - for s in ${slaves}; do + for s in "${!slaves}" ; do interface_del_addresses "${s}" interface_up "${s}" done @@ -62,7 +63,7 @@ bonding_pre_start() { # finally add in slaves eoutdent - /sbin/ifenslave "${iface}" ${slaves} >/dev/null + /sbin/ifenslave "${iface}" "${!slaves}" >/dev/null eend $? return 0 #important diff --git a/net-scripts/net.modules.d/bridge b/net-scripts/net.modules.d/bridge index a44aa9a..6780a18 100644 --- a/net-scripts/net.modules.d/bridge +++ b/net-scripts/net.modules.d/bridge @@ -63,8 +63,7 @@ bridge_exists() { # Creates the bridge - no ports are added here though # Returns 0 on success otherwise 1 bridge_create() { - local iface="$1" ifvar=$( bash_variable "$1" ) x i - local -a opts + local iface="$1" ifvar=$( bash_variable "$1" ) x i opts ebegin "Creating bridge ${iface}" x=$( brctl addbr "${iface}" 2>&1 ) @@ -77,10 +76,10 @@ bridge_create() { return 1 fi - eval opts=( \"\$\{brctl_${ifvar}\[@\]\}\" ) - for (( i=0; i<${#opts[@]}; i++ )); do - x="${opts[i]/ / ${iface} }" - [[ ${x} == "${opts[i]}" ]] && x="${x} ${iface}" + opts="brctl_${ifvar}[@]" + for i in "${!opts}" ; do + x="${i/ / ${iface} }" + [[ ${x} == "${i}" ]] && x="${x} ${iface}" x=$( brctl ${x} 2>&1 1>/dev/null ) [[ -n ${x} ]] && ewarn "${x}" done @@ -119,35 +118,35 @@ bridge_delete_port() { # dynamically bridge_pre_start() { local iface="$1" ports briface i ifvar=$( bash_variable "$1" ) opts - eval ports=\"\$\{bridge_${ifvar}\[@\]\}\" - eval briface=\"\$\{bridge_add_${ifvar}\}\" - eval opts=\"\$\{brctl_${ifvar}\}\" + ports="bridge_${ifvar}[@]" + briface="bridge_add_${ifvar}" + opts="brctl_${ifvar}[@]" - [[ -z ${ports} && -z ${briface} && -z ${opts} ]] && return 0 + [[ -z ${!ports} && -z ${!briface} && -z ${!opts} ]] && return 0 # Destroy the bridge if it exists - [[ -n ${ports} ]] && bridge_stop "${iface}" + [[ -n ${!ports} ]] && bridge_stop "${iface}" # Allow ourselves to add to the bridge - if [[ -z ${ports} && -n ${briface} ]]; then + if [[ -z ${!ports} && -n ${!briface} ]]; then ports="${iface}" - iface="${briface}" + iface="${!briface}" fi # Create the bridge if needed bridge_exists "${iface}" || bridge_create "${iface}" - if [[ -n ${ports} ]]; then + if [[ -n ${!ports} ]]; then einfo "Adding ports to ${iface}" eindent - for i in ${ports}; do + for i in ${!ports}; do interface_exists "${i}" && continue eerror "interface ${i} does not exist" return 1 done - for i in ${ports}; do + for i in ${!ports}; do ebegin "${i}" bridge_add_port "${iface}" "${i}" eend $? || return 1 diff --git a/net-scripts/net.modules.d/dhclient b/net-scripts/net.modules.d/dhclient index 72290b1..37861b0 100644 --- a/net-scripts/net.modules.d/dhclient +++ b/net-scripts/net.modules.d/dhclient @@ -45,17 +45,16 @@ dhclient_stop() { local pid=$( < "${pidfile}" ) local ifvar=$( bash_variable "${iface}" ) - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " + d="dhcp_${ifvar}[@]" ebegin "Stopping dhclient on ${iface}" - if [[ ${d} == *" release "* ]]; then + if [[ " ${!d} " == *" release "* ]]; then local r=$( dhclient -q -r -pf "${pidfile}" \ - -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" "${iface}" ) + -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" "${iface}" ) [[ ${r} == "deconfig" ]] eend $? "dhclient returned a ${r}" [[ -f "/var/cache/dhcp-${iface}.lease" ]] \ - && rm -f "/var/cache/dhcp-${iface}.lease" + && rm -f "/var/cache/dhcp-${iface}.lease" else kill -s TERM "${pid}" 2>/dev/null clean_pidfile "${pidfile}" @@ -71,23 +70,23 @@ dhclient_stop() { # # Returns 0 (true) when a DHCP address is obtained, otherwise 1 dhclient_start() { - local iface="$1" opts ifvar=$( bash_variable "$1" ) + local iface="$1" opts ifvar=$( bash_variable "$1" ) d local pidfile="/var/run/dhclient-${iface}.pid" edit="" local cffile="/etc/dhcp/dhclient.conf" - local d interface_exists "${iface}" true || return 1 - eval edit=\"\$\{dhclient_edit_config_${ifvar}\}\" - [[ -z ${edit} ]] && eval edit="${dhclient_edit_config:-no}" - if [[ ${edit} == "yes" || ${edit} == "true" ]]; then + edit="dhclient_edit_config_${ifvar}" + [[ -z ${!edit} ]] && edit="dhclient_edit_config" + if [[ ${!edit} == "yes" || ${!edit} == "true" ]]; then edit=true else edit=false fi # Load our options - eval opts=\" \$\{dhclient_${ifvar}\} \" + opts="dhclient_${ifvar}" + opts="${!opts}" # Work out our cffile x="${opts##* -cf }" @@ -115,11 +114,10 @@ dhclient_start() { ${edit} && touch "${cffile}" 2>/dev/null fi - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " + d="dhcp_${ifvar}" # Send our hostname by editing cffile - if ${edit} && [[ -e ${cffile} && ${d} != *" nosendhost "* ]] ; then + if ${edit} && [[ -e ${cffile} && " ${!d} " != *" nosendhost "* ]] ; then local hname=$( hostname ) if [[ ${hname} != "(none)" && ${hname} != "localhost" ]]; then sed -i '/^[ \t]*send[ \t]*host-name[ \t]*/d' "${cffile}" @@ -138,15 +136,15 @@ dhclient_start() { dhclient_stop "${iface}" if [[ ${background} == "yes" ]]; then - eval dhclient ${opts} -pf "${pidfile}" -q \ - -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" \ - "${iface}" &>/dev/null & + eval dhclient "${opts}" -pf "${pidfile}" -q \ + -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" \ + "${iface}" &>/dev/null & eend 0 go_background fi - local x=$( eval dhclient ${opts} -1 -pf "${pidfile}" \ - -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" -q "${iface}" 2>&1 ) + local x=$( eval dhclient "${opts}" -1 -pf "${pidfile}" \ + -sf "${MODULES_DIR}/helpers.d/dhclient-wrapper" -q "${iface}" 2>&1 ) # We just check the last 5 letters [[ ${x:${#x} - 5:5} == "bound" ]] if [[ $? != "0" ]]; then diff --git a/net-scripts/net.modules.d/dhcpcd b/net-scripts/net.modules.d/dhcpcd index ea50e30..8101822 100644 --- a/net-scripts/net.modules.d/dhcpcd +++ b/net-scripts/net.modules.d/dhcpcd @@ -52,7 +52,7 @@ dhcpcd_get_vars() { # Returns 0 (true) when a DHCP address dropped # otherwise return 1 dhcpcd_stop() { - local iface=$1 count signal pidfile="/var/run/dhcpcd-$1.pid" d + local iface=$1 count signal pidfile="/var/run/dhcpcd-$1.pid" opts [[ ! -f ${pidfile} ]] && return 0 @@ -60,10 +60,9 @@ dhcpcd_stop() { local pid=$( < "${pidfile}" ) local ifvar=$( bash_variable "${iface}" ) - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " + opts="dhcp_${ifvar}" - if [[ ${d} == *" release "* ]]; then + if [[ " ${!opts} " == *" release "* ]]; then signal="HUP" else signal="TERM" @@ -87,18 +86,18 @@ dhcpcd_start() { interface_exists "${iface}" true || return 1 # Get our options - eval opts=\" \$\{dhcpcd_${ifvar}\} \" + opts="dhcpcd_${ifvar}" + opts="${!opts}" # Map some generic options to dhcpcd - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " - [[ ${d} == *" nodns "* ]] && opts="${opts} -R" - [[ ${d} == *" nontp "* ]] && opts="${opts} -N" - [[ ${d} == *" nonis "* ]] && opts="${opts} -Y" - [[ ${d} == *" nogateway "* ]] && opts="${opts} -G" - - # We transmit the hostname by default - if [[ ${d} != *" nosendhost "* && ${opts} != *" -h "* ]]; then + d="dhcp_${ifvar}" + [[ " ${d} " == *" nodns "* ]] && opts="${opts} -R" + [[ " ${d} " == *" nontp "* ]] && opts="${opts} -N" + [[ " ${d} " == *" nonis "* ]] && opts="${opts} -Y" + [[ " ${d} " == *" nogateway "* ]] && opts="${opts} -G" + + # We transmit the hostname by default:q + if [[ " ${d} " != *" nosendhost "* && " ${opts} " != *" -h "* ]]; then local hname=$( hostname ) [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ && opts="-h \"${hname}\" ${opts}" @@ -108,8 +107,8 @@ dhcpcd_start() { opts="${opts} -o" # Add our route metric - eval metric=\"\$\{metric_${ifvar}\}\" - [[ -n ${metric} ]] && opts="${opts} -m ${metric}" + metric="metric_${ifvar}" + [[ -n ${!metric} && ${!metric} != "0" ]] && opts="${opts} -m ${!metric}" # Instruct dhcpcd to use our wrapper opts="${opts} -c \"/lib/rcscripts/net.modules.d/helpers.d/dhcpcd-wrapper\"" @@ -126,12 +125,12 @@ dhcpcd_start() { [[ ! -d "${statedir}/${iface}" ]] && mkdir -m 0755 -p "${statedir}/${iface}" if [[ ${background} == "yes" ]]; then - eval dhcpcd ${opts} ${iface} & + eval dhcpcd "${opts}" "${iface}" & eend 0 go_background fi - eval dhcpcd ${opts} ${iface} + eval dhcpcd "${opts}" "${iface}" eend $? || return 1 # DHCP succeeded, show address retrieved diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet index 32f0f3f..6956c31 100644 --- a/net-scripts/net.modules.d/essidnet +++ b/net-scripts/net.modules.d/essidnet @@ -42,8 +42,8 @@ essidnet_pre_start() { configure_variables "${iface}" "${essid}" "${mac}" # Backwards compat for old gateway var - eval x=\"\$\{gateway_${essid}\}\" - [[ -n ${x} ]] && gateway="${iface}/${x}" + x="gateway_${essid}}" + [[ -n ${!x} ]] && gateway="${iface}/${!x}" veend 0 2>/dev/null return 0 diff --git a/net-scripts/net.modules.d/helpers.d/dhclient-wrapper b/net-scripts/net.modules.d/helpers.d/dhclient-wrapper index 075229d..35f8675 100755 --- a/net-scripts/net.modules.d/helpers.d/dhclient-wrapper +++ b/net-scripts/net.modules.d/helpers.d/dhclient-wrapper @@ -38,7 +38,7 @@ export nis_servers_${interface}="${new_nis_servers}" result="$?" [[ -e /etc/dhcp/dhclient-exit-hooks ]] \ -&& ( . /etc/dhcp/dhclient-exit-hooks ) + && ( . /etc/dhcp/dhclient-exit-hooks ) exit "${result}" diff --git a/net-scripts/net.modules.d/helpers.d/dhcp b/net-scripts/net.modules.d/helpers.d/dhcp index 133ffae..ad245f3 100755 --- a/net-scripts/net.modules.d/helpers.d/dhcp +++ b/net-scripts/net.modules.d/helpers.d/dhcp @@ -60,7 +60,8 @@ fi # Calculate the metric for our routes ifvar=$( bash_variable "${interface}" ) -eval metric=\"\$\{metric_${ifvar}\}\" +metric="metric_${ifvar}" +metric="${!metric}" if [[ -z ${metric} ]]; then if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then metric=$( calculate_metric "${interface}" ) @@ -70,15 +71,11 @@ if [[ -z ${metric} ]]; then eval metric_${ifvar}="${metric}" fi - -eval d=\" \$\{dhcp_${ifvar}\} \" -[[ ${d} == " " ]] && d=" ${dhcp} " - # Configure our IP address -ip="${ip// }" -subnet="${subnet// }" +ip="${ip// /}" +subnet="${subnet// /}" cidr=$( netmask2cidr "${subnet}" ) -broadcast="${broadcast// }" +broadcast="${broadcast// /}" [[ -n ${broadcast} ]] && broadcast="broadcast ${broadcast}" # If we don't have our address then we flush it and then add our new one @@ -93,8 +90,9 @@ fi echo "${ip}" > "/var/cache/dhcp-${interface}.lease" chmod 600 "/var/cache/dhcp-${interface}.lease" +d="dhcp_${ifvar}" # Configure our default route - we only have 1 default route -if [[ ${d} != *" nogateway "* ]]; then +if [[ " ${!d} " != *" nogateway "* ]]; then for r in ${routers}; do interface_default_route "${interface}" "${r}" "${metric:-0}" && break done @@ -111,9 +109,9 @@ fi # Only setup the information we're told to # By default that's everything -[[ ${d} != *" nodns "* ]] && system_dns "${interface}" -[[ ${d} != *" nontp "* ]] && system_ntp "${interface}" -[[ ${d} != *" nonis "* ]] && system_nis "${interface}" +[[ " ${!d} " != *" nodns "* ]] && system_dns "${interface}" +[[ " ${!d} " != *" nontp "* ]] && system_ntp "${interface}" +[[ " ${!d} " != *" nonis "* ]] && system_nis "${interface}" if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then best_interface=$( select_best_interface ) diff --git a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper index 29710e3..35b6f63 100755 --- a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper +++ b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper @@ -29,17 +29,15 @@ fi ifvar=$( bash_variable "${interface}" ) if [[ ${action} == "up" ]]; then - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " - + d="dhcp_${ifvar}" resolv="${statedir}/${interface}/resolv.conf" - if [[ ${d} != *" nodns "* ]]; then - eval search=\"\$\{dns_search_${ifvar}\}\" - if [[ -n ${search} ]]; then + if [[ " ${!d} " != *" nodns "* ]]; then + search="dns_search_${ifvar}" + if [[ -n ${!search} ]]; then tmp="${resolv}.$$" egrep -v "^[ \t]*(search|domain)[ \t]*" "${resolv}" > "${tmp}" - echo "search ${search}" >> "${tmp}" + echo "search ${!search}" >> "${tmp}" mv "${tmp}" "${resolv}" fi fi @@ -48,9 +46,9 @@ if [[ ${action} == "up" ]]; then fi # As we override the -c option, we need to call the specified script ourself -eval opts=\"\$\{dhcpcd_${ifvar}\}\" -exe="${opts##* -c }" -if [[ -n ${exe} && ${exe} != "${opts}" ]]; then +opts="dhcpcd_${ifvar}" +exe="${!opts##* -c }" +if [[ -n ${exe} && ${exe} != "${!opts}" ]]; then exe="${exe%% *}" else exe="/etc/dhcpc/dhcpcd.exe" diff --git a/net-scripts/net.modules.d/helpers.d/functions b/net-scripts/net.modules.d/helpers.d/functions index 3931fb4..717e0e8 100644 --- a/net-scripts/net.modules.d/helpers.d/functions +++ b/net-scripts/net.modules.d/helpers.d/functions @@ -96,21 +96,19 @@ apply_state() { # (ie a state dir exists) # require_gateway defaults to false order_interfaces() { - local ifaces - - if [[ ${1:-false} == "true" ]]; then - ifaces=$(awk '$2!="Gateway" { print $7, $1 }' /proc/net/route \ + local ifaces extra + + ${1:-false} && extra=' && $2=="00000000"' + ifaces=$(awk '{if (NR>1 && $1!="lo"'"${extra}"') print $7, $1}' /proc/net/route \ | sort -n | cut -d' ' -f2 | uniq) - else - ifaces=$(awk '$2=="00000000" { print $7, $1 }' /proc/net/route \ - | sort -n | cut -d' ' -f2 ) - fi # Append lo if it's up - if grep -q "^lo[ \t]*" /proc/net/route ; then - ifaces="${ifaces} lo" + if ! ${1:-false} ; then + if grep -q "^lo[ \t]*" /proc/net/route ; then + ifaces="${ifaces} lo" + fi fi - + local i order for i in ${ifaces}; do [[ -d "${statedir}/${i}" ]] && order="${order}${i} " @@ -132,7 +130,7 @@ merge_resolv() { [[ ! -e "${statedir}/${ifaces[i]}/resolv.conf" ]] && unset ifaces[i] done ifaces=( "${ifaces[@]}" ) - + # No point merging unless there are two or more interfaces [[ ${#ifaces[@]} -lt 2 ]] && return @@ -151,7 +149,7 @@ merge_resolv() { opts[i]=$( sed -n -e 's/^[ \t]*options[ \t]*\([^#]*\).*/\1#/p;' "${f}" | xargs ) sortlist[i]=$( sed -n -e 's/^[ \t]*sortlist[ \t]*\([^#]*\).*/\1/p' "${f}" ) - if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} ]]; then + if [[ -z ${srvs[i]} && -z ${opts[i]} && -z ${sortlist[i]} && -z ${search[i]} ]]; then unset srvs[i] unset search[i] unset opts[i] @@ -568,9 +566,9 @@ configure_variables() { is_function ${mod}_variables || continue for v in $(${mod}_variables) ; do x="" - [[ -n ${option2} ]] && eval x=( \"\$\{${v}_${option2}\[@\]\}\" ) - [[ -z ${x} ]] && eval x=( \"\$\{${v}_${option1}\[@\]\}\" ) - [[ -n ${x} ]] && eval "${v}_${ifvar}=( "\"\$\{x\[@\]\}\"" )" + [[ -n ${option2} ]] && x="${v}_${option2}[@]" + [[ -z ${!x} ]] && x="${v}_${option1}[@]" + [[ -n ${!x} ]] && eval "${v}_${ifvar}=( "${!x}" )" done done diff --git a/net-scripts/net.modules.d/helpers.d/pppd-wrapper b/net-scripts/net.modules.d/helpers.d/pppd-wrapper new file mode 100644 index 0000000..2e7dc54 --- /dev/null +++ b/net-scripts/net.modules.d/helpers.d/pppd-wrapper @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright (c) 2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Contributed by Roy Marples (uberlord@gentoo.org) + +action="$1" +interface="$2" +export IN_BACKGROUND="true" +. /lib/rcscripts/net.modules.d/helpers.d/module-loader +resolv="${statedir}/${interface}/resolv.conf" + +if [[ ${action} == "up" ]]; then + if [[ -n ${DNS1} || -n ${DNS2} ]]; then + echo "# Generated by pppd for interface $1" > "${resolv}" + chmod 0644 "${resolv}" + [ -n ${DNS1} ] && echo "nameserver ${DNS1}" >> "${resolv}" + [ -n ${DNS2} ] && echo "nameserver ${DNS2}" >> "${resolv}" + fi + + # Calculate the metric for our routes + ifvar=$( bash_variable "${interface}" ) + metric="metric_${ifvar}" + metric="${!metric}" + if [[ -z ${metric} ]]; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then + metric=$( calculate_metric "${interface}" ) + else + metric="0" + fi + fi + + [[ ${metric} != "0" ]] && interface_route_metric "${interface}" "${metric}" + + if service_inactive "net.${interface}" ; then + export RC_INTERFACE_KEEP_CONFIG="yes" + /etc/init.d/net."${interface}" start + fi +else + /etc/init.d/net."${interface}" stop +fi + +# vim:ts=4 diff --git a/net-scripts/net.modules.d/helpers.d/pump-wrapper b/net-scripts/net.modules.d/helpers.d/pump-wrapper index 1adf0bf..bf76ef3 100755 --- a/net-scripts/net.modules.d/helpers.d/pump-wrapper +++ b/net-scripts/net.modules.d/helpers.d/pump-wrapper @@ -22,14 +22,7 @@ if [[ ${action} == "up" ]]; then fi fi - # Add any search paths if we have any defined - ifvar=$( bash_variable "${interface}" ) - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " - - resolv="${statedir}/${interface}/resolv.conf" - - system_dns_extra "${interface}" "${resolv}" + system_dns_extra "${interface}" "${statedir}/${interface}/resolv.conf" fi . /lib/rcscripts/net.modules.d/helpers.d/dhcp-state diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig index 2f96c29..e1b6d7d 100644 --- a/net-scripts/net.modules.d/ifconfig +++ b/net-scripts/net.modules.d/ifconfig @@ -175,24 +175,30 @@ ifconfig_del_addresses() { ifconfig_get_old_config() { local iface="$1" ifvar=$( bash_variable "$1" ) i inet6 - eval config=( \"\$\{ifconfig_${ifvar}\[@\]\}\" ) - eval config_fallback=( \"\$\{ifconfig_fallback_${ifvar}\[@\]\}\" ) - eval inet6=( \"\$\{inet6_${ifvar}\[@\]\}\" ) + config="ifconfig_${ifvar}[@\]" + config=( "${!config}" ) + config_fallback="ifconfig_fallback_${ifvar}[@]" + config_fallback=( "${!config_fallback}" ) + inet6="inet6_${ifvar}[@]" + inet6=( "${!inet6}" ) # BACKWARD COMPATIBILITY: populate the config_IFACE array # if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0) - eval i=\"\$\{iface_${ifvar}\}\" - if [[ -n ${i} && -z ${config} ]]; then + i="iface_${ifvar}" + if [[ -n ${!i} && -z ${config} ]]; then # Make sure these get evaluated as arrays local -a aliases broadcasts netmasks # Start with the primary interface - config=( "${i}" ) + config=( ${!i} ) # ..then add aliases - eval aliases=( \$\{alias_${ifvar}\} ) - eval broadcasts=( \$\{broadcast_${ifvar}\} ) - eval netmasks=( \$\{netmask_${ifvar}\} ) + aliases="alias_${ifvars}" + aliases=( ${!aliases} ) + broadcasts="broadcast_${ifvar}" + broadcasts=( ${!broadcasts} ) + netmasks="netmask_${ifvar}" + netmasks=( ${!netmasks} ) for (( i=0; i<${#aliases[@]}; i++ )); do config[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}" done @@ -241,8 +247,8 @@ ifconfig_pre_start() { local ifvar=$( bash_variable "$1" ) mtu # MTU support - eval mtu=\"\$\{mtu_${ifvar}\}\" - [[ -n ${mtu} ]] && ifconfig "${iface}" mtu "${mtu}" + mtu="mtu_${ifvar}" + [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}" return 0 } @@ -258,7 +264,7 @@ ifconfig_pre_start() { # net.eth0 was successful ifconfig_post_start() { local iface="$1" ifvar=$( bash_variable "$1" ) routes x metric mtu cidr - eval metric=\"\$\{metric_${ifvar}\}\" + metric="metric_${ifvar}" ifconfig_exists "${iface}" || return 0 @@ -266,10 +272,11 @@ ifconfig_post_start() { ifconfig_up "${iface}" # MTU support - eval mtu=\"\$\{mtu_${ifvar}\}\" - [[ -n ${mtu} ]] && ifconfig "${iface}" mtu "${mtu}" + mtu="mtu_${ifvar}" + [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}" - eval routes=( \"\$\{routes_${ifvar}\[@\]\}\" ) + routes="routes_${ifvar}[@]" + routes=( "${!routes}" ) # BACKWARD COMPATIBILITY: set the default gateway if [[ ${gateway} == "${iface}/"* ]]; then @@ -353,7 +360,7 @@ ifconfig_add_address() { r="${config[@]}" config=( ${r//brd +/} ) config=( "${config[@]//brd/broadcast}" ) - config=( "${config[@]//peer/pointtopoint}" ) + config=( "${config[@]//peer/pointopoint}" ) fi # Ensure that the interface is up so we can add IPv6 addresses @@ -370,8 +377,8 @@ ifconfig_add_address() { local metric ifvar=$(bash_variable "${real_iface}") # Remove the newly added route and replace with our metric - eval metric=\"\$\{metric_${ifvar}\}\" - [[ ${metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r} + metric="metric_${ifvar}" + [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r} if [[ -z ${netmask} ]]; then for (( i=1; i<${#config[@]}-1; i++ )); do @@ -388,12 +395,30 @@ ifconfig_add_address() { if route del -net "${network}/${cidr}" metric 0 dev "${iface}" \ 2>/dev/null ; then - route add -net "${network}/${cidr}" metric "${metric}" dev "${iface}" + route add -net "${network}/${cidr}" metric "${!metric}" dev "${iface}" fi return ${r} } +# void ifconfig_route_metric(char* interface, int metric) +# +# Change all routes for an interface to a given metric +ifconfig_route_metric() { + local dest gateway mask flags metric ref use + route -n | grep " $1$" | { + while read dest gateway mask flags metric ref use ; do + if [[ ${gateway} != "0.0.0.0" ]]; then + gateway="gw ${gateway}" + else + unset gateway + fi + route del ${dest} + route add -net ${dest} netmask ${mask} ${gateway} metric "$2" dev "$1" + done + } +} + # void ifconfig_default_route(char* interface, char* gateway_ip, int metric) # # Force default route to the specified gateway diff --git a/net-scripts/net.modules.d/ifplugd b/net-scripts/net.modules.d/ifplugd index a92d79c..9d4d25e 100644 --- a/net-scripts/net.modules.d/ifplugd +++ b/net-scripts/net.modules.d/ifplugd @@ -68,12 +68,13 @@ ifplugd_pre_start() { fi # Do some options - eval opts=\" \$\{ifplugd_${ifvar}\} \" + opts="ifplugd_${ifvar}" # We don't work on wirelesss interfaces # Although ifplugd can, we prefer wpa_supplicant, unless explicitly told # so via our options - if [[ ${opts} != *" -m wlan "* && ${opts} != *" --api-mode=wlan "* ]]; then + if [[ " ${!opts} " != *" -m wlan "* \ + && " ${!opts} " != *" --api-mode=wlan "* ]]; then if is_function wireless_check_extensions ; then if wireless_check_extensions "${iface}"; then veinfo "ifplugd does not work on wireless interfaces" @@ -91,14 +92,15 @@ ifplugd_pre_start() { mark_service_inactive "net.${iface}" # Start ifplugd - start-stop-daemon --start --exec /usr/sbin/ifplugd \ + eval start-stop-daemon --start --exec /usr/sbin/ifplugd \ --pidfile "${pidfile}" \ - -- ${opts} --iface="${iface}" + -- "${!opts}" --iface="${iface}" eend "$?" || return 1 eindent - eval timeout=\"\$\{plug_timeout_${ifvar}\:--1}\" + timeout="timeout_${ifvar}" + timeout="${!timeout:--1}" if [[ ${timeout} == "0" ]]; then ewarn "WARNING: infinite timeout set for ${iface} to come up" elif [[ ${timeout} -lt 0 ]]; then diff --git a/net-scripts/net.modules.d/ipppd b/net-scripts/net.modules.d/ipppd index 5688954..fd564a4 100644 --- a/net-scripts/net.modules.d/ipppd +++ b/net-scripts/net.modules.d/ipppd @@ -47,11 +47,13 @@ ipppd_pre_start() { local ifvar=$( bash_variable "${iface}" ) # Might or might not be set in conf.d/net - eval opts=\"\$\{ipppd_${ifvar}\}\" + opts="ipppd_${ifvar}" einfo "Starting ipppd for ${iface}" - /usr/sbin/ipppd "${opts}" pidfile "${pidfile}" \ - file "/etc/ppp/options.${iface}" >/dev/null + eval start-stop-daemon --start --exec /usr/sbin/ipppd \ + --pidfile "${pidfile}" \ + -- "${!opts}" pidfile "${pidfile}" \ + file "/etc/ppp/options.${iface}" >/dev/null eend $? || return $? return 0 @@ -66,18 +68,10 @@ ipppd_stop() { [[ ! -f ${pidfile} ]] && return 0 - clean_pidfile "${pidfile}" && return 0 - local pid=$( < "${pidfile}" ) r=0 - einfo "Stopping ipppd for ${iface}" - kill -s TERM "${pid}" - if ! process_finished "${pid}" ipppd 10 ; then - kill -s KILL "${pid}" - process_finished "${pid}" ipppd 10 || r=1 - fi - - eend ${r} - return ${r} + start-stop-daemon --stop --exec /usr/sbin/ippd \ + --pidfile "${pidfile}" + eend $? } # vim:ts=4 diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2 index 62dd92d..b9d0bed 100644 --- a/net-scripts/net.modules.d/iproute2 +++ b/net-scripts/net.modules.d/iproute2 @@ -147,12 +147,15 @@ iproute2_del_addresses() { # # Returns config and config_fallback for the given interface iproute2_get_old_config() { - local ifvar=$( bash_variable "$1" ) inet6 + local ifvar=$( bash_variable "$1" ) inet6 t # iproute2-style config vars - eval config=( \"\$\{ipaddr_${ifvar}\[@\]\}\" ) - eval config_fallback=( \"\$\{ipaddr_fallback_${ifvar}\[@\]\}\" ) - eval inet6=( \"\$\{inet6_${ifvar}\[@\]\}\" ) + t="ipaddr_${ifvar}[@]" + config=( "${!t}" ) + t="config_fallback_${ifvar}[@]" + config_fallback=( "${!t}" ) + t="inet6_${ifvar}[@]" + inet6=( "${!t}" ) # BACKWARD COMPATIBILITY: check for space-separated inet6 addresses [[ ${#inet6[@]} == "1" && ${inet6} == *" "* ]] && inet6=( ${inet6} ) @@ -204,16 +207,16 @@ iproute2_add_address() { for (( x=0; x<n; x++ )); do case "${config[x]}" in netmask) - config[0]="${config[0]}/$( netmask2cidr ${config[x+1]} )" - unset config[x] config[x+1] - ;; + config[0]="${config[0]}/$( netmask2cidr ${config[x+1]} )" + unset config[x] config[x+1] + ;; mtu) - ip link set mtu "${config[x+1]}" dev "${iface}" - unset config[x] config[x+1] - ;; + ip link set mtu "${config[x+1]}" dev "${iface}" + unset config[x] config[x+1] + ;; esac done - config=( "${config[@]//pointtopoint/peer}" ) + config=( "${config[@]//pointopoint/peer}" ) # Always scope lo addresses as host unless specified otherwise [[ ${iface} == "lo" && " ${config[@]} " != *" scope "* ]] \ @@ -241,8 +244,8 @@ iproute2_add_address() { local metric ifvar=$( bash_variable "${iface}" ) # Remove the newly added route and replace with our metric - eval metric=\"\$\{metric_${ifvar}\}\" - [[ ${metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return "${r}" + metric="metric_${ifvar}" + [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return "${r}" local network=$( ip_network "${config[0]}" ) [[ -z ${network} ]] && return "${r}" @@ -250,7 +253,7 @@ iproute2_add_address() { local cidr="${config[0]##*/}" if ip route del "${network}/${cidr}" metric 0 dev "${iface}" \ 2>/dev/null ; then - ip route add "${network}/${cidr}" metric "${metric}" dev "${iface}" + ip route add "${network}/${cidr}" metric "${!metric}" dev "${iface}" fi return "${r}" @@ -269,8 +272,8 @@ iproute2_pre_start() { local ifvar=$( bash_variable "$1" ) mtu # MTU support - eval mtu=\"\$\{mtu_${ifvar}\}\" - [[ -n ${mtu} ]] && ip link set mtu "${mtu}" dev "${iface}" + mtu="mtu_${ifvar}" + [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" return 0 } @@ -288,15 +291,17 @@ iproute2_post_start() { iproute2_up "${iface}" # MTU support - eval mtu=\"\$\{mtu_${ifvar}\}\" - [[ -n ${mtu} ]] && ip link set mtu "${mtu}" dev "${iface}" + mtu="mtu_${ifvar}" + [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" - eval routes=( \"\$\{routes_${ifvar}\[@\]\}\" ) - eval metric=\"\$\{metric_${ifvar}\:-0}\" + x="routes_${ifvar}[@]" + routes=( "${!x}" ) + metric="metric_${ifvar}" # Test for old style ipaddr variable if [[ -z ${routes} ]]; then - eval routes=( \"\$\{iproute_${ifvar}\[@\]\}\" ) + t="iproute_${ifvar}[@]" + routes=( "${!t}" ) fi [[ -z ${routes} ]] && return 0 @@ -309,9 +314,9 @@ iproute2_post_start() { # Support net-tools routing too x="${x//gw/via}" - x="${x//-A inet6}" - x="${x//-net}" - [[ " ${x} " == *" -host "* ]] && x="${x//-host} scope host" + x="${x//-A inet6/}" + x="${x//-net/}" + [[ " ${x} " == *" -host "* ]] && x="${x//-host/} scope host" # Attempt to support net-tools route netmask option netmask="${x##* netmask }" @@ -324,7 +329,7 @@ iproute2_post_start() { fi # Add a metric if we don't have one - [[ " ${x} " != *" metric "* ]] && x="${x} metric ${metric}" + [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}" ip route append ${x} dev "${iface}" eend $? @@ -334,6 +339,19 @@ iproute2_post_start() { return 0 } +# void iproute2_route_metric(char* interface, int metric) +# +# Change all routes for an interface to a given metric +iproute2_route_metric() { + local route + ip route | grep " dev $1" | { + while read route ; do + ip route del ${route} + ip route add ${route} metric "$2" + done + } +} + # void iproute2_default_route(char* interface, char* gateway_ip, int metric) # # Force default route to the specified gateway, optionally on diff --git a/net-scripts/net.modules.d/iptunnel b/net-scripts/net.modules.d/iptunnel index 572f369..73e7594 100644 --- a/net-scripts/net.modules.d/iptunnel +++ b/net-scripts/net.modules.d/iptunnel @@ -21,11 +21,11 @@ iptunnel_pre_start() { local iface="$1" opts ifvar=$( bash_variable "$1" ) # Get our options - eval opts=\"\$\{iptunnel_${ifvar}\}\" - [[ -z ${opts} ]] && return 0 + eval opts="iptunnel_${ifvar}" + [[ -z ${!opts} ]] && return 0 ebegin "Creating tunnel ${iface}" - interface_tunnel add "${iface}" ${opts} + interface_tunnel add "${iface}" ${!opts} eend "$?" } diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig index 5fafae9..90c0f6e 100644 --- a/net-scripts/net.modules.d/iwconfig +++ b/net-scripts/net.modules.d/iwconfig @@ -147,9 +147,9 @@ iwconfig_report() { # or the given ESSID. The mac address setting takes precendence iwconfig_get_wep_key() { local mac="$1" key - eval key=\"\${mac_key_${mac//:/}\}\" - [[ -z ${key} ]] && eval key=\"\${key_${ESSIDVAR}\}\" - echo "${key:-off}" + key="mac_key_${mac//:/}" + [[ -z ${!key} ]] && key="key_${ESSIDVAR}" + echo "${!key:-off}" } # void iwconfig_user_config(char *iface) @@ -159,19 +159,19 @@ iwconfig_user_config() { local iface="$1" conf ifvar=$( bash_variable "$1" ) # Apply the user configuration - eval conf=\"\$\{iwconfig_${ifvar}\}\" - if [[ -n ${conf} ]]; then - if ! eval iwconfig "${iface}" ${conf} ; then + conf="iwconfig_${ifvar}" + if [[ -n ${!conf} ]]; then + if ! eval iwconfig "${iface}" "${!conf}" ; then ewarn "${iface} does not support the following configuration commands" - ewarn " \"${conf}\"" + eval ewarn " ${!conf}" fi fi - eval conf=\"\$\{iwpriv_${ifvar}\}\" - if [[ -n ${conf} ]]; then - if ! eval iwpriv "${iface}" ${conf} ; then + conf="iwpriv_${ifvar}" + if [[ -n ${!conf} ]]; then + if ! eval iwpriv "${iface}" "${!conf}" ; then ewarn "${iface} does not support the following private ioctls" - ewarn " \"${conf}\"" + ewarn " ${!conf}" fi fi } @@ -192,7 +192,7 @@ iwconfig_setup_specific() { ESSIDVAR=$( bash_variable "${ESSID}" ) key=$( iwconfig_get_wep_key ) - if ! eval iwconfig "${iface}" key ${key} ; then + if ! eval iwconfig "${iface}" key "${key}" ; then if [[ ${key} != "off" ]]; then ewarn "${iface} does not support setting keys" ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" @@ -214,9 +214,9 @@ iwconfig_setup_specific() { fi fi - eval channel=\"\$\{channel_${ifvar}\}\" + channel="channel_${ifvar}" # We default the channel to 3 - channel=${channel:-3} + channel="${!channel:-3}" if ! iwconfig "${iface}" channel "${channel}" ; then ewarn "${iface} does not support setting the channel to \"${channel}\"" @@ -272,11 +272,12 @@ iwconfig_associate_quality() { # # Returns true if the interface has associated with an Access Point iwconfig_test_associated() { - local iface="$1" ttype ifvar=$( bash_variable "$1" ) + local iface="$1" ttype ifvar=$( bash_variable "$1" ) x # Some drivers don't set MAC to a bogus value when assocation is lost/fails # whereas they do set link quality to 0 - ttype=$( eval echo \"\$\{associate_test_${ifvar}\:-mac}\" | tr '[:upper:]' '[:lower:]' ) + x="associate_test_${ifvar}" + ttype=$( echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]' ) if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then ewarn " associate_test_${iface} is not set to mac, quality or all" ewarn " defaulting to \"mac\"" @@ -299,11 +300,12 @@ iwconfig_test_associated() { # we are assocaited with an Access Point iwconfig_wait_for_association() { local iface="$1" i=0 timeout ifvar=$( bash_variable "$1" ) - eval timeout=\"\$\{associate_timeout_${ifvar}\}\" - [[ -z ${timeout} ]] && eval timeout=\"\$\{sleep_associate_${ifvar}\:-10\}\" + timeout="associate_timeout_${ifvar}" + [[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}" + timeout="${!timeout:-10}" [[ ${timeout} == "0" ]] \ - && vewarn "WARNING: infinite timeout set for association on ${iface}" + && vewarn "WARNING: infinite timeout set for association on ${iface}" while true; do iwconfig_test_associated "${iface}" && return 0 @@ -343,7 +345,7 @@ iwconfig_associate() { vewarn "\"${dessid}\" is not WEP enabled - ignoring setting" fi - if ! eval iwconfig "${iface}" key ${key} ; then + if ! eval iwconfig "${iface}" key "${key}" ; then if [[ ${key} != "off" ]]; then ewarn "${iface} does not support setting keys" ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" @@ -414,7 +416,8 @@ iwconfig_scan() { local iface="$1" mode x ifvar=$( bash_variable "$1" ) # First, we may need to change mode to scan in - mode=$( eval echo \"\$\{scan_mode_${ifvar}\}\" | tr '[:upper:]' '[:lower:]' ) + x="scan_mode_${ifvar}" + mode=$( echo "${!x}" | tr '[:upper:]' '[:lower:]' ) if [[ -n ${mode} ]]; then if ! iwconfig "${iface}" mode "${mode}" ; then ewarn "${iface} does not support setting the mode to \"${mode}\"" @@ -422,11 +425,11 @@ iwconfig_scan() { fi # Next we set any private driver ioctls needed - eval x=\"\$\{iwpriv_scan_pre_${ifvar}\}\" - if [[ -n ${x} ]]; then - if ! eval iwpriv "${iface}" ${x} ; then + x="iwpriv_scan_pre_${ifvar}" + if [[ -n ${!x} ]]; then + if ! eval iwpriv "${iface}" "${!x}" ; then ewarn "${iface} does not support the following private ioctls" \ - ewarn " \"${x}\"" + ewarn " ${!x}" fi fi @@ -436,8 +439,8 @@ iwconfig_scan() { veinfo "Scanning for access points" # Sleep if required - eval x=\"\$\{sleep_scan_${ifvar}\:-1}\" - [[ -n ${x} ]] && sleep "${x}" + x="sleep_scan_${ifvar}" + [[ -z ${!x} || ${!x} -gt 0 ]] && sleep "${!x:-1}" local error=true i=-1 line local -a mac essid enc qual mode @@ -471,8 +474,8 @@ iwconfig_scan() { if ${error}; then ewarn "${iface} does not support scanning" - eval x=\"\$\{adhoc_essid_${ifvar}\}\" - [[ -n ${x} ]] && return 0 + x="adhoc_essid_${ifvar}" + [[ -n ${!x} ]] && return 0 if [[ -n ${preferred_aps} ]]; then [[ ${associate_order} == "forcepreferred" \ || ${associate_order} == "forcepreferredonly" ]] && return 0 @@ -491,16 +494,17 @@ iwconfig_scan() { fi # We may need to unset the previous private driver ioctls - eval x=\"\$\{iwpriv_scan_post_${ifvar}\}\" - if [[ -n ${x} ]]; then - if ! eval iwpriv "${iface}" ${x} ; then + x="iwpriv_scan_post_${ifvar}" + if [[ -n ${!x} ]]; then + if ! eval iwpriv "${iface}" "${!x}" ; then ewarn "${iface} does not support the following private ioctls" \ - ewarn " \"${x}\"" + ewarn " ${!x}" fi fi # Change back mode if needed - x=$( eval echo \"\$\{mode_${ifvar}\:-managed}\" | tr '[:upper:]' '[:lower:]' ) + x="mode_${ifvar}" + x=$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' ) [[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}" for (( i=0; i<${#mac[@]}; i++ )); do @@ -547,10 +551,10 @@ iwconfig_scan_report() { eindent - eval m=\"\$\{mac_essid_${mac_APs[i]//:/}\}\" - if [[ -n ${m} ]]; then - essid_APs[i]="${m}" - veinfo "mapping to \"${m//\\\\/\\\\}\"" + m="mac_essid_${mac_APs[i]//:/}" + if [[ -n ${!m} ]]; then + essid_APs[i]="${!m}" + veinfo "mapping to \"${!m//\\\\/\\\\}\"" fi remove=false @@ -743,10 +747,12 @@ iwconfig_configure() { iwconfig_defaults "${iface}" iwconfig_user_config "${iface}" - eval ESSID=\"\$\{essid_${ifvar}\}\" + ESSID="essid_${ifvar}" + ESSID="${!ESSID}" # Setup ad-hoc mode? - x=$( eval echo \"\$\{mode_${ifvar}:-managed\}\" | tr '[:upper:]' '[:lower:]' ) + x="mode_${ifvar}" + x=$( echo "${!mode:-managed}" | tr '[:upper:]' '[:lower:]' ) if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then iwconfig_setup_specific "${iface}" "${x}" return $? @@ -775,7 +781,8 @@ iwconfig_configure() { iwconfig_associate "${iface}" && return 0 [[ ${ESSID} == "any" ]] && iwconfig_force_preferred "${iface}" && return 0 - eval ESSID=\"\$\{adhoc_essid_${ifvar}\}\" + ESSID="adhoc_essid_${ifvar}" + ESSID="${!ESSID}" if [[ -n ${ESSID} ]]; then iwconfig_setup_specific "${iface}" ad-hoc return $? @@ -784,17 +791,20 @@ iwconfig_configure() { fi # Do we have a preferred Access Point list specific to the interface? - eval x=( \"\$\{preferred_aps_${ifvar}\[@\]\}\" ) - [[ -n ${x} ]] && preferred_aps=( "${x[@]}" ) + x="preferred_aps_${ifvar}[@]" + [[ -n ${!x} ]] && preferred_aps=( "${!x}" ) # Do we have a blacklist Access Point list specific to the interface? - eval x=( \"\$\{blacklist_aps_${ifvar}\[@\]\}\" ) - [[ -n ${e} ]] && blacklist_aps=( "${x[@]}" ) + x="blacklist_aps_${ifvar}[@]" + [[ -n ${!x} ]] && blacklist_aps=( "${!x}" ) # Are we forcing preferred only? - eval x=\"\$\{associate_order_${ifvar}\}\" - [[ -n ${x} ]] && associate_order="${x}" - associate_order=$( echo "${associate_order:-any}" | tr '[:upper:]' '[:lower:]' ) + x="associate_order_${ifvar}" + [[ -n ${!x} ]] && associate_order="${!x}" + associate_order=$( + echo "${associate_order:-any}" \ + | tr '[:upper:]' '[:lower:]' + ) if [[ ${associate_order} == "forcepreferredonly" ]]; then iwconfig_force_preferred "${iface}" && return 0 @@ -804,8 +814,8 @@ iwconfig_configure() { # Strip AP's from the list that have already been associated with # other wireless cards in the system if requested - eval x=\"\$\{unique_ap_${ifvar}\}\" - [[ -n ${x} ]] && unique_ap="${x}" + x="unique_ap_${ifvar}" + [[ -n ${!x} ]] && unique_ap="${!x}" unique_ap=$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' ) [[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}" @@ -823,7 +833,8 @@ iwconfig_configure() { && e="force" e="Couldn't ${e} any access points on ${iface}" - eval ESSID=\"\$\{adhoc_essid_${ifvar}\}\" + ESSID="adhoc_essid_${ifvar}" + ESSID="${!ESSID}" if [[ -n ${ESSID} ]]; then ewarn "${e}" iwconfig_setup_specific "${iface}" ad-hoc @@ -892,11 +903,11 @@ iwconfig_pre_start() { if [[ ${background} == "yes" ]]; then IN_BACKGROUND=true iwconfig_configure "${iface}" &>/dev/null \ - && save_options "ESSID" "${ESSID}" \ - || iwconfig_defaults "${iface}" \ - && interface_down "${iface}" \ - && mark_service_stopped "net.${iface}" \ - & + && save_options "ESSID" "${ESSID}" \ + || iwconfig_defaults "${iface}" \ + && interface_down "${iface}" \ + && mark_service_stopped "net.${iface}" \ + & go_background fi diff --git a/net-scripts/net.modules.d/macchanger b/net-scripts/net.modules.d/macchanger index 7096a2a..f908fa7 100644 --- a/net-scripts/net.modules.d/macchanger +++ b/net-scripts/net.modules.d/macchanger @@ -22,14 +22,14 @@ macchanger_pre_start() { local iface="$1" mac opts ifvar=$( bash_variable "$1" ) - eval mac=\"\$\{mac_${ifvar}\}\" - [[ -z ${mac} ]] && return 0 + mac="mac_${ifvar}" + [[ -z ${!mac} ]] && return 0 interface_exists "${iface}" true || return 1 ebegin "Changing MAC address of ${iface}" - mac=$( echo "${mac}" | tr '[:upper:]' '[:lower:]' ) + mac=$( echo "${!mac}" | tr '[:upper:]' '[:lower:]' ) case "${mac}" in # specific mac-addr, i wish there were a shorter way to specify this [0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]) diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet index 5ef8f30..ec01449 100644 --- a/net-scripts/net.modules.d/macnet +++ b/net-scripts/net.modules.d/macnet @@ -35,7 +35,7 @@ macnet_pre_start() { [[ -z ${mac} ]] && return 0 vebegin "Configuring ${iface} for MAC address ${mac}" 2>/dev/null - mac="${mac//:}" + mac="${mac//:/}" configure_variables "${iface}" "${mac}" veend 0 2>/dev/null diff --git a/net-scripts/net.modules.d/netplugd b/net-scripts/net.modules.d/netplugd index 8903292..60bf47a 100644 --- a/net-scripts/net.modules.d/netplugd +++ b/net-scripts/net.modules.d/netplugd @@ -85,7 +85,8 @@ netplugd_pre_start() { eindent - eval timeout=\"\$\{plug_timeout_${ifvar}\:--1}\" + timeout="plug_timeout_${ifvar}" + timeout="${!timeout:--1}" if [[ ${timeout} == "0" ]]; then ewarn "WARNING: infinite timeout set for ${iface} to come up" elif [[ ${timeout} -lt 0 ]]; then diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd index 779797c..6777c71 100644 --- a/net-scripts/net.modules.d/pppd +++ b/net-scripts/net.modules.d/pppd @@ -6,20 +6,20 @@ # # Sets up the dependancies for the module pppd_depend() { - after interface - before dhcp - provide ppp + after interface + before dhcp + provide ppp } # bool pppd_check_installed(void) # # Returns 1 if pppd is installed, otherwise 0 pppd_check_installed() { - if [[ ! -x /usr/sbin/pppd ]]; then - ${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" - return 1 - fi - return 0 + if [[ ! -x /usr/sbin/pppd ]]; then + ${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" + return 1 + fi + return 0 } # char *pppd_regex_escape(char *string) @@ -29,25 +29,25 @@ pppd_check_installed() { # This may be a candidate for adding to /sbin/functions.sh or # net-scripts functions at some point pppd_regex_escape() { - local escaped_result="$*" - escaped_result=${escaped_result//\\/\\\\} - escaped_result=${escaped_result//./\\.} - escaped_result=${escaped_result//+/\\+} - escaped_result=${escaped_result//(/\\(} - escaped_result=${escaped_result//)/\\)} - escaped_result=${escaped_result//[/\\[} - escaped_result=${escaped_result//]/\\]} - escaped_result=${escaped_result//\{/\\\{} - escaped_result=${escaped_result//\}/\\\}} - escaped_result=${escaped_result//\?/\\\?} - escaped_result=${escaped_result//\*/\\\*} - escaped_result=${escaped_result//\//\\/} - escaped_result=${escaped_result//|/\\|} - escaped_result=${escaped_result//&/\\&} - escaped_result=${escaped_result//~/\\~} - escaped_result=${escaped_result//^/\\^} - escaped_result=${escaped_result//$/\\$} - echo $escaped_result + local escaped_result="$*" + escaped_result="${escaped_result//\\/\\\\}" + escaped_result="${escaped_result//./\\.}" + escaped_result="${escaped_result//+/\\+}" + escaped_result="${escaped_result//(/\\(}" + escaped_result="${escaped_result//)/\\)}" + escaped_result="${escaped_result//[/\\[}" + escaped_result="${escaped_result//]/\\]}" + escaped_result="${escaped_result//\{/\\\{}" + escaped_result="${escaped_result//\}/\\\}}" + escaped_result="${escaped_result//\?/\\\?}" + escaped_result="${escaped_result//\*/\\\*}" + escaped_result="${escaped_result//\//\\/}" + escaped_result="${escaped_result//|/\\|}" + escaped_result="${escaped_result//&/\\&}" + escaped_result="${escaped_result//~/\\~}" + escaped_result="${escaped_result//^/\\^}" + escaped_result="${escaped_result//$/\\$}" + echo "${escaped_result}" } # bool pppd_update_secrets_file(char* filepath, char* username, \ @@ -55,44 +55,44 @@ pppd_regex_escape() { # # Add/update PAP/CHAP authentication information pppd_update_secrets_file() { - local filepath="$1" username="$2" remotename="$3" password="$4" - if [[ ! -f ${filepath} ]]; then - touch ${filepath} && \ - chmod 0600 ${filepath} || \ - return 1 - fi - - #escape username and remotename, used in following sed calls - local regex_username=$(pppd_regex_escape ${username}) - local regex_remotename=$(pppd_regex_escape ${remotename}) - local regex_password - local regex_filter="[ \t]*\"?${regex_username}\"?[ \t]*\"?${regex_remotename}\"?[ \t]*" - - #read old password, including " chars - #for being able to distinct when we need to add or update auth info - local old_password=$( - sed -r -e "/^${regex_filter}\".*\"[ \t]*\$/\ - {s/^${regex_filter}(\".*\")[ \t]*\$/\1/;q;};\ - d;" \ - ${filepath} - ) - - if [[ -z "${old_password}" ]]; then - regex_username=${username//\\/\\\\} - regex_remotename=${remotename//\\/\\\\} - regex_password=${password//\\/\\\\} - regex_password=${password//"/\\"} - sed -r -i -e "\$a\"${regex_username}\" ${regex_remotename} \"${regex_password}\"" ${filepath} - vewarn "Authentication info has been added to ${filepath}" - elif [[ "\"${password//\"/\\\"}\"" != "${old_password}" ]]; then - regex_password=${password//\\/\\\\} - regex_password=${regex_password//\//\\/} - regex_password=${regex_password//&/\\&} - regex_password=${regex_password//\"/\\\\\"} - sed -r -i -e "s/^(${regex_filter}\").*(\"[ \t]*)\$/\1${regex_password}\2/" ${filepath} - vewarn "Authentication info has been updated in ${filepath}" - fi - return 0 + local filepath="$1" username="$2" remotename="$3" password="$4" + if [[ ! -f ${filepath} ]]; then + touch ${filepath} && \ + chmod 0600 ${filepath} || \ + return 1 + fi + + #escape username and remotename, used in following sed calls + local regex_username=$(pppd_regex_escape ${username}) + local regex_remotename=$(pppd_regex_escape ${remotename}) + local regex_password + local regex_filter="[ \t]*\"?${regex_username}\"?[ \t]*\"?${regex_remotename}\"?[ \t]*" + + #read old password, including " chars + #for being able to distinct when we need to add or update auth info + local old_password=$( + sed -r -e "/^${regex_filter}\".*\"[ \t]*\$/\ + {s/^${regex_filter}(\".*\")[ \t]*\$/\1/;q;};\ + d;" \ + ${filepath} + ) + + if [[ -z "${old_password}" ]]; then + regex_username="${username//\\/\\\\}" + regex_remotename="${remotename//\\/\\\\}" + regex_password="${password//\\/\\\\}" + regex_password=${password//"/\\\\"} + sed -r -i -e "\$a\"${regex_username}\" ${regex_remotename} \"${regex_password}\"" ${filepath} + vewarn "Authentication info has been added to ${filepath}" + elif [[ "\"${password//\"/\\\"}\"" != "${old_password}" ]]; then + regex_password="${password//\\/\\\\}" + regex_password="${regex_password//\//\\/}" + regex_password="${regex_password//&/\\&}" + regex_password=${regex_password//\"/\\\\\"} + sed -r -i -e "s/^(${regex_filter}\").*(\"[ \t]*)\$/\1${regex_password}\2/" ${filepath} + vewarn "Authentication info has been updated in ${filepath}" + fi + return 0 } # bool pppd_start(char *iface) @@ -101,140 +101,163 @@ pppd_update_secrets_file() { # # Returns 0 (true) when successful, otherwise 1 pppd_start() { - local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link - if [[ ${iface%%[0-9]*} != "ppp" ]]; then - eerror "PPP can only be invoked from net.ppp[0-9]" - return 1 - fi - - local unit="${iface#ppp}" - if [[ -z ${unit} ]] ; then - eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp" - return 1 - fi - - # PPP requires a link to communicate over - normally a serial port - # PPPoE communicates over ethernet - # PPPoA communictes over ATM - # In all cases, the link needs to be available before we start PPP - eval link=\"\$\{link_${ifvar}\}\" - if [[ -z ${link} ]]; then - eerror "link_${ifvar} has not been set in /etc/conf.d/net" - return 1 - fi - - # Might or might not be set in conf.d/net - local user password i - eval username=\"\$\{username_${ifvar}\}\" - eval password=\"\$\{password_${ifvar}\}\" - - #Add/update info in PAP/CHAP secrets files - if [[ -n ${username} && -n ${password} ]]; then - for i in chap pap ; do - if ! pppd_update_secrets_file "/etc/ppp/${i}-secrets" \ - "${username}" "${iface}" "${password}" ; then - eerror "Failed to update /etc/ppp/${i}-secrets" - return 1 - fi - done - fi - - # Load any commandline options - eval opts=\"\$\{pppd_${ifvar}\[@\]}\" - - # We don't work if unit, no detach or linkname is set. - for i in unit nodetach linkname ; do - if [[ " ${opts} " == *" ${i} "* ]]; then - eerror "The option \"${i}\" is not allowed" - return 1 - fi - done - - # Check for mtu/mru - local mtu - eval mtu=\"\$\{mtu_${ifvar}\}\" - if [[ -n ${mtu} ]]; then - [[ " ${opts} " != *" mtu "* ]] && opts="${opts} mtu ${mtu}" - [[ " ${opts} " != *" mru "* ]] && opts="${opts} mru ${mtu}" - fi - - # Set linkname because we need /var/run/ppp-${linkname}.pid - # This pidfile has the advantage of being there, even if ${iface} interface was never started - opts="linkname ${iface} ${opts}" - - # Setup auth info - [[ -n ${username} ]] && opts="user \"${username}\" ${opts}" - opts="remotename ${iface} ${opts}" - - # Load a custom interface configuration file if it exists - [[ -f "/etc/ppp/options.${iface}" ]] \ - && opts="${opts} file /etc/ppp/options.${iface}" - - # Set forced options - opts="unit ${unit} persist maxfail 0 ${opts}" - - # Setup connect script - local -a chat - eval chat=( \"\$\{chat_${ifvar}\[@\]\}\" ) - if [[ -n "${chat[@]}" ]]; then - opts="${opts} connect \"/usr/sbin/chat -e -E -v" - - local -a phone_number - eval phone_number=( \"\$\{phone_number_${ifvar}\}\" ) - if [[ ${#phone_number[@]} -ge 1 ]]; then - opts="${opts} -T '${phone_number[0]}'" - if [[ ${#phone_number[@]} -ge 2 ]]; then - opts="${opts} -U '${phone_number[1]}'" - fi - fi - - for (( i=0; i<${#chat[@]}; i++ )); do - opts="${opts} '${chat[i]}'" - done - - opts="${opts}\"" - fi - - # Add plugins - local -a plugins - eval plugins=( \"\$\{plugins_${ifvar}\[@\]\}\" ) - if [[ -n "${plugins[@]}" ]]; then - for (( i=0; i<${#plugins[@]}; i++ )); do - local -a plugin=( ${plugins[i]} ) - # Bound to be some users who do this - [[ ${plugin[0]} == "pppoe" ]] && plugin[0]="rp-pppoe" - [[ ${plugin[0]} == "pppoa" ]] && plugin[0]="pppoatm" - [[ ${plugin[0]} == "capi" ]] && plugin[0]="capiplugin" - - [[ ${plugin[0]} == "rp-pppoe" ]] && opts="${opts} connect true" - opts="${opts} plugin ${plugin[0]}.so ${plugin[@]:1}" - [[ ${plugin[0]} == "rp-pppoe" ]] && opts="${opts} ${link}" - done - fi - - #Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) - local insert_link_in_opts=1 - if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]]; then - # Ensure that the link exists and is up - interface_exists "${link}" true || return 1 - interface_up "${link}" - - # Load the pppoe kernel module - if this fails, we have to hope - # that pppoe support is compiled into the kernel - modprobe pppoe 2>/dev/null - - insert_link_in_opts=0 - fi - [[ ${insert_link_in_opts} -eq 0 ]] || opts="${link} ${opts}" - - ebegin "Running pppd" - i=$( eval /usr/sbin/pppd ${opts} 2>&1 ) - eend $? "${i}" || return 1 - - if [[ " ${opts} " == *" updetach "* ]]; then - local addr=$( interface_get_address "${iface}" ) - einfo "${iface} received address ${addr}" - fi + ${IN_BACKGROUND} && return 0 + + local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link + if [[ ${iface%%[0-9]*} != "ppp" ]]; then + eerror "PPP can only be invoked from net.ppp[0-9]" + return 1 + fi + + local unit="${iface#ppp}" + if [[ -z ${unit} ]] ; then + eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp" + return 1 + fi + + # PPP requires a link to communicate over - normally a serial port + # PPPoE communicates over Ethernet + # PPPoA communicates over ATM + # In all cases, the link needs to be available before we start PPP + link="link_${ifvar}" + if [[ -z ${!link} ]]; then + eerror "${link} has not been set in /etc/conf.d/net" + return 1 + fi + + # Might or might not be set in conf.d/net + local user password i + username="username_${ifvar}" + password="password_${ifvar}" + + #Add/update info in PAP/CHAP secrets files + if [[ -n ${!username} && -n ${!password} ]]; then + for i in chap pap ; do + if ! pppd_update_secrets_file "/etc/ppp/${i}-secrets" \ + "${!username}" "${iface}" "${!password}" ; then + eerror "Failed to update /etc/ppp/${i}-secrets" + return 1 + fi + done + fi + + # Load any commandline options + opts="pppd_${ifvar}[@]" + opts="${!opts}" + + # We don't work with these options set by the user + for i in unit nodetach linkname maxfail persist ; do + if [[ " ${opts} " == *" ${i} "* ]]; then + eerror "The option \"${i}\" is not allowed" + return 1 + fi + done + + # Check for mtu/mru + local mtu="mtu_${ifvar}" + if [[ -n ${!mtu} ]]; then + [[ " ${opts} " != *" mtu "* ]] && opts="${opts} mtu ${!mtu}" + [[ " ${opts} " != *" mru "* ]] && opts="${opts} mru ${!mtu}" + fi + + # Set linkname because we need /var/run/ppp-${linkname}.pid + # This pidfile has the advantage of being there, even if ${iface} interface was never started + opts="linkname ${iface} ${opts}" + + # Setup auth info + [[ -n ${!username} ]] && opts="user '"${!username}"' ${opts}" + opts="remotename ${iface} ${opts}" + + # Load a custom interface configuration file if it exists + [[ -f "/etc/ppp/options.${iface}" ]] \ + && opts="${opts} file /etc/ppp/options.${iface}" + + # Set forced options + opts="unit ${unit} persist maxfail 0 ${opts}" + + # Setup connect script + local chat="chat_${ifvar}[@]" + if [[ -n "${!chat}" ]]; then + opts="${opts} connect \"/usr/sbin/chat -e -E -v" + + local -a phone_number="phone_number_${ifvar}[@]" + phone_number=( "${!phone_number}" ) + if [[ ${#phone_number[@]} -ge 1 ]]; then + opts="${opts} -T '${phone_number[0]}'" + if [[ ${#phone_number[@]} -ge 2 ]]; then + opts="${opts} -U '${phone_number[1]}'" + fi + fi + + for i in "${!chat}"; do + opts="${opts} '${i}'" + done + + opts="${opts}\"" + fi + + # Add plugins + local plugins="plugins_${ifvar}[@]" + for i in "${!plugins}" ; do + local -a plugin=( ${i} ) + # Bound to be some users who do this + [[ ${plugin[0]} == "pppoe" ]] && plugin[0]="rp-pppoe" + [[ ${plugin[0]} == "pppoa" ]] && plugin[0]="pppoatm" + [[ ${plugin[0]} == "capi" ]] && plugin[0]="capiplugin" + + [[ ${plugin[0]} == "rp-pppoe" ]] && opts="${opts} connect true" + opts="${opts} plugin ${plugin[0]}.so ${plugin[@]:1}" + [[ ${plugin[0]} == "rp-pppoe" ]] && opts="${opts} ${!link}" + done + + #Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) + local insert_link_in_opts=1 + if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]]; then + if [[ ! -e /proc/net/pppoe ]]; then + # Load the PPPoE kernel module + if ! modprobe pppoe ; then + eerror "kernel does not support PPPoE" + return 1 + fi + fi + + # Ensure that the link exists and is up + interface_exists "${!link}" true || return 1 + interface_up "${!link}" + + insert_link_in_opts=0 + fi + + if [[ " ${opts} " == *" plugin pppoatm.so "* ]]; then + if [[ ! -d /proc/net/atm ]]; then + # Load the PPPoA kernel module + if ! modprobe pppoatm ; then + eerror "kernel does not support PPPoATM" + return 1 + fi + fi + fi + [[ ${insert_link_in_opts} -eq 0 ]] || opts="${!link} ${opts}" + + ebegin "Running pppd" + [[ " ${opts} " != *" updetach "* ]] && mark_service_inactive "net.${iface}" + eval start-stop-daemon --start --exec /usr/sbin/pppd \ + --pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null + if [[ $? != "0" ]]; then + eend $? "Failed to start PPP" + mark_service_starting "net.${iface}" + return $? + fi + + if [[ " ${opts} " == *" updetach "* ]]; then + local addr=$( interface_get_address "${iface}" ) + einfo "${iface} received address ${addr}" + else + einfo "Backgrounding ..." + exit 0 + fi + + return 0 } # bool pppd_stop(char *iface) @@ -244,15 +267,14 @@ pppd_start() { # Returns 0 (true) if no process to kill or it terminates successfully, # otherwise non-zero (false) pppd_stop() { - local iface="$1" pidfile="/var/run/ppp-$1.pid" + ${IN_BACKGROUND} && return 0 + local iface="$1" pidfile="/var/run/ppp-$1.pid" - [[ ! -s ${pidfile} ]] && return 0 + [[ ! -s ${pidfile} ]] && return 0 - local pid - read pid <"${pidfile}" #PID is the first line of the pidfile - einfo "Stopping pppd on ${iface}" - kill -s TERM "${pid}" - process_finished "${pid}" /usr/sbin/pppd - - eend $? + einfo "Stopping pppd on ${iface}" + start-stop-daemon --stop --exec /usr/sbin/pppd --pidfile "${pidfile}" + eend $? } + +# vim: ts=4 diff --git a/net-scripts/net.modules.d/pump b/net-scripts/net.modules.d/pump index 69eb675..5a0b3cc 100644 --- a/net-scripts/net.modules.d/pump +++ b/net-scripts/net.modules.d/pump @@ -43,13 +43,12 @@ pump_stop() { # Check that pump is running on the interface pump --status --interface "${iface}" 2>/dev/null \ - | grep -q "^Device ${iface}" || return 0 + | grep -q "^Device ${iface}" || return 0 # Pump always releases the lease ebegin "Stopping pump on ${iface}" pump --release --interface "${iface}" - eend "$?" "Failed to stop pump" - return "$?" + eend $? "Failed to stop pump" } # bool pump_start(char *iface) @@ -63,21 +62,22 @@ pump_start() { interface_exists "${iface}" true || return 1 - eval opts=\" \$\{pump_${ifvar}\} \" + opts="pump_${ifvar}" + opts="${!opts}" # Map some generic options to pump - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " - [[ ${d} == *" nodns "* ]] && opts="${opts} --no-dns" - [[ ${d} == *" nogateway "* ]] && opts="${opts} --no-gateway" - [[ ${d} == *" nontp "* ]] && opts="${opts} --no-ntp" + d="dhcp_${ifvar}" + [[ " ${!d} " == " " ]] && d=" ${dhcp} " + [[ " ${!d} " == *" nodns "* ]] && opts="${opts} --no-dns" + [[ " ${!d} " == *" nogateway "* ]] && opts="${opts} --no-gateway" + [[ " ${!d} " == *" nontp "* ]] && opts="${opts} --no-ntp" - eval search=\"\$\{dns_search_${ifvar}\}\" - [[ -n ${search} ]] && opts="${opts} --search-path='"${search}"'" + search="dns_search_${ifvar}" + [[ -n ${!search} ]] && opts="${opts} --search-path='"${!search}"'" # Add our route metric - eval metric=\"\$\{metric_${ifvar}\}\" - [[ -n ${metric} ]] && opts="${opts} --route-metric ${metric}" + metric="metric_${ifvar}" + [[ -n ${!metric} ]] && opts="${opts} --route-metric ${!metric}" [[ ! -d "${statedir}/${iface}" ]] && mkdir -m 0755 -p "${statedir}/${iface}" @@ -89,13 +89,13 @@ pump_start() { ebegin "Running pump" if [[ ${background} == "yes" ]]; then - eval pump ${opts} & + eval pump "${opts}" & eend 0 go_background fi - eval pump ${opts} - eend "$?" || return "$?" + eval pump "${opts}" + eend $? || return $? # pump succeeded, show address retrieved local addr=$( interface_get_address "${iface}" ) diff --git a/net-scripts/net.modules.d/rename b/net-scripts/net.modules.d/rename index 2e531b1..a02f17c 100644 --- a/net-scripts/net.modules.d/rename +++ b/net-scripts/net.modules.d/rename @@ -22,36 +22,36 @@ rename_pre_start() { interface_exists "${iface}" || return 0 - eval newname=\"\$\{rename_${ifvar}\}\" - [[ -z ${newname} || ${iface} == "${newname}" ]] && return 0 + newname="rename_${ifvar}" + [[ -z ${!newname} || ${iface} == "${!newname}" ]] && return 0 # We cannot rename vlan interfaces as /proc/net/vlan/config always # returns the old interface name. We don't bail out though as it's # not critical that the interface gets renamed. if [[ -d /proc/net/vlan/config ]] ; then - if grep -q "^eth0.2 " /proc/net/vlan/config ; then + if grep -q "^${iface} " /proc/net/vlan/config ; then eerror "Cannot rename VLAN interfaces" return 0 fi fi - ebegin "Renaming \"${iface}\" to \"${newname}\"" + ebegin "Renaming \"${iface}\" to \"${!newname}\"" # Ensure that we have an init script - [[ ! -e "/etc/init.d/net.${newname}" ]] \ - && ( cd /etc/init.d ; ln -s net.lo "net.${newname}" ) + [[ ! -e "/etc/init.d/net.${!newname}" ]] \ + && ( cd /etc/init.d ; ln -s net.lo "net.${!newname}" ) # Ensure that the interface is down and without any addresses or we # will not work interface_del_addresses "${iface}" interface_down "${iface}" - interface_set_name "${iface}" "${newname}" - eend "$?" "Failed to rename interface" || return 1 + interface_set_name "${iface}" "${!newname}" + eend $? "Failed to rename interface" || return 1 # Mark us as stopped, start the new interface and bail cleanly mark_service_stopped "net.${iface}" einfo "Stopped configuration of ${iface} due to renaming" - service_stopped "net.${newname}" && start_service "net.${newname}" + service_stopped "net.${!newname}" && start_service "net.${!newname}" exit 1 } diff --git a/net-scripts/net.modules.d/system b/net-scripts/net.modules.d/system index ec5f028..36c279f 100644 --- a/net-scripts/net.modules.d/system +++ b/net-scripts/net.modules.d/system @@ -6,7 +6,8 @@ # # Sets up the dependancies for the module system_depend() { - after interface dhcp + after interface + before dhcp variables dns_servers dns_domain dns_options dns_search dns_sortlist \ ntp_servers nis_domain nis_servers } @@ -15,15 +16,16 @@ system_dns_extra() { local iface="$1" ifvar=$( bash_variable "$1" ) out="$2" x sortlist local -a options - eval options=( \"\$\{dns_options_${ifvar}\[@\]\}\" ) + x="dns_options_${ifvar}[@]" + options=( "${!x}" ) [[ -z ${options} ]] && options=( "${dns_options[@]}" ) for x in "${options[@]}"; do echo "options ${x}" >> "${out}" done - eval sortlist=\"\$\{dns_sortlist_${ifvar}\}\" - [[ -z ${sortlist} ]] && sortlist="${dns_sortlist}" - [[ -n ${sortlist} ]] && echo "sortlist ${sortlist}" >> "${out}" + sortlist="dns_sortlist_${ifvar}" + [[ -z ${!sortlist} ]] && sortlist="dns_sortlist" + [[ -n ${!sortlist} ]] && echo "sortlist ${!sortlist}" >> "${out}" } system_dns() { @@ -31,27 +33,27 @@ system_dns() { local conffile="${statedir}/${iface}/resolv.conf" tmpfile="${conffile}.$$" local -a servers - eval servers=( \"\$\{dns_servers_${ifvar}\[@\]\}\" ) - [[ -z ${servers} ]] && servers=( "${dns_servers[@]}" ) + servers="dns_servers_${ifvar}[@]" + [[ -z ${!servers} ]] && servers="dns_servers[@]" - eval domain=\"\$\{dns_domain_${ifvar}\}\" - [[ -z ${domain} ]] && domain="${dns_domain}" + domain="dns_domain_${ifvar}" + [[ -z ${!domain} ]] && domain="dns_domain" - eval search=\"\$\{dns_search_${ifvar}\}\" - [[ -z ${search} ]] && search="${dns_search}" + search="dns_search_${ifvar}" + [[ -z ${!search} ]] && search="dns_search" - [[ -z ${servers} && -z ${domain} && -z ${search} ]] && return 0 + [[ -z ${!servers} && -z ${!domain} && -z ${!search} ]] && return 0 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}" chmod 644 "${tmpfile}" - [[ -n ${domain} ]] && echo "domain ${domain}" >> "${tmpfile}" + [[ -n ${!domain} ]] && echo "domain ${!domain}" >> "${tmpfile}" - for x in ${servers[@]}; do + for x in ${!servers} ; do echo "nameserver ${x}" >> "${tmpfile}" done - [[ -n ${search} ]] && echo "search ${search}" >> "${tmpfile}" + [[ -n ${!search} ]] && echo "search ${!search}" >> "${tmpfile}" system_dns_extra "${iface}" "${tmpfile}" @@ -63,9 +65,9 @@ system_ntp() { local conffile="${statedir}/${iface}/ntp.conf" tmpfile="${conffile}.$$" local -a servers - eval servers=( \"\$\{ntp_servers_${ifvar}\[\@\]\}\" ) - [[ -z ${servers} ]] && servers=( "${ntp_servers[@]}" ) - [[ -z ${servers} ]] && return 0 + servers="ntp_servers_${ifvar}[@]" + [[ -z ${!servers} ]] && servers="ntp_servers[@]" + [[ -z ${!servers} ]] && return 0 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}" chmod 644 "${tmpfile}" @@ -73,7 +75,7 @@ system_ntp() { echo "restrict default noquery notrust nomodify" >> "${tmpfile}" echo "restrict 127.0.0.1" >> "${tmpfile}" - for x in ${servers[@]}; do + for x in ${!servers}; do echo "restrict ${x} nomodify notrap noquery" >> "${tmpfile}" echo "server ${x}" >> "${tmpfile}" done @@ -89,28 +91,28 @@ system_nis() { local conffile="${statedir}/${iface}/yp.conf" tmpfile="${conffile}.$$" local -a servers - eval servers=( \"\$\{nis_servers_${ifvar}\[\@\]\}\" ) - [[ -z ${servers} ]] && servers=( "${nis_servers[@]}" ) + servers="nis_servers_${ifvar}[@]" + [[ -z ${!servers} ]] && servers="nis_servers[@]" - eval domain=\"\$\{nis_domain_${ifvar}\}\" - [[ -z ${domain} ]] && domain="${nis_domain}" + domain="nis_domain_${ifvar}" + [[ -z ${!domain} ]] && domain="nis_domain" - [[ -z ${servers} && -z ${domain} ]] && return 0 + [[ -z ${!servers} && -z ${!domain} ]] && return 0 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}" chmod 644 "${tmpfile}" - if [[ -n ${domain} ]]; then - hostname -y "${domain}" - if [[ -n ${servers} ]]; then - for x in ${servers}; do - echo "domain ${domain} server ${x}" >> "${tmpfile}" + if [[ -n ${!domain} ]]; then + hostname -y "${!domain}" + if [[ -n ${!servers} ]]; then + for x in ${!servers}; do + echo "domain ${!domain} server ${x}" >> "${tmpfile}" done else - echo "domain ${domain} broadcast" >> "${tmpfile}" + echo "domain ${!domain} broadcast" >> "${tmpfile}" fi else - for x in ${servers}; do + for x in ${!servers}; do echo "ypserver ${x}" >> "${tmpfile}" done fi @@ -122,7 +124,7 @@ system_nis() { # # Configures the host system for dns, ntp and nis information # Always returns 0 -system_post_start() { +system_pre_start() { local iface="$1" system_dns "${iface}" diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap index 1cbc621..dffa5ad 100644 --- a/net-scripts/net.modules.d/tuntap +++ b/net-scripts/net.modules.d/tuntap @@ -64,10 +64,10 @@ tuntap_pre_start() { tuntap_check_kernel || return 1 # Get our options - eval opts=\"\$\{tunctl_${ifvar}\}\" + opts="tunctl_${ifvar}" ebegin "Creating Tun/Tap interface ${iface}" - tunctl ${opts} -t "${iface}" >/dev/null + tunctl ${!opts} -t "${iface}" >/dev/null eend "$?" || return 1 return 0 diff --git a/net-scripts/net.modules.d/udhcpc b/net-scripts/net.modules.d/udhcpc index 131231e..69598e3 100644 --- a/net-scripts/net.modules.d/udhcpc +++ b/net-scripts/net.modules.d/udhcpc @@ -42,13 +42,12 @@ udhcpc_stop() { local pid=$( < "${pidfile}" ) e=true local ifvar=$( bash_variable "${iface}" ) - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " + d="dhcp_${ifvar}" - if [[ ${d} == *" release "* ]]; then + if [[ " ${!d} " == *" release "* ]]; then kill -s USR2 "${pid}" &>/dev/null [[ -f "/var/cache/dhcp-${iface}.lease" ]] \ - && rm "/var/cache/dhcp-${iface}.lease" + && rm "/var/cache/dhcp-${iface}.lease" fi kill -s TERM "${pid}" &>/dev/null @@ -72,12 +71,12 @@ udhcpc_start() { interface_exists "${iface}" true || return 1 local ifvar=$( bash_variable "${iface}" ) opts - eval opts=\"\$\{udhcpc_${ifvar}\}\" + opts="udhcpc_${ifvar}" + opts="${!opts}" - eval d=\" \$\{dhcp_${ifvar}\} \" - [[ ${d} == " " ]] && d=" ${dhcp} " + d="dhcp_${ifvar}" - if [[ ${d} != *" nosendhost "* ]]; then + if [[ " ${!d} " != *" nosendhost "* ]]; then if [[ ! " ${opts}" =~ " -([hH] |-hostname=)" ]]; then local hname=$( hostname ) [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ @@ -101,13 +100,13 @@ udhcpc_start() { fi if [[ ${background} == "yes" ]]; then - eval udhcpc ${opts} --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" \ - --pidfile="${pidfile}" --interface="${iface}" &>/dev/null & + eval udhcpc "${opts}" --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" \ + --pidfile="${pidfile}" --interface="${iface}" &>/dev/null & eend 0 go_background fi - x=$( eval udhcpc ${opts} --now --pidfile="${pidfile}" \ + x=$( eval udhcpc "${opts}" --now --pidfile="${pidfile}" \ --interface="${iface}" \ --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" 2>&1 \ | egrep -v '^info,' ) diff --git a/net-scripts/net.modules.d/vlan b/net-scripts/net.modules.d/vlan index 859e6dd..2c6894e 100644 --- a/net-scripts/net.modules.d/vlan +++ b/net-scripts/net.modules.d/vlan @@ -56,8 +56,9 @@ vlan_check_kernel() { vlan_pre_start() { local iface="$1" opts i x e ifvar=$( bash_variable "$1" ) - eval opts=( \"\$\{vconfig_${ifvar}\[@\]\}\" ) - [[ -z ${opts} ]] && return 0 + opts="vconfig_${ifvar}[@]" + [[ -z ${!opts} ]] && return 0 + opts=( "${!opts}" ) vlan_check_kernel || return 1 interface_exists "${iface}" || return 1 @@ -87,19 +88,19 @@ vlan_pre_start() { vlan_post_start() { local iface="$1" vlan vlans vlans_old e ifname ifvar=$( bash_variable "$1" ) - eval vlans=\"\$\{vlans_${ifvar}\}\" + vlans="vlans_${ifvar}[@]" # BACKWARD COMPATIBILITY: check for old vlan variable name - eval vlans_old=\"\$\{iface_${ifvar}_vlans\}\" - [[ -n ${vlans_old} && -z ${vlans} ]] && vlans="${vlans_old}" + vlans_old="iface_${ifvar}_vlans" + [[ -n ${!vlans_old} && -z ${!vlans} ]] && vlans="vlans_old" - [[ -z ${vlans} ]] && return 0 + [[ -z ${!vlans} ]] && return 0 vlan_check_kernel || return 1 interface_exists "${iface}" true || return 1 # Start vlans for this interface - for vlan in ${vlans}; do + for vlan in ${!vlans}; do einfo "Adding VLAN ${vlan} to ${iface}" e=$( vconfig add "${iface}" "${vlan}" 2>&1 1>/dev/null ) if [[ -n ${e} ]] ; then @@ -110,8 +111,8 @@ vlan_post_start() { # We need to work out the interface name of our new vlan id ifname=$( \ - sed -n -e 's/^\([^ \t]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \ - /proc/net/vlan/config + sed -n -e 's/^\([^ \t]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \ + /proc/net/vlan/config ) iface_start "${ifname}" done diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index 06a7296..285f06e 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -138,8 +138,9 @@ wpa_supplicant_kill() { # otherwise, 1 wpa_supplicant_associate() { local iface="$1" ifvar=$( bash_variable "$1" ) timeout i - eval timeout=\"\$\{associate_timeout_${ifvar}\}\" - [[ -z ${timeout} ]] && eval timeout=\"\$\{wpa_timeout_${ifvar}:--1\}\" + timeout="associate_timeout_${ifvar}" + [[ -z ${!timeout} ]] && timeout="wpa_timeout_${ifvar}" + timeout="${!timeout:--1}" if [[ ${timeout} == "0" ]]; then ewarn "WARNING: infinite timeout set for association on ${iface}" @@ -205,7 +206,8 @@ wpa_supplicant_pre_start() { save_options "ESSID" "" local ifvar=$( bash_variable "${iface}" ) - eval opts=\" \$\{wpa_supplicant_${ifvar}\} \" + opts="wpa_supplicant_${ifvar}" + opts=" ${!opts} " [[ ${opts} != *" -D"* ]] \ && ewarn "wpa_supplicant_${ifvar} does not define a driver" @@ -281,9 +283,9 @@ wpa_supplicant_pre_start() { [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && background=no fi - start-stop-daemon --start --exec /sbin/wpa_supplicant \ + eval start-stop-daemon --start --exec /sbin/wpa_supplicant \ --pidfile "/var/run/wpa_supplicant-${iface}.pid" \ - -- ${opts} -B -i"${iface}" + -- "${opts}" -B -i"${iface}" eend "$?" || return 1 # Starting wpa_supplication-0.4.0, we can get wpa_cli to @@ -321,7 +323,7 @@ wpa_supplicant_pre_start() { ESSIDVAR=$( bash_variable "${ESSID}" ) save_options "ESSID" "${ESSID}" - local -a status=( "$( wpa_cli -i${iface} status | sed -n -e 's/^\(bssid\|pairwise_cipher\|key_mgmt\)=\([^=]\+\).*/\U\2/p' | tr '[:lower:]' '[:upper:]' )" ) + local -a status=( "$( wpa_cli -i${iface} status | sed -n -e 's/^\(bssid\|pairwise_cipher\|key_mgmt\)=\([^=]\+\).*/\"\U\2\"/p' | tr '[:lower:]' '[:upper:]' )" ) einfo "${iface} connected to \"${ESSID//\\\\/\\\\}\" at ${status[0]}" if [[ ${status[2]} == "NONE" ]]; then diff --git a/src/env_whitelist b/src/env_whitelist index c52f9ec..ef30661 100644 --- a/src/env_whitelist +++ b/src/env_whitelist @@ -8,10 +8,13 @@ # NB: Do not modify below this line if you do not know what you are doing!! # -# Hotplug ? -IN_BACKGROUND +# Hotplug IN_HOTPLUG +# RC network script support +IN_BACKGROUND +RC_INTERFACE_KEEP_CONFIG + # Default shell stuff SHELL USER |