diff options
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | ChangeLog.vserver | 7 | ||||
-rwxr-xr-x | net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper | 2 | ||||
-rw-r--r-- | net-scripts/net.modules.d/iwconfig | 1 | ||||
-rw-r--r-- | net-scripts/net.modules.d/wpa_supplicant | 123 | ||||
-rwxr-xr-x | sbin/MAKEDEV | 1 | ||||
-rwxr-xr-x | sbin/functions.sh | 8 | ||||
-rwxr-xr-x | sbin/rc-daemon.sh | 17 | ||||
-rwxr-xr-x | sbin/rc-services.sh | 13 |
9 files changed, 141 insertions, 57 deletions
@@ -1,6 +1,32 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2 + 19 Oct 2005; Roy Marples <uberlord@gentoo.org>: + + rc-daemon.sh now kills children correctly. + + 18 Oct 2005; Mike Frysinger <vapier@gentoo.org>: + + Touchup the devfsd init code to be a bit more resilient. + + Cache get_KV() so we don't keep calling `uname -r`. + + 18 Oct 2005; Roy Marples <uberlord@gentoo.org>: + + You can now specify a custom wpa_supplicant configuration file. + wpa_supplicant now works on more than one interface. + + 17 Oct 2005; Roy Marples <uberlord@gentoo.org>: + + wpa_supplicant now works on wired interfaces, and can work with + ifplugd and netplug too. + + 16 Oct 2005; Roy Marples <uberlord@gentoo.org>: + + Fixed typo in dhcpcd-wrapper so the new resolv.conf gets created + in /var/lib/net-scripts and not the current directory. Thanks to + Mark-Dominik Bürkle for the patch. + 13 Oct 2005; Roy Marples <uberlord@gentoo.org>: Fix test_service_state() so it always returns 1 when it's not in that diff --git a/ChangeLog.vserver b/ChangeLog.vserver index 8cbe36d..67a132b 100644 --- a/ChangeLog.vserver +++ b/ChangeLog.vserver @@ -1,6 +1,13 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2 + 20 Oct 2005; Christian Heim <phreak@gentoo.org> ChangeLog, ChangeLog.vserver, + net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper, + net-scripts/net.modules.d/iwconfig, + net-scripts/net.modules.d/wpa_supplicant, + sbin/MAKEDEV, sbin/functions.sh, sbin/rc-daemon.sh, sbin/rc-services.sh: + Merging changes from baselayout 1583 + 16 Oct 2005; Christian Heim <phreak@gentoo.org> ChangeLog, ChangeLog.vserver, etc/group, etc/passwd, sbin/rc-services.sh: Merging changes from baselayout revision 1572 diff --git a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper index 6568d10..29710e3 100755 --- a/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper +++ b/net-scripts/net.modules.d/helpers.d/dhcpcd-wrapper @@ -37,7 +37,7 @@ if [[ ${action} == "up" ]]; then if [[ ${d} != *" nodns "* ]]; then eval search=\"\$\{dns_search_${ifvar}\}\" if [[ -n ${search} ]]; then - tmp="${revolv}.$$" + tmp="${resolv}.$$" egrep -v "^[ \t]*(search|domain)[ \t]*" "${resolv}" > "${tmp}" echo "search ${search}" >> "${tmp}" mv "${tmp}" "${resolv}" diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig index fbe6432..04055eb 100644 --- a/net-scripts/net.modules.d/iwconfig +++ b/net-scripts/net.modules.d/iwconfig @@ -25,6 +25,7 @@ iwpriv() { # # Sets up the dependancies for the module iwconfig_depend() { + after plug before interface } diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index acedeab..c03774d 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -25,7 +25,7 @@ wpa_supplicant_provides() { # # Sets up the dependancies for the module wpa_supplicant_depend() { - after macnet + after macnet plug before interface } @@ -38,13 +38,6 @@ wpa_supplicant_check_installed() { installed="1" ${report} && eerror "For WPA support (wpa_supplicant) support, emerge net-wireless/wpa_supplicant" fi - if [[ ! -e /proc/net/wireless ]]; then - installed="1" - if ${report} ; then - eerror "wpa_supplicant requires wireless support" - eerror "(CONFIG_NET_WIRELESS=y) enabled in the kernel" - fi - fi if [[ ! -e /proc/net/packet ]]; then installed="1" if ${report} ; then @@ -109,14 +102,13 @@ wpa_supplicant_get_ap_mac_address() { # Returns 0 if we're associated correctly or 1 if not # Note that just because we are associated does not mean we are using the # correct encryption keys -# We only need this for wpa_supplicant-0.3.x wpa_supplicant_associated() { local -a status=( "$( wpa_cli -i"$1" status | sed -n -e 's/^\(key_mgmt\|wpa_state\|EAP state\)=\([^=]\+\).*/\U\2/p' )" ) case "${status[0]}" in - "NONE") [[ ${status[1]} == "ASSOCIATED" ]] ;; + "NONE") [[ ${status[1]} == "ASSOCIATED" ]] ;; "IEEE 802.1X (no WPA)") [[ ${status[2]} == "SUCCESS" ]] ;; - *) [[ ${status[1]} == "COMPLETED" ]] ;; + *) [[ ${status[1]} == "COMPLETED" ]] ;; esac return $? @@ -134,8 +126,7 @@ wpa_supplicant_kill() { pidfile="/var/run/wpa_cli-${iface}.pid" if ! clean_pidfile "${pidfile}" ; then ${report} && ebegin "Stopping wpa_cli on ${iface}" - start-stop-daemon --stop --exec /bin/wpa_cli \ - --pidfile "${pidfile}" + start-stop-daemon --stop --exec /bin/wpa_cli --pidfile "${pidfile}" ${report} && eend "$?" fi @@ -144,7 +135,7 @@ wpa_supplicant_kill() { if ! clean_pidfile "${pidfile}" ; then ${report} && ebegin "Stopping wpa_supplicant on ${iface}" start-stop-daemon --stop --exec /sbin/wpa_supplicant \ - --pidfile "${pidfile}" + --pidfile "${pidfile}" ${report} && eend "$?" else # Support wpa_supplicant-0.3.x @@ -158,7 +149,7 @@ wpa_supplicant_kill() { # If wpa_supplicant exits uncleanly, we need to remove the stale dir [[ -S "/var/run/wpa_supplicant/${iface}" ]] \ - && rm -f "/var/run/wpa_supplicant/${iface}" + && rm -f "/var/run/wpa_supplicant/${iface}" } # bool wpa_supplicant_associate(char *interface) @@ -215,29 +206,40 @@ 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 - local cfgfile="/etc/wpa_supplicant.conf" + local iface="$1" opts timeout action=false cfgfile local actfile="/sbin/wpa_cli.action" # We don't configure wireless if we're being called from - # the background + # the background unless we're not currently running if ${IN_BACKGROUND} ; then - ESSID=$( wpa_supplicant_get_essid "${iface}" ) - ESSIDVAR=$( bash_variable "${ESSID}" ) - save_options "ESSID" "${ESSID}" - return 0 + if service_started_daemon "net.${iface}" /sbin/wpa_supplicant ; then + if wpa_supplicant_check_extensions "${iface}" ; then + ESSID=$( wpa_supplicant_get_essid "${iface}" ) + ESSIDVAR=$( bash_variable "${ESSID}" ) + save_options "ESSID" "${ESSID}" + fi + return 0 + fi fi save_options "ESSID" "" - # We only work on wirelesss interfaces - wpa_supplicant_check_extensions "${iface}" || return 0 - - # Kill off any existing wpa_supplicant on this interface - # This is so we can re-read the configuration file and clean any stale - # directories - wpa_supplicant_kill "${iface}" true + local ifvar=$( bash_variable "${iface}" ) + eval opts=\" \$\{wpa_supplicant_${ifvar}\} \" + + # We only work on wirelesss interfaces unless a driver for wired + # has been defined + if [[ ${opts} != *" -Dwired "* && ${opts} != *" -D wired "* ]]; then + if ! wpa_supplicant_check_extensions "${iface}" ; then + veinfo "wpa_supplicant only works on wireless interfaces" + veinfo "unless the -D wired option is specified" + return 0 + fi + fi + [[ ${opts} != *" -D"* ]] \ + && ewarn "wpa_supplicant_${ifvar} does not define a driver" + # Check for rf_kill - only ipw supports this at present, but other # cards may in the future if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]]; then @@ -251,12 +253,23 @@ wpa_supplicant_pre_start() { # This is needed for some drivers - such as hostap because they start # the card in Master mode which causes problems with wpa_supplicant. if [[ $( type -t iwconfig_defaults ) == "function" ]]; then - iwconfig_defaults "${iface}" - iwconfig_user_config "${iface}" + if wpa_supplicant_check_extensions "${iface}" ; then + iwconfig_defaults "${iface}" + iwconfig_user_config "${iface}" + fi fi ebegin "Starting wpa_supplicant on ${iface}" + cfgfile="${opts##* -c}" + if [[ -n ${cfgfile} && ${cfgfile} != "${opts}" ]]; then + [[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}" + cfgfile="${cfgfile%% *}" + else + cfgfile="/etc/wpa_supplicant.conf" + opts="${opts} -c/etc/wpa_supplicant.conf" + fi + if [[ ! -f ${cfgfile} ]]; then eend 1 "configuration file ${cfgfile} not found!" return 1 @@ -270,11 +283,6 @@ wpa_supplicant_pre_start() { return 1 fi - local ifvar=$( bash_variable "${iface}" ) - eval opts=\" \$\{wpa_supplicant_${ifvar}\}\" - [[ ${opts} != *" -D"* ]] \ - && ewarn "wpa_supplicant_${ifvar} does not define a driver" - # Some drivers require the interface to be up interface_up "${iface}" @@ -295,7 +303,8 @@ wpa_supplicant_pre_start() { fi start-stop-daemon --start --exec /sbin/wpa_supplicant \ - -- ${opts} -B -c/etc/wpa_supplicant.conf -i"${iface}" + --pidfile "/var/run/wpa_supplicant-${iface}.pid" \ + -- ${opts} -B -i"${iface}" eend "$?" || return 1 # Starting wpa_supplication-0.4.0, we can get wpa_cli to @@ -304,8 +313,9 @@ wpa_supplicant_pre_start() { mark_service_inactive "net.${iface}" ebegin "Starting wpa_cli on ${iface}" start-stop-daemon --start --exec /bin/wpa_cli \ - -- -a"${actfile}" -i"${iface}" \ - -P"/var/run/wpa_cli-${iface}.pid" -B + --pidfile "/var/run/wpa_cli-${iface}.pid" \ + -- -a"${actfile}" -i"${iface}" \ + -P"/var/run/wpa_cli-${iface}.pid" -B eend "$?" || return 1 fi @@ -325,24 +335,29 @@ wpa_supplicant_pre_start() { wpa_supplicant_associate "${iface}" || return 1 - # Set ESSID for essidnet and report - ESSID=$( wpa_supplicant_get_essid "${iface}" ) - ESSIDVAR=$( bash_variable "${ESSID}" ) - save_options "ESSID" "${ESSID}" + # Only report wireless info for wireless interfaces + if wpa_supplicant_check_extensions "${iface}" ; then + # Set ESSID for essidnet and report + ESSID=$( wpa_supplicant_get_essid "${iface}" ) + 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:]' )" ) - einfo "${iface} connected to \"${ESSID//\\\\/\\\\}\" at ${status[0]}" + 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 - if [[ ${status[1]} == "NONE" ]]; then - ewarn "not using any encryption" + if [[ ${status[2]} == "NONE" ]]; then + if [[ ${status[1]} == "NONE" ]]; then + ewarn "not using any encryption" + else + veinfo "using ${status[1]}" + fi else - veinfo "using ${status[1]}" + veinfo "using ${status[2]}/${status[1]}" fi + eoutdent else - veinfo "using ${status[2]}/${status[1]}" + einfo "${iface} connected" fi - eoutdent if ${action} ; then local addr=$( interface_get_address "${iface}" ) @@ -358,7 +373,11 @@ wpa_supplicant_pre_start() { # Stops wpa_supplicant on an interface # Returns 0 (true) when successful, non-zero otherwise wpa_supplicant_post_stop() { - ! ${IN_BACKGROUND} && wpa_supplicant_kill "$1" true + if ${IN_BACKGROUND} ; then + # Only stop wpa_supplicant if it's not the controlling daemon + ! service_started_daemon "net.$1" /sbin/wpa_supplicant 0 + fi + [[ $? == 0 ]] && wpa_supplicant_kill "$1" true return 0 } diff --git a/sbin/MAKEDEV b/sbin/MAKEDEV index dfcae19..4a28ad3 100755 --- a/sbin/MAKEDEV +++ b/sbin/MAKEDEV @@ -309,7 +309,6 @@ cvt () { } get_arch() { - local a=`uname -m` case `uname -m` in arm*) echo arm;; i?86) echo i386;; diff --git a/sbin/functions.sh b/sbin/functions.sh index d5cbf22..e301d67 100755 --- a/sbin/functions.sh +++ b/sbin/functions.sh @@ -401,10 +401,12 @@ KV_to_int() { # portion of Z is a number. # e.g. 2.4.25, 2.6.10, 2.6.4-rc3, 2.2.40-poop, 2.0.15+foo # +_RC_GET_KV_CACHE="" get_KV() { - local KV=$(uname -r) + [[ -z ${_RC_GET_KV_CACHE} ]] \ + && _RC_GET_KV_CACHE=$(uname -r) - echo "$(KV_to_int "${KV}")" + echo $(KV_to_int "${_RC_GET_KV_CACHE}") return $? } @@ -733,9 +735,9 @@ else GOOD=$'\e[32;01m' WARN=$'\e[33;01m' BAD=$'\e[31;01m' - NORMAL=$'\e[0m' HILITE=$'\e[36;01m' BRACKET=$'\e[34;01m' + NORMAL=$'\e[0m' fi ############################################################################## diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh index b59eb66..8ef6bc6 100755 --- a/sbin/rc-daemon.sh +++ b/sbin/rc-daemon.sh @@ -281,6 +281,23 @@ rc_stop_daemon() { pids=${pid} fi + # If there's nothing to kill then return without error + [[ -z ${pids} ]] && return 0 + + # We may not have pgrep to find our children, so we provide + # two methods + if [[ ${RC_KILL_CHILDREN} == "yes" ]]; then + if [[ -x /usr/bin/pgrep ]]; then + pids="${pids} $(pgrep -P ${pids// /,})" + else + local npids + for pid in ${pids} ; do + npids="${npids} $(ps -eo pid,ppid | sed -n 's/'${pid}'$//p')" + done + pids="${pids} ${npids}" + fi + fi + for pid in ${pids}; do if [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]]; then ps -p "${pid}" &>/dev/null || return 1 diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh index e828863..d629dd4 100755 --- a/sbin/rc-services.sh +++ b/sbin/rc-services.sh @@ -597,6 +597,19 @@ service_failed() { [[ -n $1 && -L ${svcdir}/failed/$1 ]] } +# bool service_started_daemon(char *interface, char *daemon, int index) +# Returns 0 if the service started the given daemon +# via start-stop-daemon, otherwise 1. +# If index is emtpy, then we don't care what the first daemon launched +# was, otherwise the daemon must also be at that index +service_started_daemon() { + local service="$1" daemon="$2" index="${3:-[0-9]*}" + local daemonfile="${svcdir}/daemons/${service}" + + [[ ! -e ${daemonfile} ]] && return 1 + grep -q '^RC_DAEMONS\['"${index}"'\]="'${daemon}'"$' "${daemonfile}" +} + # bool net_service(service) # # Returns true if 'service' is a service controlling a network interface |