diff options
Diffstat (limited to 'net-scripts')
-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 |
3 files changed, 73 insertions, 53 deletions
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 } |