diff options
author | 2006-02-14 13:00:44 +0000 | |
---|---|---|
committer | 2006-02-14 13:00:44 +0000 | |
commit | edf64857241690199cb5c4a7ada6283daa67be2c (patch) | |
tree | 5769bc8952f9bb9c2a3f001f5fa1870e6db8da19 | |
parent | Merging r1851 (diff) | |
download | baselayout-vserver-edf64857241690199cb5c4a7ada6283daa67be2c.tar.gz baselayout-vserver-edf64857241690199cb5c4a7ada6283daa67be2c.tar.bz2 baselayout-vserver-edf64857241690199cb5c4a7ada6283daa67be2c.zip |
Merging r1881
svn path=/baselayout-vserver/trunk/; revision=236
26 files changed, 617 insertions, 299 deletions
@@ -5,6 +5,37 @@ Give a better error message when no valid DHCP client is installed. + 08 Feb 2006; Roy Marples <uberlord@gentoo.org>: + + New module ip6to4 that creates tunnels with IPv6 addresses based off + global IPv4 addresses on a specified interface, #122015. + Thanks to Antti Mäkelä for testing and ideas. + + 07 Feb 2006; Roy Marples <uberlord@gentoo.org>: + + Always ensure the end_service is called, #119233 again. + + You can now specify a maxfail value for pppd (default 0), #115346. + + net.lo now depends on isapnp to work with older NICs, #121539. + + chat commands in pppd are now re-quoted, #121665. + + ip routing policies are now supports via the rule_eth0=( ... ) + variable (only supported by iproute2), #107628. + + wpa_supplicant now looks for config files in order + /etc/wpa_supplicant/wpa_supplicant-$iface.conf + /etc/wpa_supplicant/wpa_supplicant.conf + /etc/wpa_supplicant.conf + and for these wpa_cli scripts + /etc/wpa_supplicant/wpa_cli.sh + /sbin/wpa_cli.action + + 6 Feb 2006; Mike Frysinger <vapier@gentoo.org>: + + Update xen checks #96240 by Tuan Van and #107976 by Chris Bainbridge. + 29 Jan 2006; Mike Frysinger <vapier@gentoo.org>: Update modules-update to run depmod even if /proc/modules doesn't exist @@ -879,8 +910,9 @@ 19 Jul 2005; Mike Frysinger <vapier@gentoo.org>: - Punt the at/bind/cron/cyrus/ftp/games/gdm/man/mysql/qmail/slocate/squid/ - sshd/vpopmail/xfs users/groups to the respective ebuilds. + Punt the at/bind/cron/cyrus/ftp/games/gdm/man/mysql/nut/postfix/postgres/ + qmail/slocate/squid/sshd/vpopmail/xfs users/groups to the respective + ebuilds. 19 Jul 2005; Roy Marples <uberlord@gentoo.org>: diff --git a/ChangeLog.vserver b/ChangeLog.vserver index 2a752fd..138abb1 100644 --- a/ChangeLog.vserver +++ b/ChangeLog.vserver @@ -1,6 +1,38 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2 + 14 Feb 2006; Christian Heim <phreak@gentoo.org>: + Importing latest baselayout/trunk changes. This merge is based upon + revision 1881. + + ChangeLog | 36 ++++ + ChangeLog.vserver | 32 +++ + etc/group | 4 + etc/passwd | 3 + etc/shadow | 2 + net-scripts/conf.d/net.example | 25 ++ + net-scripts/init.d/net.lo | 124 +++++++------- + net-scripts/net.modules.d/bonding | 3 + net-scripts/net.modules.d/bridge | 3 + net-scripts/net.modules.d/dhcpcd | 10 - + net-scripts/net.modules.d/essidnet | 2 + net-scripts/net.modules.d/ifconfig | 4 + net-scripts/net.modules.d/ip6to4 | 90 ++++++++++ + net-scripts/net.modules.d/iproute2 | 152 +++++++++++------- + net-scripts/net.modules.d/iptunnel | 4 + net-scripts/net.modules.d/iwconfig | 89 +++++----- + net-scripts/net.modules.d/macnet | 2 + net-scripts/net.modules.d/pppd | 64 +++---- + net-scripts/net.modules.d/tuntap | 3 + net-scripts/net.modules.d/wpa_supplicant | 51 +++--- + sbin/runscript.sh | 6 + src/core/autogen.sh | 4 + src/core/configure.ac | 17 +- + src/core/scripts/svn2cl.sh | 97 +++++++++-- + src/core/scripts/svn2cl.xsl | 79 ++++++--- + src/core/src/runscript.c | 6 + 26 files changed, 615 insertions(+), 297 deletions(-) + 06 Feb 2006; Christian Heim <phreak@gentoo.org>: Importing latest baselayout/trunk changes. This merge is based upon revision 1851. @@ -19,14 +19,10 @@ cdrom::19: dialout::20:root tape::26:root video::27:root -postgres::70: cdrw::80: -nut::84: usb::85: users::100:games nofiles:x:200: -postfix:x:207: -postdrop:x:208: smmsp:x:209:smmsp portage::250:portage utmp:x:406: @@ -11,9 +11,6 @@ news:x:9:13:news:/usr/lib/news:/bin/false uucp:x:10:14:uucp:/var/spool/uucppublic:/bin/false operator:x:11:0:operator:/root:/bin/bash postmaster:x:14:12:postmaster:/var/spool/mail:/bin/false -postgres:x:70:70::/var/lib/postgresql:/bin/bash -nut:x:84:84:nut:/var/state/nut:/bin/false -postfix:x:207:207:postfix:/var/spool/postfix:/bin/false smmsp:x:209:209:smmsp:/var/spool/mqueue:/bin/false portage:x:250:250:portage:/var/tmp/portage:/bin/false nobody:x:65534:65534:nobody:/:/bin/false @@ -4,7 +4,6 @@ operator:*:9797:0::::: shutdown:*:9797:0::::: sync:*:9797:0::::: bin:*:9797:0::::: -ftp:*:9797:0::::: daemon:*:9797:0::::: adm:*:9797:0::::: lp:*:9797:0::::: @@ -12,7 +11,6 @@ mail:*:9797:0::::: postmaster:*:9797:0::::: news:*:9797:0::::: uucp:*:9797:0::::: -man:*:9797:0::::: games:*:9797:0::::: guest:*:9797:0::::: nobody:*:9797:0::::: diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example index ebf1236..d637731 100644 --- a/net-scripts/conf.d/net.example +++ b/net-scripts/conf.d/net.example @@ -119,6 +119,13 @@ # "::/0" # IPv6 unicast #) +# If you're using iproute2 then you can also do policy routing. +# This is not available with ifconfig. +#rules_eth0=( +# "from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100" +# "from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100" +#) + # If a specified module fails (like dhcp - see below), you can specify a # fallback like so #fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" ) @@ -396,6 +403,8 @@ #pppd_ppp0=( # "updetach" # WARNING: If you don't specify this then we will # # not wait for the actual PPP link to go up +# "maxfail 0" # WARNING: It's not recommended you use change this +# # if you don't specify maxfail then we assume 0 # "debug" # Enables syslog debugging # "noauth" # Do not require the peer to authenticate itself # "defaultroute" # Make this PPP interface the default route @@ -546,6 +555,9 @@ #----------------------------------------------------------------------------- # Tunnelling +# WARNING: For tunnelling it is highly recommended that you +# emerge sys-apps/iproute2 +# # For GRE tunnels #iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255" @@ -556,6 +568,19 @@ #config_vpn0=( "192.168.0.2 pointopoint 192.168.1.2" ) # ifconfig style #config_vpn0=( "192.168.0.2 peer 192.168.1.1" ) # iproute2 style +# 6to4 Tunnels allow IPv6 to work over IPv4 addresses, provided you +# have a non-private address configured on an interface. +# link_6to4="eth0" # Interface to base it's addresses on +# config_6to4=( "ip6to4" ) +# You may want to depend on eth0 like so +# depend_6to4() { +# need net.eth0 +# } +# To ensure that eth0 is configured before 6to4. Of course, the tunnel could be +# any name and this also works for any configured interface. +# NOTE: If you're not using iproute2 then your 6to4 tunnel has to be called +# sit0 - otherwise use a different name like 6to4 in the example above. + #----------------------------------------------------------------------------- # System # For configuring system specifics such as domain, dns, ntp and nis servers diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo index 43bfd46..53a51c9 100755 --- a/net-scripts/init.d/net.lo +++ b/net-scripts/init.d/net.lo @@ -12,7 +12,7 @@ # runlevel as the net.* script that needs it. depend() { need localmount - use pcmcia usb isdn wlan + use isapnp isdn pcmcia usb wlan # Load any custom depend functions for the given interface # For example, br0 may need eth0 and eth1 @@ -60,7 +60,7 @@ variables() { module_load_minimum() { local f="$1" MODULE="${1##*/}" - if [[ ! -f ${f} ]]; then + if [[ ! -f ${f} ]] ; then eerror "${f} does not exist" return 1 fi @@ -103,7 +103,7 @@ modules_load_auto() { j="${#MODULES[@]}" loaded_interface=false for (( i=0; i<j; i++ )); do - if [[ ${MODULES[i]##*/} == "interface" ]]; then + if [[ ${MODULES[i]##*/} == "interface" ]] ; then eerror "interface is a reserved name - cannot load a module called interface" return 1 fi @@ -111,7 +111,7 @@ modules_load_auto() { ( u=0; module_load_minimum "${MODULES[i]}" || u=1; - if [[ ${u} == 0 ]]; then + if [[ ${u} == 0 ]] ; then inst="${MODULES[i]##*/}_check_installed"; if is_function "${inst}" ; then ${inst} false || u=1; @@ -120,7 +120,7 @@ modules_load_auto() { exit "${u}"; ) - if [[ $? == 0 ]]; then + if [[ $? == 0 ]] ; then source "${MODULES[i]}" MODULES[i]="${MODULES[i]##*/}" else @@ -188,11 +188,11 @@ modules_check_user() { [[ ${umods[i]} == "dhcp" ]] && continue # We remove any modules we explicitly don't want - if [[ ${umods[i]} == "!"* ]]; then + if [[ ${umods[i]} == "!"* ]] ; then for (( j=0; j<nmods; j++ )); do [[ -z ${MODULES[j]} ]] && continue if [[ ${umods[i]:1} == "${MODULES[j]}" \ - || ${umods[i]:1} == "${PROVIDES[j]}" ]]; then + || ${umods[i]:1} == "${PROVIDES[j]}" ]] ; then # We may need to setup a class wrapper for it even though # we don't use it directly # However, we put it into an array and wrap later as @@ -217,7 +217,7 @@ modules_check_user() { # The function may not exist because the modules software is # not installed. Load the module and report its error - if [[ -e "${MODULES_DIR}/${umods[i]}" ]]; then + if [[ -e "${MODULES_DIR}/${umods[i]}" ]] ; then source "${MODULES_DIR}/${umods[i]}" is_function "${umods[i]}_check_installed" \ && ${umods[i]}_check_installed true @@ -228,18 +228,18 @@ modules_check_user() { fi if is_function "${umods[i]}_provide" ; then - mod=$( ${umods[i]}_provide ) + mod="$(${umods[i]}_provide )" else mod="${umods[i]}" fi for (( j=0; j<nmods; j++ )); do [[ -z ${MODULES[j]} ]] && continue - if [[ ${PROVIDES[j]} == "${mod}" && ${umods[i]} != "${MODULES[j]}" ]]; then + if [[ ${PROVIDES[j]} == "${mod}" && ${umods[i]} != "${MODULES[j]}" ]] ; then # We don't have a match - now ensure that we still provide an # alternative. This is to handle our preferred modules. for (( l=0; l<nmods; l++ )); do [[ ${l} == "${j}" || -z ${MODULES[l]} ]] && continue - if [[ ${PROVIDES[l]} == "${mod}" ]]; then + if [[ ${PROVIDES[l]} == "${mod}" ]] ; then unset MODULES[j] unset PROVIDES[j] break @@ -280,7 +280,7 @@ modules_sort() { if [[ ${MODULES[i]} != "${PROVIDES[i]}" ]] ; then local provided=false for ((j=0; j<${#provide[@]}; j++)); do - if [[ ${provide[j]} == "${PROVIDES[i]}" ]]; then + if [[ ${provide[j]} == "${PROVIDES[i]}" ]] ; then provide_list[j]="${provide_list[j]} ${MODULES[i]}" provided=true fi @@ -301,7 +301,7 @@ modules_sort() { if is_function "${MODULES[i]}_before" ; then for m in $(${MODULES[i]}_before); do for ((j=0; j<nmods; j++)) ; do - if [[ ${PROVIDES[j]} == "${m}" ]]; then + if [[ ${PROVIDES[j]} == "${m}" ]] ; then after[j]=" ${after[j]} ${MODULES[i]} " break fi @@ -312,7 +312,7 @@ modules_sort() { # Replace the after list modules with real modules for ((i=0; i<nmods; i++)); do - if [[ -n ${after[i]} ]]; then + if [[ -n ${after[i]} ]] ; then for ((j=0; j<${#provide[@]}; j++)); do after[i]="${after[i]// ${provide[j]} / ${provide_list[j]} }" done @@ -357,7 +357,7 @@ modules_check_depends() { missingdeps=true for (( j=0; j<nmods; j++ )); do if [[ ${needmod} == "${MODULES[j]}" \ - || ${needmod} == "${PROVIDES[j]}" ]]; then + || ${needmod} == "${PROVIDES[j]}" ]] ; then missingdeps=false break fi @@ -404,10 +404,10 @@ modules_load() { local RC_INDENTATION="${RC_INDENTATION}" local -a PROVIDES WRAP_MODULES - if [[ ${iface} != "lo" ]]; then + if [[ ${iface} != "lo" ]] ; then x="modules_force_${iface}[@]" [[ -n ${!x} ]] && modules_force=( "${!x}" ) - if [[ -n ${modules_force} ]]; then + if [[ -n ${modules_force} ]] ; then ewarn "WARNING: You are forcing modules!" ewarn "Do not complain or file bugs if things start breaking" report=true @@ -417,7 +417,7 @@ modules_load() { veinfo "Loading networking modules for ${iface}" eindent - if [[ -z ${modules_force} ]]; then + if [[ -z ${modules_force} ]] ; then modules_load_auto || return 1 else j="${#modules_force[@]}" @@ -439,19 +439,19 @@ modules_load() { # If no provide is given, assume module name if is_function "${MODULES[i]}_provide" ; then - PROVIDES[i]=$( ${MODULES[i]}_provide ) + PROVIDES[i]="$(${MODULES[i]}_provide)" else PROVIDES[i]="${MODULES[i]}" fi done - if [[ -n ${modules_force[@]} ]]; then + if [[ -n ${modules_force[@]} ]] ; then # Strip any duplicate modules providing the same thing j="${#MODULES[@]}" for (( i=0; i<j-1; i++ )); do [[ -z ${MODULES[i]} ]] && continue for (( k=i+1; k<j; k++ )); do - if [[ ${PROVIDES[i]} == ${PROVIDES[k]} ]]; then + if [[ ${PROVIDES[i]} == ${PROVIDES[k]} ]] ; then unset MODULES[k] unset PROVIDES[k] fi @@ -465,7 +465,7 @@ modules_load() { else # Always prefer iproute2 for taking down interfaces if is_function iproute2_provide ; then - function_wrap iproute2 $(iproute2_provide) + function_wrap iproute2 "$(iproute2_provide)" fi fi fi @@ -480,7 +480,7 @@ modules_load() { function_wrap ${WRAP_MODULES[i]} done - if [[ -z ${modules_force[@]} ]]; then + if [[ -z ${modules_force[@]} ]] ; then modules_check_installed || return 1 modules_sort || return 1 fi @@ -507,9 +507,9 @@ iface_start() { # Try and work out a metric for the interface if we're on auto x="metric_${ifvar}" - if [[ -z ${!x} ]]; then - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - eval "metric_${ifvar}=\""$( calculate_metric ${iface} )"\"" + if [[ -z ${!x} ]] ; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + eval "metric_${ifvar}=\"$(calculate_metric ${iface})\"" else eval "metric_${ifvar}=0" fi @@ -528,14 +528,14 @@ iface_start() { a="config_${ifvar}[@]" a=( "${!a}" ) for (( i=0; i<${#a[@]}; i++ )); do - eval b=( $( expand_parameters "${a[i]}" ) ) + eval b=( $(expand_parameters "${a[i]}") ) config=( "${config[@]}" "${b[@]}" ) done a="fallback_${ifvar}[@]" a=( "${!a}" ) for (( i=0; i<${#a[@]}; i++ )); do - eval b=( $( expand_parameters "${a[i]}" ) ) + eval b=( $(expand_parameters "${a[i]}") ) fallback=( "${fallback[@]}" "${b[@]}" ) done @@ -544,16 +544,16 @@ iface_start() { fallback_route=( "${!fallback_route}" ) # We must support old configs - if [[ -z ${config} ]]; then + if [[ -z ${config} ]] ; then interface_get_old_config "${iface}" || return 1 - if [[ -n ${config} ]]; then + if [[ -n ${config} ]] ; then ewarn "You are using a depreciated configuration syntax for ${iface}" ewarn "You are advised to read /etc/conf.d/net.example and upgrade it accordingly" fi fi # Handle "noop" correctly - if [[ ${config[0]} == "noop" ]]; then + if [[ ${config[0]} == "noop" ]] ; then if interface_is_up "${iface}" true ; then einfo "Keeping current configuration for ${iface}" eend 0 @@ -566,8 +566,8 @@ iface_start() { # Provide a default of DHCP if no configuration is set and we're auto # Otherwise a default of NULL - if [[ -z ${config} ]]; then -# if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then + if [[ -z ${config} ]] ; then +# if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then ewarn "Configuration not set for ${iface} - assuming DHCP" if is_function "dhcp_start" ; then config=( "dhcp" ) @@ -586,7 +586,7 @@ iface_start() { for (( config_counter=0; config_counter<${#config[@]}; config_counter++ )); do # Handle null and noop correctly if [[ ${config[config_counter]} == "null" \ - || ${config[config_counter]} == "noop" ]]; then + || ${config[config_counter]} == "noop" ]] ; then eend 0 config_worked=true continue @@ -605,7 +605,7 @@ iface_start() { [[ ${x} == 0 ]] && config_worked=true && continue # We need to test to see if it's an IP address or a function # We do this by testing if the 1st character is a digit - elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]]; then + elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]] ; then x="0" if [[ ${RC_AUTO_INTERFACE} == "yes" ]] \ && is_function arping_address_exists ; then @@ -624,13 +624,13 @@ iface_start() { fi fi - if [[ -n ${fallback[config_counter]} ]]; then + if [[ -n ${fallback[config_counter]} ]] ; then einfo "Trying fallback configuration" config[config_counter]="${fallback[config_counter]}" fallback[config_counter]="" # Do we have a fallback route? - if [[ -n ${fallback_route[config_counter]} ]]; then + if [[ -n ${fallback_route[config_counter]} ]] ; then x="fallback_route[config_counter]" eval "routes_${ifvar}=( \"\${!x}\" )" fallback_route[config_counter]="" @@ -676,7 +676,7 @@ iface_stop() { # Collect list of aliases for this interface. # List will be in reverse order. if interface_exists "${iface}" ; then - aliases=$( interface_get_aliases_rev "${iface}" ) + aliases="$(interface_get_aliases_rev "${iface}")" fi # Stop aliases before primary interface. @@ -700,7 +700,7 @@ iface_stop() { # Do final shut down of this alias if [[ ${IN_BACKGROUND} != "true" \ - && ${RC_DOWN_INTERFACE} == "yes" ]]; then + && ${RC_DOWN_INTERFACE} == "yes" ]] ; then ebegin "Shutting down ${i}" interface_iface_stop "${i}" eend "$?" @@ -724,12 +724,12 @@ iface_stop() { # We cannot check that the device exists ourselves as modules like # tuntap make create it. run_start() { - local iface="$1" IFVAR=$( bash_variable "$1" ) + local iface="$1" IFVAR="$(bash_variable "$1")" # We do this so users can specify additional addresses for lo if they # need too - additional routes too # However, no extra modules are loaded as they are just not needed - if [[ ${iface} == "lo" ]]; then + if [[ ${iface} == "lo" ]] ; then metric_lo="0" config_lo=( "127.0.0.1/8 brd 127.255.255.255" "${config_lo[@]}" ) routes_lo=( "127.0.0.0/8" "${routes_lo[@]}" ) @@ -772,13 +772,13 @@ run_start() { # There may be existing ip address info - so we strip it if [[ ${RC_INTERFACE_KEEP_CONFIG} != "yes" \ - && ${IN_BACKGROUND} != "true" ]]; then + && ${IN_BACKGROUND} != "true" ]] ; then interface_del_addresses "${iface}" fi # Start the interface if ! iface_start "${iface}" ; then - if [[ ${IN_BACKGROUND} != "true" ]]; then + if [[ ${IN_BACKGROUND} != "true" ]] ; then interface_exists "${iface}" && interface_down "${iface}" fi eend 1 @@ -806,12 +806,12 @@ run_start() { # stop returns non-zero to indicate failure bringing down device. # In all other cases stop returns 0 to indicate success. run_stop() { - local iface="$1" IFVAR=$( bash_variable "$1" ) x + local iface="$1" IFVAR="$(bash_variable "$1")" x # Load our ESSID variable so users can use it in predown() instead # of having to write code. - local ESSID=$( get_options "ESSID" ) ESSIDVAR - [[ -n ${ESSID} ]] && ESSIDVAR=$( bash_variable "${ESSID}" ) + local ESSID="$(get_options ESSID)" ESSIDVAR + [[ -n ${ESSID} ]] && ESSIDVAR="$(bash_variable "${ESSID}")" # Call user-defined predown function if it exists if is_function predown ; then @@ -855,7 +855,7 @@ run() { local -a MODULES mods local IN_BACKGROUND="${IN_BACKGROUND}" - if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]]; then + if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]] ; then IN_BACKGROUND=true else IN_BACKGROUND=false @@ -872,7 +872,7 @@ run() { [[ ${iface} == "lo" ]] && modules_force=( "iproute2" "ifconfig" "system" ) if modules_load "${iface}" "${starting}" ; then - if [[ ${cmd} == "stop" ]]; then + if [[ ${cmd} == "stop" ]] ; then # Reverse the module list for stopping mods=( "${MODULES[@]}" ) for ((i = 0; i < ${#mods[@]}; i++)); do @@ -895,19 +895,19 @@ run() { fi # Only apply best state if we're on auto - if [[ ${r} == "0" ]]; then + if [[ ${r} == "0" ]] ; then local siface="" - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then - siface=$( select_best_interface ) - if [[ -n ${siface} ]]; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then + siface="$(select_best_interface)" + if [[ -n ${siface} ]] ; then einfo "Selecting best interface: ${siface}" fi - elif [[ ${cmd} == "start" ]]; then + elif [[ ${cmd} == "start" ]] ; then siface="${iface}" fi [[ -n ${siface} ]] && apply_state "${siface}" else - if [[ ${cmd} == "start" ]]; then + if [[ ${cmd} == "start" ]] ; then # Call user-defined failup if it exists if is_function failup ; then einfo "Running failup function" @@ -938,9 +938,9 @@ run() { # and allow /etc to become read only. link_file() { local file="$1" - local link=$( readlink "/etc/${file}" 2>/dev/null ) - if [[ ${link} != "${netdir}/${file}" ]]; then - if [[ -f "/etc/${file}" ]]; then + local link="$(readlink "/etc/${file}" 2>/dev/null)" + if [[ ${link} != "${netdir}/${file}" ]] ; then + if [[ -f "/etc/${file}" ]] ; then vewarn "Moving /etc/${file} to ${netdir}/${file} and creating link" mv "/etc/${file}" "${netdir}" ln -snf "${netdir}/${file}" "/etc/${file}" @@ -953,12 +953,12 @@ link_file() { # Start entry point so that we only have one function # which localises variables and unsets functions start() { - if [[ ${IN_HOTPLUG} == "1" ]]; then + if [[ ${IN_HOTPLUG} == "1" ]] ; then # 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}" ) + local x ifvar="$(bash_variable "${IFACE}")" x="hotplug_${ifvar}" - if [[ ${!x} == "no" || ${!x} == "false" ]]; then + if [[ ${!x} == "no" || ${!x} == "false" ]] ; then eerror "Not starting interface ${IFACE} due to hotplug policy" unset -f exit mark_service_stopped "net.${IFACE}" @@ -966,14 +966,14 @@ start() { fi fi - if [[ ! -d "${statedir}/${IFACE}" ]]; then + if [[ ! -d "${statedir}/${IFACE}" ]] ; then if ! mkdir -m 0755 -p "${statedir}/${IFACE}" ; then eerror "Unable to create state directory!" return 1 fi fi - if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then + if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then link_file "resolv.conf" link_file "ntp.conf" link_file "yp.conf" diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding index 62431aa..100ca28 100644 --- a/net-scripts/net.modules.d/bonding +++ b/net-scripts/net.modules.d/bonding @@ -8,8 +8,7 @@ # # Sets up the dependancies for the module bonding_depend() { - after interface macnet - before vlan dhcp bridge + before interface macchanger functions interface_exists interface_up interface_down \ interface_del_addresses variables slaves diff --git a/net-scripts/net.modules.d/bridge b/net-scripts/net.modules.d/bridge index 23a0be1..747dd1f 100644 --- a/net-scripts/net.modules.d/bridge +++ b/net-scripts/net.modules.d/bridge @@ -13,8 +13,7 @@ brctl() { # # Sets up the dependancies for the module bridge_depend() { - after interface macnet tuntap - before dhcp + before interface macnet functions interface_down interface_del_addresses interface_set_flag variables bridge bridge_add brctl } diff --git a/net-scripts/net.modules.d/dhcpcd b/net-scripts/net.modules.d/dhcpcd index ab8f9dc..c467f2a 100644 --- a/net-scripts/net.modules.d/dhcpcd +++ b/net-scripts/net.modules.d/dhcpcd @@ -28,7 +28,7 @@ dhcpcd_check_installed() { if dhcpcd -h 2>&1 | grep -q "etcDir" ; then return 0 else - ${1:-false} && eerror "We require dhcpcd-1.3.22_p4-r12 or newer" + ${1:-false} && eerror "We require dhcpcd-2.0.0 or newer" return 1 fi fi @@ -37,14 +37,6 @@ dhcpcd_check_installed() { return 1 } -# char* dhcpcd_get_vars(char *interface) -# -# Returns a string spaced with possible user set -# configuration variables -dhcpcd_get_vars() { - echo "dhcpcd_$1 dhcp_$1" -} - # bool dhcpcd_stop(char *iface) # # Stop DHCP on an interface by calling dhcpcd -z $iface diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet index f2bd823..eb114ea 100644 --- a/net-scripts/net.modules.d/essidnet +++ b/net-scripts/net.modules.d/essidnet @@ -22,7 +22,7 @@ essidnet_depend() { # bool essidnet_start(char *iface) # -# All interfaces and module scripts expose modulename_get_vars +# All interfaces and module scripts can depend on the variables function # which returns a space seperated list of user configuration variables # We can override each variable here from a given ESSID or the MAC # of the AP connected to. MAC configuration takes precedence diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig index 35db157..a7bbff8 100644 --- a/net-scripts/net.modules.d/ifconfig +++ b/net-scripts/net.modules.d/ifconfig @@ -390,7 +390,7 @@ ifconfig_add_address() { local metric ifvar=$(bash_variable "${real_iface}") # Remove the newly added route and replace with our metric metric="metric_${ifvar}" - [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r} + [[ ${!metric:-0} == "0" ]] && return ${r} if [[ -z ${netmask} ]]; then for (( i=1; i<${#config[@]}-1; i++ )); do @@ -407,7 +407,7 @@ 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:-0}" dev "${iface}" fi return ${r} diff --git a/net-scripts/net.modules.d/ip6to4 b/net-scripts/net.modules.d/ip6to4 new file mode 100644 index 0000000..a833609 --- /dev/null +++ b/net-scripts/net.modules.d/ip6to4 @@ -0,0 +1,90 @@ +#!/bin/bash +# Copyright (c) 2004-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# Contributed by Roy Marples (uberlord@gentoo.org) + +# void ip6to4_depend(void) +# +# Sets up the dependancies for the module +ip6to4_depend() { + after interface + functions interface_exists interface_get_address interface_tunnel + variables link +} + +# bool ip6to4_start(char *interface) +# +# Configures IPv6 addresses to be added to the tunnel based on a IPv4 +# addresses on a pre-configured interface. +# Returns 0 on success, otherwise 1. +ip6to4_start() { + local iface="$1" addr="" + local ifvar="$(bash_variable "${iface}")" + + # Ensure the interface is sit0 if we're using ifconfig + if [[ " ${MODULES[@]} " == *" ifconfig "* && ${iface} != "sit0" ]] ; then + eerror "ip6to4 can only on interface sit0 using ifconfig" + eerror "emerge sys-apps/iproute2 to use other interfaces" + return 1 + fi + + local host="link_${ifvar}" + if [[ -z ${!host} ]] ; then + eerror "link_${ifvar} is not set" + return 1 + fi + + interface_exists "${!host}" true || return 1 + + # An interface can have more than 1 ip address + local -a addrs=( $(interface_get_address "${!host}") ) + if [[ -z ${addrs} ]] ; then + eerror "${!host} is not configured with an IPv4 address" + return 1 + fi + + local -a new=() + local addr="" + for addr in "${addrs[@]}" ; do + # Strip the subnet + local ip="${addr%/*}" subnet="${addr#*/}" + # We don't work on private IPv4 addresses + [[ ${ip} == "127."* ]] && continue + [[ ${ip} == "10."* ]] && continue + [[ ${ip} == "192.168."* ]] && continue + local i + for ((i=16; i<32; i++)); do + [[ ${ip} == "172.${i}."* ]] && break + done + [[ ${i} -lt 32 ]] && continue + + veinfo "IPv4 address on ${!host}: ${ip}" + local ip6="$(printf "2002:%02x%02x:%02x%02x::1" ${ip//./ })" + veinfo "Derived IPv6 address: ${ip6}" + + # Now apply our IPv6 address to our config + new=( "${new[@]}" "${ip6}/16" ) + done + + if [[ -z ${new} ]] ; then + eerror "No global IPv4 addresses found on interface ${!host}" + return 1 + fi + + if [[ ${iface} != "sit0" ]] ; then + ebegin "Creating 6to4 tunnel on ${iface}" + interface_tunnel add "${iface}" mode sit ttl 255 remote any local "${ip}" + eend $? || return 1 + fi + + # Now apply our config + config=( "${config[@]}" "${new[@]}" ) + + # Add a route for us, ensuring we don't delete anything else + local routes="routes_${ifvar}[@]" + eval "routes_${ifvar}=( \"\${!routes}\" \ + \"2003::/3 via ::192.88.99.1 metric 2147483647\" )" +} + +# vim:ts=4 diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2 index 09fcfa5..2052998 100644 --- a/net-scripts/net.modules.d/iproute2 +++ b/net-scripts/net.modules.d/iproute2 @@ -28,11 +28,11 @@ iproute2_depend() { # Returns 1 if iproute2 is installed, otherwise 0 iproute2_check_installed() { local report="${1:-false}" installed="0" - if [[ ! -x /sbin/ip ]]; then + if [[ ! -x /sbin/ip ]] ; then installed="1" ${report} && eerror "For iproute2 support, emerge sys-apps/iproute2" fi - if [[ ! -e /proc/net/netlink ]]; then + if [[ ! -e /proc/net/netlink ]] ; then installed="1" ${report} && eerror "iproute2 requires NetLink enabled in the kernel" fi @@ -43,7 +43,7 @@ iproute2_check_installed() { # # Returns 1 if the interface exists, otherwise 0 iproute2_exists() { - local e=$( ip addr show label "$1" ) report="${2:-false}" + local e="$( ip addr show label "$1" )" report="${2:-false}" [[ -n ${e} ]] && return 0 if ${report} ; then @@ -93,8 +93,7 @@ iproute2_set_flag() { # Fetch the address retrieved by DHCP. If successful, echoes the # address on stdout, otherwise echoes nothing. iproute2_get_address() { - ip -family inet addr show "$1" \ - | sed -n -e 's/.*inet \([^ ]*\).*/\1/p' + ip -family inet addr show "$1" | sed -n -e 's/.*inet \([^ ]*\).*/\1/p' } # bool iproute2_is_ethernet(char *interface) @@ -108,8 +107,8 @@ iproute2_is_ethernet() { # # Fetch the mac address assingned to the network card iproute2_get_mac_address() { - local mac=$( ip link show "$1" | sed -n -e \ - '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' ) + local mac="$( ip link show "$1" | sed -n -e \ + '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )" [[ ${mac} != '00:00:00:00:00:00' \ && ${mac} != '44:44:44:44:44:44' \ && ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \ @@ -137,7 +136,7 @@ iproute2_set_name() { # Outputs a space-separated list on stdout, in reverse order, for # example "eth0:2 eth0:1" iproute2_get_aliases_rev() { - local iface=$( interface_device "$1" ) + local iface="$( interface_device "$1" )" ip addr show dev "${iface}" | grep -o "${iface}:[0-9].*" | tac } @@ -158,7 +157,7 @@ iproute2_del_addresses() { # # Returns config and config_fallback for the given interface iproute2_get_old_config() { - local ifvar=$( bash_variable "$1" ) inet6 t + local ifvar="$( bash_variable "$1" )" inet6="" t="" # iproute2-style config vars t="ipaddr_${ifvar}[@]" @@ -190,10 +189,10 @@ iproute2_get_old_config() { # # Returns 0 (true) when successful, non-zero (false) on failure iproute2_iface_stop() { - local label="$1" iface=$( interface_device "$1" ) + local label="$1" iface="$( interface_device "$1" )" # Shut down the link if this isn't an alias or vlan - if [[ ${label} == "${iface}" ]]; then + if [[ ${label} == "${iface}" ]] ; then iproute2_down "${iface}" return $? fi @@ -205,7 +204,7 @@ iproute2_iface_stop() { # Adds an the specified address to the interface # returns 0 on success and non-zero on failure iproute2_add_address() { - local iface="$1" x + local iface="$1" x="" iproute2_exists "${iface}" true || return 1 @@ -218,7 +217,7 @@ iproute2_add_address() { for (( x=0; x<n; x++ )); do case "${config[x]}" in netmask) - config[0]="${config[0]}/$( netmask2cidr ${config[x+1]} )" + config[0]="${config[0]}/$( netmask2cidr "${config[x+1]}" )" unset config[x] config[x+1] ;; mtu) @@ -231,10 +230,10 @@ iproute2_add_address() { # Always scope lo addresses as host unless specified otherwise [[ ${iface} == "lo" && " ${config[@]} " != *" scope "* ]] \ - && config=( "${config[@]}" "scope host" ) + && config=( "${config[@]}" "scope host" ) # IPv4 specifics - if [[ ${config[@]} == *.*.*.* ]]; then + if [[ ${config[@]} == *.*.*.* ]] ; then # Work out a broadcast if none supplied [[ ${config[@]} != *" brd "* && ${config[@]} != *" broadcast "* ]] \ && config=( "${config[@]}" "brd +" ) @@ -245,7 +244,7 @@ iproute2_add_address() { # Some kernels like to apply lo with an address when they are brought up if [[ ${iface} == "lo" \ - && ${config[@]} == "127.0.0.1/8 brd 127.255.255.255 scope host" ]]; then + && ${config[@]} == "127.0.0.1/8 brd 127.255.255.255 scope host" ]] ; then ip addr del dev "${iface}" 127.0.0.1/8 2>/dev/null fi @@ -253,18 +252,18 @@ iproute2_add_address() { local r="$?" [[ ${r} != "0" ]] && return "${r}" - local metric ifvar=$( bash_variable "${iface}" ) + local ifvar="$( bash_variable "${iface}" )" # Remove the newly added route and replace with our metric - metric="metric_${ifvar}" - [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return "${r}" + local metric="metric_${ifvar}" + [[ ${!metric:-0} == "0" ]] && return "${r}" - local network=$( ip_network "${config[0]}" ) + local network="$( ip_network "${config[0]}" )" [[ -z ${network} ]] && return "${r}" 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:-0}" dev "${iface}" fi return "${r}" @@ -280,10 +279,10 @@ iproute2_pre_start() { interface_exists "${iface}" || return 0 - local ifvar=$( bash_variable "$1" ) mtu + local ifvar="$( bash_variable "$1" )" # MTU support - mtu="mtu_${ifvar}" + local mtu="mtu_${ifvar}" [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" return 0 @@ -294,7 +293,7 @@ iproute2_pre_start() { # Runs any post_start stuff on our interface and adds routes # Always returns 0 iproute2_post_start() { - local iface="$1" ifvar=$( bash_variable "$1" ) routes metric mtu x netmask + local iface="$1" ifvar="$( bash_variable "$1" )" x="" iproute2_exists "${iface}" || return 0 @@ -302,50 +301,73 @@ iproute2_post_start() { iproute2_up "${iface}" # MTU support - mtu="mtu_${ifvar}" + local mtu="mtu_${ifvar}" [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" - x="routes_${ifvar}[@]" - routes=( "${!x}" ) - metric="metric_${ifvar}" + local x="routes_${ifvar}[@]" + local -a routes=( "${!x}" ) + local metric="metric_${ifvar}" # Test for old style ipaddr variable - if [[ -z ${routes} ]]; then + if [[ -z ${routes} ]] ; then t="iproute_${ifvar}[@]" routes=( "${!t}" ) fi - [[ -z ${routes} ]] && return 0 - # Set routes with ip route -- this might also include default route - einfo "Adding routes" - eindent - for x in "${routes[@]}"; do - ebegin "${x}" - - # Support net-tools routing too - x="${x//gw/via}" - 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 }" - if [[ -n ${netmask} && ${x} != "${netmask}" ]]; then - netmask="${netmask%% *}" - x="${x// netmask ${netmask} / }" - local -a a=( ${x} ) - a[0]="${a[0]}/$( netmask2cidr ${netmask} )" - x="${a[@]}" - fi + if [[ -n ${routes} ]] ; then + einfo "Adding routes" + eindent + for x in "${routes[@]}"; do + ebegin "${x}" + + # Support net-tools routing too + x="${x//gw/via}" + 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 }" + if [[ -n ${netmask} && ${x} != "${netmask}" ]] ; then + netmask="${netmask%% *}" + x="${x// netmask ${netmask} / }" + local -a a=( ${x} ) + a[0]="${a[0]}/$( netmask2cidr "${netmask}")" + x="${a[@]}" + fi + + # Add a metric if we don't have one + [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}" + + ip route append ${x} dev "${iface}" + eend $? + done + eoutdent + fi - # Add a metric if we don't have one - [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}" + # Now apply any rules we may want + x="rules_${ifvar}[@]" + local -a rules=( "${!x}" ) + if [[ -n ${rules} ]] ; then + einfo "Adding IP policy routing rules" + eindent + # Ensure that the kernel supports policy routing + if ! ip rule list | grep -q "^" ; then + eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)" + eerror "in your kernel to use ip rules" + else + for x in "${rules[@]}" ; do + ebegin "${x}" + ip rule add ${x} dev "${iface}" + eend $? + done + fi + eoutdent + fi - ip route append ${x} dev "${iface}" - eend $? - done - eoutdent + # Flush the route cache + ip route flush cache dev "${iface}" return 0 } @@ -354,7 +376,7 @@ iproute2_post_start() { # # Change all routes for an interface to a given metric iproute2_route_metric() { - local route + local route="" ip route | grep " dev $1" | { while read route ; do ip route del ${route} @@ -374,4 +396,22 @@ iproute2_default_route() { || ip route append default via "$2" metric "${metric}" dev "$1" 2>/dev/null } +# void iproute2_post_stop(char* interface) +iproute2_post_stop() { + local iface="$1" rule="" + + iproute2_exists "${iface}" || return + + # Remove any rules for this interface + ip rule list | grep " iif ${iface}[ ]*" | { + while read rule ; do + rule="${rule#*:}" + ip rule del ${rule} + done + } + + # Flush the route cache + ip route flush cache dev "${iface}" +} + # vim:ts=4 diff --git a/net-scripts/net.modules.d/iptunnel b/net-scripts/net.modules.d/iptunnel index 73e7594..13fd824 100644 --- a/net-scripts/net.modules.d/iptunnel +++ b/net-scripts/net.modules.d/iptunnel @@ -8,7 +8,6 @@ # # Sets up the dependancies for the module iptunnel_depend() { - after wireless before interface functions interface_exists interface_tunnel variables iptunnel @@ -35,6 +34,9 @@ iptunnel_pre_start() { iptunnel_stop() { local iface="$1" + # Don't delete sit0 as it's a special tunnel + [[ ${iface} == "sit0" ]] && return 0 + interface_exists "${iface}" || return 0 [[ -z $( interface_tunnel show "${iface}" 2>/dev/null ) ]] && return 0 diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig index 68f70b3..30e0249 100644 --- a/net-scripts/net.modules.d/iwconfig +++ b/net-scripts/net.modules.d/iwconfig @@ -63,12 +63,12 @@ iwconfig_exists() { # Echos a string showing whether WEP is enabled or disabled # for the given interface iwconfig_get_wep_status() { - local key=$( iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]" ) + local key="$( iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]" )" local mode status="disabled" if [[ -n ${key} ]]; then status="enabled" - mode="$( iwconfig $1 | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p' )" + mode="$( iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p' )" [[ -n ${mode} ]] && mode=" - ${mode}" fi @@ -82,7 +82,7 @@ iwconfig_get_essid() { local i essid for (( i=0; i<5; i++ )); do - essid="$( iwgetid $1 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )" + essid="$( iwgetid "$1" 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )" if [[ -n ${essid} ]]; then echo "${essid}" return 0 @@ -121,18 +121,18 @@ iwconfig_get_type() { iwconfig_report() { local iface="$1" essid mac m="to" - essid=$( iwconfig_get_essid "${iface}" ) + essid="$( iwconfig_get_essid "${iface}" )" - local wep_status=$( iwconfig_get_wep_status "${iface}" ) - local channel=$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 ) + local wep_status="$( iwconfig_get_wep_status "${iface}" )" + local channel="$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 )" [[ -n ${channel} ]] && channel="on channel ${channel} " essid="${essid//\\\\/\\\\}" - local mode=$( iwconfig_get_mode "${iface}" ) + local mode="$( iwconfig_get_mode "${iface}" )" if [[ ${mode} == "master" ]]; then m="as" elif [[ ${mode} != "ad-hoc" ]]; then - mac=$( iwconfig_get_ap_mac_address "${iface}" ) + mac="$( iwconfig_get_ap_mac_address "${iface}" )" [[ -n ${mac} ]] && mac=" at ${mac}" fi @@ -158,7 +158,7 @@ iwconfig_get_wep_key() { # Applies the user configuration to the interface iwconfig_user_config() { local iface="$1" conf aconf ifvar="$2" - [[ -z ${ifvar} ]] && ifvar=$( bash_variable "$1" ) + [[ -z ${ifvar} ]] && ifvar="$( bash_variable "$1" )" # Apply the user configuration conf="iwconfig_${ifvar}" @@ -189,7 +189,7 @@ iwconfig_user_config() { # Sets up our wireless interface to operate in ad-hoc or master mode iwconfig_setup_specific() { local iface="$1" mode="$2" channel key dessid - local ifvar=$( bash_variable "$1" ) + local ifvar="$( bash_variable "$1" )" if [[ -z ${ESSID} ]]; then eerror "${iface} requires an ESSID to be set to operate in ${mode} mode" @@ -197,11 +197,11 @@ iwconfig_setup_specific() { return 1 fi dessid="${ESSID//\\\\/\\\\}" - ESSIDVAR=$( bash_variable "${ESSID}" ) - key=$( iwconfig_get_wep_key ) + ESSIDVAR="$( bash_variable "${ESSID}" )" + key="$( iwconfig_get_wep_key )" # We only change the mode if it's not the same - local cur_mode=$( iwconfig_get_mode "${iface}" ) + local cur_mode="$( iwconfig_get_mode "${iface}" )" if [[ ${cur_mode} != "${mode}" ]]; then if ! iwconfig "${iface}" mode "${mode}" ; then eerror "${iface} does not support setting the mode to \"${mode}\"" @@ -218,7 +218,7 @@ iwconfig_setup_specific() { fi # Now set the key - if ! eval iwconfig "${iface}" key "${key}" ; then + if ! 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" @@ -230,7 +230,6 @@ iwconfig_setup_specific() { eerror "${iface} does not support setting ESSID to \"${dessid}\"" return 1 fi - iwconfig "${iface}" nick "${ESSID}" 2>/dev/null # Finally apply the user Config iwconfig_user_config "${iface}" "${ESSIDVAR}" @@ -245,7 +244,7 @@ iwconfig_setup_specific() { # Returns true if the AP MAC address is valid or not iwconfig_associate_mac() { # Checks if a MAC address has been assigned - local mac="$( iwconfig_get_ap_mac_address $1 )" i + local mac="$( iwconfig_get_ap_mac_address "$1" )" i local -a invalid_macs=( "00:00:00:00:00:00" "44:44:44:44:44:44" @@ -264,10 +263,10 @@ iwconfig_associate_mac() { # # Returns true if the link quality is not 0 or 0. iwconfig_associate_quality() { - local quality=$( \ + local quality="$( \ sed -n -e 's/^.*'"$1"': *[0-9]* *\([0-9]*\).*/\1/p' \ /proc/net/wireless - ) + )" [[ ${quality} != "0" ]] return "$?" } @@ -276,12 +275,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" ) x + 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 x="associate_test_${ifvar}" - ttype=$( echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]' ) + 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\"" @@ -303,7 +302,7 @@ iwconfig_test_associated() { # Waits for a configured ammount of time until # we are assocaited with an Access Point iwconfig_wait_for_association() { - local iface="$1" i=0 timeout ifvar=$( bash_variable "$1" ) + local iface="$1" i=0 timeout ifvar="$( bash_variable "$1" )" timeout="associate_timeout_${ifvar}" [[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}" timeout="${!timeout:-10}" @@ -338,8 +337,8 @@ iwconfig_associate() { dessid="any" unset ESSIDVAR else - ESSIDVAR=$( bash_variable "${ESSID}" ) - key=$( iwconfig_get_wep_key "${mac}" ) + ESSIDVAR="$( bash_variable "${ESSID}" )" + key="$( iwconfig_get_wep_key "${mac}" )" if [[ ${wep_required} == "on" && ${key} == "off" ]]; then eerror "WEP key is not set for \"${dessid}\" - not connecting" return 1 @@ -349,14 +348,14 @@ iwconfig_associate() { ewarn "\"${dessid}\" is not WEP enabled - ignoring setting" fi - if ! eval iwconfig "${iface}" key "${key}" ; then + if ! 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" return 1 fi fi - [[ ${key} != "off" ]] && w=$( iwconfig_get_wep_status "${iface}" ) + [[ ${key} != "off" ]] && w="$( iwconfig_get_wep_status "${iface}" )" fi if ! iwconfig "${iface}" essid "${ESSID}" ; then @@ -364,7 +363,6 @@ iwconfig_associate() { ewarn "${iface} does not support setting ESSID to \"${dessid}\"" fi fi - iwconfig "${iface}" nick "${ESSID}" 2>/dev/null # Finally apply the user Config iwconfig_user_config "${iface}" "${ESSIDVAR}" @@ -390,7 +388,7 @@ iwconfig_associate() { veend 0 if [[ ${ESSID} == "any" ]]; then - ESSID=$( iwconfig_get_essid "${iface}" ) + ESSID="$( iwconfig_get_essid "${iface}" )" iwconfig_associate "${iface}" return $? fi @@ -411,11 +409,11 @@ iwconfig_associate() { # # Fills 3 arrays with information from a wireless scan iwconfig_scan() { - local iface="$1" mode x ifvar=$( bash_variable "$1" ) + local iface="$1" mode x ifvar="$( bash_variable "$1" )" # First, we may need to change mode to scan in x="scan_mode_${ifvar}" - mode=$( echo "${!x}" | tr '[:upper:]' '[:lower:]' ) + 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}\"" @@ -448,14 +446,14 @@ iwconfig_scan() { case "${line}" in *Address:*) (( i++ )) - mac[i]=$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' ) + mac[i]="$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' )" ;; *ESSID:*) essid[i]="${line#*\"}" essid[i]="${essid[i]%*\"}" ;; *Mode:*) - mode[i]=$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]' ) + mode[i]="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]' )" [[ ${mode[i]} == "master" ]] && mode[i]="managed" ;; *'Encryption key:'*) @@ -502,7 +500,7 @@ iwconfig_scan() { # Change back mode if needed x="mode_${ifvar}" - x=$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' ) + x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )" [[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}" for (( i=0; i<${#mac[@]}; i++ )); do @@ -681,12 +679,13 @@ iwconfig_defaults() { # Set some defaults iwconfig "${iface}" rate auto &>/dev/null - iwconfig "${iface}" rts off &>/dev/null - iwconfig "${iface}" frag off &>/dev/null - iwconfig "${iface}" power off &>/dev/null + iwconfig "${iface}" rts auto &>/dev/null + iwconfig "${iface}" frag auto &>/dev/null iwconfig "${iface}" txpower auto &>/dev/null iwconfig "${iface}" key [1] off &>/dev/null iwconfig "${iface}" mode managed &>/dev/null + iwconfig "${iface}" essid -- off &>/dev/null + iwconfig "${iface}" ap off &>/dev/null } # void iwconfig_strip_associated(char *iface) @@ -696,15 +695,15 @@ iwconfig_defaults() { # We also remove from the preferred list iwconfig_strip_associated() { local iface="$1" e a j - local essid=$( iwconfig_get_essid "${iface}" ) + local essid="$( iwconfig_get_essid "${iface}" )" local -a ifaces=( $( iwconfig 2>/dev/null | grep -o "^\w*" ) ) for i in "${ifaces[@]}"; do [[ ${i} == ${iface} ]] && continue interface_is_up "${i}" || continue iwconfig_test_associated "${i}" || continue - e=$( iwconfig_get_essid "${i}" ) - u=() + e="$( iwconfig_get_essid "${i}" )" + local -a u=() for ((j=0; j<${#mac_APs[@]}; j++)); do if [[ ${essid_APs[j]} == "${e}" ]]; then ewarn "${e} has already been associated with ${i}" @@ -739,7 +738,7 @@ iwconfig_strip_associated() { # Once we're connected we show a report and then configure any interface # variables for the ESSID iwconfig_configure() { - local iface="$1" test x e ifvar=$( bash_variable "$1" ) + local iface="$1" test x e ifvar="$( bash_variable "$1" )" local -a essid_APs mac_APs mode_APs enc_APs iwconfig_defaults "${iface}" @@ -750,7 +749,7 @@ iwconfig_configure() { # Setup ad-hoc mode? x="mode_${ifvar}" - x=$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' ) + x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )" if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then iwconfig_setup_specific "${iface}" "${x}" return $? @@ -763,7 +762,7 @@ iwconfig_configure() { # We only change the mode if it's not the same as some drivers # only do managed and throw an error changing to managed - local cur_mode=$( iwconfig_get_mode "${iface}" ) + local cur_mode="$( iwconfig_get_mode "${iface}" )" if [[ ${cur_mode} != "${x}" ]]; then if ! iwconfig "${iface}" mode "${x}" ; then eerror "${iface} does not support setting the mode to \"${x}\"" @@ -799,10 +798,10 @@ iwconfig_configure() { # Are we forcing preferred only? x="associate_order_${ifvar}" [[ -n ${!x} ]] && associate_order="${!x}" - associate_order=$( + associate_order="$( echo "${associate_order:-any}" \ | tr '[:upper:]' '[:lower:]' - ) + )" if [[ ${associate_order} == "forcepreferredonly" ]]; then iwconfig_force_preferred "${iface}" && return 0 @@ -814,7 +813,7 @@ iwconfig_configure() { # other wireless cards in the system if requested x="unique_ap_${ifvar}" [[ -n ${!x} ]] && unique_ap="${!x}" - unique_ap=$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' ) + unique_ap="$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' )" [[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}" iwconfig_connect_preferred "${iface}" && return 0 @@ -883,7 +882,7 @@ iwconfig_pre_start() { # and RA cards return RAPCI or similar which really sucks :( # For the time being, we will test prism54 not loading firmware which reports # NOT READY! - x=$( iwconfig_get_type "${iface}" ) + x="$( iwconfig_get_type "${iface}" )" if [[ ${x} == "NOT READY!" ]]; then eerror "Looks like there was a probem loading the firmware for ${iface}" return 1 diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet index ec01449..4c84b2d 100644 --- a/net-scripts/net.modules.d/macnet +++ b/net-scripts/net.modules.d/macnet @@ -18,7 +18,7 @@ macnet_depend() { # bool macnet_start(char *iface) # -# All interfaces and module scripts expose modulename_get_vars +# All interfaces and module scripts can depend on the variables function # which returns a space seperated list of user configuration variables # We can override each variable here from a given MAC address of the interface # Always returns 0 diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd index bd707c8..4a46045 100644 --- a/net-scripts/net.modules.d/pppd +++ b/net-scripts/net.modules.d/pppd @@ -15,7 +15,7 @@ pppd_depend() { # # Returns 1 if pppd is installed, otherwise 0 pppd_check_installed() { - if [[ ! -x /usr/sbin/pppd ]]; then + if [[ ! -x /usr/sbin/pppd ]] ; then ${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" return 1 fi @@ -56,7 +56,7 @@ pppd_regex_escape() { # Add/update PAP/CHAP authentication information pppd_update_secrets_file() { local filepath="$1" username="$2" remotename="$3" password="$4" - if [[ ! -s ${filepath} ]]; then + if [[ ! -s ${filepath} ]] ; then echo '#'client$'\t'server$'\t'secret$'\t'IP addresses > "${filepath}" \ && chmod 0600 "${filepath}" \ || return 1 @@ -77,14 +77,14 @@ pppd_update_secrets_file() { ${filepath} ) - if [[ -z "${old_password}" ]]; then + 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 + elif [[ "\"${password//\"/\\\"}\"" != "${old_password}" ]] ; then regex_password="${password//\\/\\\\}" regex_password="${regex_password//\//\\/}" regex_password="${regex_password//&/\\&}" @@ -104,7 +104,7 @@ pppd_start() { ${IN_BACKGROUND} && return 0 local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link - if [[ ${iface%%[0-9]*} != "ppp" ]]; then + if [[ ${iface%%[0-9]*} != "ppp" ]] ; then eerror "PPP can only be invoked from net.ppp[0-9]" return 1 fi @@ -120,7 +120,7 @@ pppd_start() { # PPPoA communicates over ATM # In all cases, the link needs to be available before we start PPP link="link_${ifvar}" - if [[ -z ${!link} ]]; then + if [[ -z ${!link} ]] ; then eerror "${link} has not been set in /etc/conf.d/net" return 1 fi @@ -131,7 +131,7 @@ pppd_start() { password="password_${ifvar}" #Add/update info in PAP/CHAP secrets files - if [[ -n ${!username} && -n ${!password} ]]; then + 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 @@ -146,16 +146,16 @@ pppd_start() { 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" + for i in unit nodetach linkname ; do + if [[ " ${opts} " == *" ${i} "* ]] ; then + eerror "The option \"${i}\" is not allowed in pppd_${ifvar}" return 1 fi done # Check for mtu/mru local mtu="mtu_${ifvar}" - if [[ -n ${!mtu} ]]; then + if [[ -n ${!mtu} ]] ; then [[ " ${opts} " != *" mtu "* ]] && opts="${opts} mtu ${!mtu}" [[ " ${opts} " != *" mru "* ]] && opts="${opts} mru ${!mtu}" fi @@ -172,28 +172,28 @@ pppd_start() { [[ -f "/etc/ppp/options.${iface}" ]] \ && opts="${opts} file /etc/ppp/options.${iface}" - # Set forced options - opts="unit ${unit} persist maxfail 0 ${opts}" + # Set unit + opts="unit ${unit} ${opts}" + # Default maxfail to 0 unless specified + [[ " ${opts} " != *" maxfail "* ]] && opts="${opts} maxfail 0" + + # Append persist + [[ " ${opts} " != *" persist "* ]] && opts="${opts} persist" + # Setup connect script local chat="chat_${ifvar}[@]" - if [[ -n "${!chat}" ]]; then - opts="${opts} connect \"/usr/sbin/chat -e -E -v" - + if [[ -n "${!chat}" ]] ; then + local chatopts="/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]}'" + if [[ ${#phone_number[@]} -ge 1 ]] ; then + chatopts="${chatopts} -T '${phone_number[0]}'" + if [[ ${#phone_number[@]} -ge 2 ]] ; then + chatopts="${chatopts} -U '${phone_number[1]}'" fi fi - - for i in "${!chat}"; do - opts="${opts} '${i}'" - done - - opts="${opts}\"" + opts="${opts} connect $(requote "${chatopts} $(requote "${!chat}")")" fi # Add plugins @@ -212,8 +212,8 @@ pppd_start() { #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 + 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" @@ -228,8 +228,8 @@ pppd_start() { insert_link_in_opts=0 fi - if [[ " ${opts} " == *" plugin pppoatm.so "* ]]; then - if [[ ! -d /proc/net/atm ]]; then + 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" @@ -243,13 +243,13 @@ pppd_start() { [[ " ${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 + if [[ $? != "0" ]] ; then eend $? "Failed to start PPP" mark_service_starting "net.${iface}" return $? fi - if [[ " ${opts} " == *" updetach "* ]]; then + if [[ " ${opts} " == *" updetach "* ]] ; then local addr=$( interface_get_address "${iface}" ) einfo "${iface} received address ${addr}" else diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap index dffa5ad..bdea08c 100644 --- a/net-scripts/net.modules.d/tuntap +++ b/net-scripts/net.modules.d/tuntap @@ -14,8 +14,7 @@ tunctl() { # # Sets up the dependancies for the module tuntap_depend() { - after interface macnet - before dhcp + before interface macchanger functions interface_exists interface_type variables tunctl } diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index 4f621d1..77fc29c 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -58,7 +58,7 @@ wpa_supplicant_get_essid() { local i essid for (( i=0; i<5; i++ )); do - essid="$( wpa_cli -i$1 status | sed -n -e 's/^ssid=//p' )" + essid="$( wpa_cli -i"$1" status | sed -n -e 's/^ssid=//p' )" if [[ -n ${essid} ]]; then echo "${essid}" return 0 @@ -120,7 +120,7 @@ wpa_supplicant_kill() { ${report} && eend "$?" else # Support wpa_supplicant-0.3.x - local pid=$( pgrep -f '^/sbin/wpa_supplicant .* -i'"${iface}"'[ ]*$' ) + local pid="$( pgrep -f "^/sbin/wpa_supplicant .* -i${iface}[ ]*$" )" if [[ -n ${pid} ]]; then ${report} && ebegin "Stopping wpa_supplicant on ${iface}" kill -s TERM "${pid}" @@ -138,7 +138,7 @@ wpa_supplicant_kill() { # Returns 0 if wpa_supplicant associates and authenticates to an AP # otherwise, 1 wpa_supplicant_associate() { - local iface="$1" ifvar=$( bash_variable "$1" ) timeout i + local iface="$1" ifvar="$( bash_variable "$1" )" timeout i timeout="associate_timeout_${ifvar}" [[ -z ${!timeout} ]] && timeout="wpa_timeout_${ifvar}" timeout="${!timeout:--1}" @@ -151,7 +151,7 @@ wpa_supplicant_associate() { fi while true ; do - if ${action} ; then + if [[ -n ${actfile} ]] ; then service_started "net.${iface}" && return 0 else if ! wpa_cli -i"${iface}" status &>/dev/null ; then @@ -166,7 +166,7 @@ wpa_supplicant_associate() { done # Spit out an appropriate error - if ${action} ; then + if [[ -n ${actfile} ]] ; then eend 1 "Failed to configure ${iface} in the background" else eend 1 "Timed out" @@ -174,7 +174,7 @@ wpa_supplicant_associate() { # exit without error with wpa_supplicant-0.4.x as we may get kickstarted # when an AP comes in range - ${action} && exit 0 + [[ -n ${actfile} ]] && exit 0 # Kill wpa_supplicant for 0.3.x wpa_supplicant_kill "${iface}" @@ -186,16 +186,15 @@ wpa_supplicant_associate() { # Start wpa_supplicant on an interface and wait for association # Returns 0 (true) when successful, non-zero otherwise wpa_supplicant_pre_start() { - local iface="$1" opts timeout action=false cfgfile - local actfile="/sbin/wpa_cli.action" + local iface="$1" opts="" timeout="" actfile="" cfgfile="" # We don't configure wireless if we're being called from # the background unless we're not currently running if ${IN_BACKGROUND} ; then if service_started_daemon "net.${iface}" /sbin/wpa_supplicant ; then if wpa_supplicant_exists "${iface}" ; then - ESSID=$( wpa_supplicant_get_essid "${iface}" ) - ESSIDVAR=$( bash_variable "${ESSID}" ) + ESSID="$( wpa_supplicant_get_essid "${iface}" )" + ESSIDVAR="$( bash_variable "${ESSID}" )" save_options "ESSID" "${ESSID}" fi return 0 @@ -204,7 +203,7 @@ wpa_supplicant_pre_start() { save_options "ESSID" "" - local ifvar=$( bash_variable "${iface}" ) + local ifvar="$( bash_variable "${iface}" )" opts="wpa_supplicant_${ifvar}" opts=" ${!opts} " [[ ${opts} != *" -D"* ]] \ @@ -246,8 +245,13 @@ wpa_supplicant_pre_start() { [[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}" cfgfile="${cfgfile%% *}" else - cfgfile="/etc/wpa_supplicant.conf" - opts="${opts} -c/etc/wpa_supplicant.conf" + # Support new and old style locations + cfgfile="/etc/wpa_supplicant/wpa_supplicant-${iface}.conf" + [[ ! -e ${cfgfile} ]] \ + && cfgfile="/etc/wpa_supplicant/wpa_supplicant.conf" + [[ ! -e ${cfgfile} ]] \ + && cfgfile="/etc/wpa_supplicant.conf" + opts="${opts} -c${cfgfile}" fi if [[ ! -f ${cfgfile} ]]; then @@ -255,7 +259,7 @@ wpa_supplicant_pre_start() { return 1 fi - local ctrl_dir=$( sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' "${cfgfile}" ) + local ctrl_dir="$( sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' "${cfgfile}" )" if [[ ${ctrl_dir} != "/var/run/wpa_supplicant" ]]; then eerror "${cfgfile} must set" eerror " ctrl_interface=/var/run/wpa_supplicant" @@ -266,7 +270,7 @@ wpa_supplicant_pre_start() { # Some drivers require the interface to be up interface_up "${iface}" - version=$( wpa_cli -v | sed -n -e 's/wpa_cli v//p' ) + version="$( wpa_cli -v | sed -n -e 's/wpa_cli v//p' )" version=( ${version//./ } ) (( version = version[0] * 1000 + version[1] * 100 + version[2] )) @@ -276,9 +280,12 @@ wpa_supplicant_pre_start() { # wpa_cli is now responsible for informing us of success/failure. # The downside of this is that we don't see the interface being configured # for DHCP/static. - if [[ ${version} -gt 399 && -x ${actfile} ]]; then + if [[ ${version} -gt 399 ]]; then opts="${opts} -W -P/var/run/wpa_supplicant-${iface}.pid" - action=true + actfile="/etc/wpa_supplicant/wpa_cli.sh" + # Support old file location + [[ ! -x ${actfile} ]] && actfile="/sbin/wpa_cli.action" + [[ ! -x ${actfile} ]] && unset actfile fi eval start-stop-daemon --start --exec /sbin/wpa_supplicant \ @@ -288,7 +295,7 @@ wpa_supplicant_pre_start() { # Starting wpa_supplication-0.4.0, we can get wpa_cli to # start/stop our scripts from wpa_supplicant messages - if ${action} ; then + if [[ -n ${actfile} ]] ; then mark_service_inactive "net.${iface}" ebegin "Starting wpa_cli on ${iface}" start-stop-daemon --start --exec /bin/wpa_cli \ @@ -307,8 +314,8 @@ wpa_supplicant_pre_start() { # Only report wireless info for wireless interfaces if wpa_supplicant_exists "${iface}" ; then # Set ESSID for essidnet and report - ESSID=$( wpa_supplicant_get_essid "${iface}" ) - ESSIDVAR=$( bash_variable "${ESSID}" ) + ESSID="$( wpa_supplicant_get_essid "${iface}" )" + ESSIDVAR="$( bash_variable "${ESSID}" )" save_options "ESSID" "${ESSID}" local -a status @@ -329,8 +336,8 @@ wpa_supplicant_pre_start() { einfo "${iface} connected" fi - if ${action} ; then - local addr=$( interface_get_address "${iface}" ) + if [[ -n ${actfile} ]] ; then + local addr="$( interface_get_address "${iface}" )" einfo "${iface} configured with address ${addr}" exit 0 fi diff --git a/sbin/runscript.sh b/sbin/runscript.sh index 8441fcc..156ddb2 100755 --- a/sbin/runscript.sh +++ b/sbin/runscript.sh @@ -554,6 +554,7 @@ for arg in $* ; do rm -rf "${svcdir}/snapshot/$$" mkdir -p "${svcdir}/snapshot/$$" cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/" + rm -f "${svcdir}/snapshot/$$/${myservice}" fi svc_stop @@ -597,6 +598,7 @@ for arg in $* ; do rm -rf "${svcdir}/snapshot/$$" mkdir -p "${svcdir}/snapshot/$$" cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/" + rm -f "${svcdir}/snapshot/$$/${myservice}" # Simple way to try and detect if the service use svc_{start,stop} # to restart if it have a custom restart() funtion. @@ -619,7 +621,7 @@ for arg in $* ; do [[ -e "${svcdir}/scheduled/${myservice}" ]] \ && rm -Rf "${svcdir}/scheduled/${myservice}" - + # Restart dependencies as well for x in $(dolisting "${svcdir}/snapshot/$$/") ; do if service_stopped "${x##*/}" ; then @@ -627,7 +629,7 @@ for arg in $* ; do || service_wasinactive "${myservice}" ; then svc_schedule_start "${myservice}" "${x##*/}" ewarn "WARNING: ${x##*/} is scheduled to start when ${myservice} has started." - else + elif service_started "${myservice}" ; then start_service "${x##*/}" fi fi diff --git a/src/core/autogen.sh b/src/core/autogen.sh index 03951c2..50dfcf8 100644 --- a/src/core/autogen.sh +++ b/src/core/autogen.sh @@ -1,6 +1,10 @@ #!/bin/bash +# Generate Changelog by default if we in svn repository if [[ -d .svn && $1 != -n ]] ; then + # For some reason svn do not give the full log if we do not + # update first ... + svn update ./scripts/svn2cl.sh fi diff --git a/src/core/configure.ac b/src/core/configure.ac index 1528b38..2e8e66b 100644 --- a/src/core/configure.ac +++ b/src/core/configure.ac @@ -62,12 +62,23 @@ AC_TRY_COMPILE([ AC_MSG_RESULT([$va_copy]) if test x"$va_copy" != xva_copy ; then AC_DEFINE_UNQUOTED([va_copy], [$va_copy], - [va_copy macro proviced by gcc (undefined if its va_copy, else defined - to proper name)] + [Define to name of va_copy macro proviced by gcc if its not `va_copy'.] ) fi -dnl check if we have 32bit or 64bit output +dnl Check if we want SELinux support +AC_ARG_ENABLE([selinux], + AS_HELP_STRING([--enable-selinux], + [enable SELinux support (default=disabled)]), + [enable_selinux="$enableval"], + [enable_selinux="no"] +) + +if test x"$enable_selinux" != xno ; then + AC_DEFINE([WANT_SELINUX], [], [Define if SELinux support is required.]) +fi + +dnl Check if we want debugging AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [enable debugging - very verbose (default=disabled)]), diff --git a/src/core/scripts/svn2cl.sh b/src/core/scripts/svn2cl.sh index bf89bb0..06eba0e 100644 --- a/src/core/scripts/svn2cl.sh +++ b/src/core/scripts/svn2cl.sh @@ -32,46 +32,84 @@ # exit on any failures set -e +# report unset variables +set -u # svn2cl version -VERSION="0.3" +VERSION="0.5" # set default parameters -STRIPPREFIX=`basename $(pwd)` +PWD=`pwd` +STRIPPREFIX=`basename $PWD` LINELEN=75 GROUPBYDAY="no" INCLUDEREV="no" -CHANGELOG="ChangeLog" +CHANGELOG="" +OUTSTYLE="cl" +SVNCMD="svn --verbose --xml log" # do command line checking prog=`basename $0` -while [ -n "$1" ] +while [ $# -gt 0 ] do case "$1" in --strip-prefix) STRIPPREFIX="$2" - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --strip-prefix=*) + STRIPPREFIX="`echo "$1" | sed 's/--strip-prefix=//'`" + shift ;; --linelen) LINELEN="$2"; - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --linelen=*) + LINELEN="`echo "$1" | sed 's/--linelen=//'`" + shift ;; --group-by-day) GROUPBYDAY="yes"; shift ;; - -r|--include-rev) + -i|--include-rev) INCLUDEREV="yes"; shift ;; - -o|--output) + -f|--file|-o|--output) CHANGELOG="$2" - shift 2 + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --file=*|--output=*) + CHANGELOG="`echo "$1" | sed 's/--[^=]*=//'`" + shift ;; --stdout) CHANGELOG="-" shift ;; + --html) + OUTSTYLE="html" + shift + ;; + -r|--revision|--targets|--username|--password|--config-dir|--limit) + # add these as extra options to the command (with argument) + arg=`echo "$2" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD $1 '$arg'" + shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; } + ;; + --revision=*|--targets=*|--username=*|--password=*|--config-dir=*|--limit=*) + # these are single argument versions of the above + arg=`echo "$1" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD '$arg'" + shift + ;; + --stop-on-copy|--no-auth-cache|--non-interactive) + # add these as simple options + SVNCMD="$SVNCMD $1" + shift + ;; -V|--version) echo "$prog $VERSION"; echo "Written by Arthur de Jong." @@ -82,26 +120,37 @@ do exit 0 ;; -h|--help) - echo "Usage: $prog [OPTION]..." - echo "Generate a ChangeLog from a checked out subversion repository." + echo "Usage: $prog [OPTION]... [PATH]..." + echo "Generate a ChangeLog from a subversion repository." echo "" - echo " --strip-prefix NAME prefix to strip from all entries, defaults" + echo " --strip-prefix=NAME prefix to strip from all entries, defaults" echo " to the name of the current directory" - echo " --linelen NUM maximum length of an output line" + echo " --linelen=NUM maximum length of an output line" echo " --group-by-day group changelog entries by day" - echo " -r, --include-rev include revision numbers" - echo " -o, --output FILE output to FILE instead of ChangeLog" - echo " -f, --file FILE alias for -o, --output" + echo " -i, --include-rev include revision numbers" + echo " -o, --output=FILE output to FILE instead of ChangeLog" + echo " -f, --file=FILE alias for -o, --output" echo " --stdout output to stdout instead of ChangeLog" + echo " --html output as html instead of plain text" echo " -h, --help display this help and exit" echo " -V, --version output version information and exit" + echo "" + echo "PATH arguments and the following options are passed to the svn log" + echo "command: -r, --revision, --target --stop-on-copy, --username," + echo "--password, --no-auth-cache, --non-interactive, --config-dir," + echo "--limit (see \`svn help log' for more information)." exit 0 ;; - *) + -*) echo "$prog: invalid option -- $1" echo "Try \`$prog --help' for more information." exit 1 ;; + *) + arg=`echo "$1" | sed "s/'/'\"'\"'/g"` + SVNCMD="$SVNCMD '$arg'" + shift + ;; esac done @@ -109,11 +158,19 @@ done prog="$0" while [ -h "$prog" ] do - prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$(dirname "$prog")/,"` + dir=`dirname "$prog"` + prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$dir/,"` done dir=`dirname $prog` dir=`cd $dir && pwd` -XSL="$dir/svn2cl.xsl" +XSL="$dir/svn2${OUTSTYLE}.xsl" + +# if no filename was specified, make one up +if [ -z "$CHANGELOG" ] +then + CHANGELOG="ChangeLog" + [ "$OUTSTYLE" != "cl" ] && CHANGELOG="$CHANGELOG.$OUTSTYLE" +fi # redirect stdout to the changelog file if needed if [ "x$CHANGELOG" != "x-" ] @@ -122,7 +179,7 @@ then fi # actually run the command we need -svn --verbose --xml log | \ +eval "$SVNCMD" | \ xsltproc --stringparam strip-prefix "$STRIPPREFIX" \ --stringparam linelen $LINELEN \ --stringparam groupbyday $GROUPBYDAY \ diff --git a/src/core/scripts/svn2cl.xsl b/src/core/scripts/svn2cl.xsl index 3672035..e3e5d74 100644 --- a/src/core/scripts/svn2cl.xsl +++ b/src/core/scripts/svn2cl.xsl @@ -5,7 +5,8 @@ svn2cl.xsl - xslt stylesheet for converting svn log to a normal changelog - Usage (replace ++ with two minus signs): + Usage (replace ++ with two minus signs which aren't allowed + inside xml comments): svn ++verbose ++xml log | \ xsltproc ++stringparam strip-prefix `basename $(pwd)` \ ++stringparam linelen 75 \ @@ -48,27 +49,17 @@ <!DOCTYPE page [ <!ENTITY tab "	"> - <!ENTITY newl " "> + <!ENTITY newl " "> <!ENTITY space " "> ]> -<!-- - TODO - - make external lookups of author names possible - - find a place for revision numbers - - mark deleted files as such - - combine paths - - make path formatting nicer ---> - <xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns="http://www.w3.org/1999/xhtml"> + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" - encoding="iso-8859-15" + encoding="utf-8" media-type="text/plain" omit-xml-declaration="yes" standalone="yes" @@ -97,14 +88,14 @@ <!-- format one entry from the log --> <xsl:template match="logentry"> <!-- save log entry number --> - <xsl:variable name="pos" select="position()"/> + <xsl:variable name="pos" select="position()" /> <!-- fetch previous entry's date --> <xsl:variable name="prevdate"> - <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date"/> + <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/date" /> </xsl:variable> <!-- fetch previous entry's author --> <xsl:variable name="prevauthor"> - <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author"/> + <xsl:apply-templates select="../logentry[position()=(($pos)-1)]/author" /> </xsl:variable> <!-- fetch this entry's date --> <xsl:variable name="date"> @@ -132,20 +123,27 @@ <!-- get paths string --> <xsl:variable name="paths"> <xsl:apply-templates select="paths" /> + <xsl:text>:&space;</xsl:text> </xsl:variable> <!-- get revision number --> <xsl:variable name="rev"> <xsl:if test="$include-rev='yes'"> <xsl:text>[r</xsl:text> - <xsl:value-of select="@revision"/> + <xsl:value-of select="@revision" /> <xsl:text>]&space;</xsl:text> </xsl:if> </xsl:variable> + <!-- trim trailing newlines --> + <xsl:variable name="msg"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="msg" /> + </xsl:call-template> + </xsl:variable> <!-- first line is indented (other indents are done in wrap template) --> <xsl:text>&tab;*&space;</xsl:text> <!-- print the paths and message nicely wrapped --> <xsl:call-template name="wrap"> - <xsl:with-param name="txt" select="concat($rev,$paths,normalize-space(msg))" /> + <xsl:with-param name="txt" select="concat($rev,$paths,$msg)" /> </xsl:call-template> </xsl:template> @@ -175,10 +173,8 @@ <xsl:text>,&space;</xsl:text> </xsl:if> <!-- print the path name --> - <xsl:apply-templates select="."/> + <xsl:apply-templates select="." /> </xsl:for-each> - <!-- end the list with a colon --> - <xsl:text>:&space;</xsl:text> </xsl:template> <!-- transform path to something printable --> @@ -245,6 +241,18 @@ <xsl:template name="wrap"> <xsl:param name="txt" /> <xsl:choose> + <xsl:when test="contains($txt,'
')"> + <!-- text contains newlines, do the first line --> + <xsl:call-template name="wrap"> + <xsl:with-param name="txt" select="substring-before($txt,'
')" /> + </xsl:call-template> + <!-- print tab --> + <xsl:text>&tab;&space;&space;</xsl:text> + <!-- wrap the rest of the text --> + <xsl:call-template name="wrap"> + <xsl:with-param name="txt" select="substring-after($txt,'
')" /> + </xsl:call-template> + </xsl:when> <xsl:when test="(string-length($txt) < (($linelen)-9)) or not(contains($txt,' '))"> <!-- this is easy, nothing to do --> <xsl:value-of select="$txt" /> @@ -271,7 +279,7 @@ <xsl:text>&newl;&tab;&space;&space;</xsl:text> <!-- wrap the rest of the text --> <xsl:call-template name="wrap"> - <xsl:with-param name="txt" select="normalize-space(substring($txt,string-length($line)+1))" /> + <xsl:with-param name="txt" select="substring($txt,string-length($line)+1)" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> @@ -282,7 +290,7 @@ <xsl:param name="txt" /> <xsl:choose> <xsl:when test="substring($txt,string-length($txt),1) = ' '"> - <xsl:value-of select="normalize-space($txt)" /> + <xsl:value-of select="$txt" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="find-line"> @@ -292,4 +300,27 @@ </xsl:choose> </xsl:template> + <!-- template to trim trailing and starting newlines --> + <xsl:template name="trim-newln"> + <xsl:param name="txt" /> + <xsl:choose> + <!-- find starting newlines --> + <xsl:when test="substring($txt,1,1) = '
'"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="substring($txt,2)" /> + </xsl:call-template> + </xsl:when> + <!-- find trailing newlines --> + <xsl:when test="substring($txt,string-length($txt),1) = '
'"> + <xsl:call-template name="trim-newln"> + <xsl:with-param name="txt" select="substring($txt,1,string-length($txt)-1)" /> + </xsl:call-template> + </xsl:when> + <!-- no newlines found, we're done --> + <xsl:otherwise> + <xsl:value-of select="$txt" /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + </xsl:stylesheet> diff --git a/src/core/src/runscript.c b/src/core/src/runscript.c index 0c633e7..e80774f 100644 --- a/src/core/src/runscript.c +++ b/src/core/src/runscript.c @@ -23,11 +23,14 @@ static void (*selinux_run_init_old) (void); static void (*selinux_run_init_new) (int argc, char **argv); +#if defined(WANT_SELINUX) void setup_selinux (int argc, char **argv); +#endif char ** filter_environ (char *caller); extern char **environ; +#if defined(WANT_SELINUX) void setup_selinux (int argc, char **argv) { @@ -52,6 +55,7 @@ setup_selinux (int argc, char **argv) } } } +#endif char ** filter_environ (char *caller) @@ -184,8 +188,10 @@ main (int argc, char *argv[]) myenv = environ; } +#if defined(WANT_SELINUX) /* Ok, we are ready to go, so setup selinux if applicable */ setup_selinux (argc, argv); +#endif if (!IS_SBIN_RC ()) { |