summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-09-23 15:55:04 +0200
committerJames Rayner <james@archlinux.org>2009-09-23 15:55:04 +0200
commit4d80e053525f937b3eb76d9d2072895a826f53d6 (patch)
tree78351a487ca7d1411d3bfecc707dc344e7244bff /src
parent0bba84008f180097acf979cc2e87533c6e0bf2bd (diff)
downloadnetctl-4d80e053525f937b3eb76d9d2072895a826f53d6.tar.gz
netctl-4d80e053525f937b3eb76d9d2072895a826f53d6.tar.xz
Add WPA_DRIVER, WPA_COUNTRY and handle WEP string keys
WPA_DRVER: Configure the -D argument to wpa_supplicant, for example -Dnl80211 WPA_COUNTRY: Set the 'country=' variable in the wpa_supplicant configuration. WEP string keys: modified such that they may work. Not tested yet.
Diffstat (limited to 'src')
-rw-r--r--src/8021x11
-rw-r--r--src/connections/ethernet6
-rw-r--r--src/connections/wireless16
3 files changed, 19 insertions, 14 deletions
diff --git a/src/8021x b/src/8021x
index f18b83f..704b023 100644
--- a/src/8021x
+++ b/src/8021x
@@ -25,11 +25,11 @@ wpa_check()
start_wpa()
{
- local INTERFACE="$1" WPA_CONF="$2"
- shift 2
+ local INTERFACE="$1" WPA_CONF="$2" WPA_DRIVER="$3"
+ shift 3
local WPA_OPTS="$*"
- wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -c "$WPA_CONF" $WPA_OPTS
+ wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -D "$WPA_DRIVER" -c "$WPA_CONF" $WPA_OPTS
sleep 1
if [[ ! -f "/var/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
@@ -48,15 +48,16 @@ stop_wpa()
}
# $1 is profile
-make_wpa_config() {
+make_wpa_config() {
local WPA_CONF="${TMPDIR:-/tmp}/wpa.${1// /}" # substitute spaces out
+
# make empty tmp dir with correct permissions, rename it
rm -rf "$WPA_CONF"
mv -f "$(mktemp -d)" "$WPA_CONF" || return 1
echo "ctrl_interface=/var/run/wpa_supplicant" >> "$WPA_CONF/wpa.conf" # we know $WPA_CONF now has no spaces, but it may have other nasty chars, so still needs to be quoted
echo "ctrl_interface_group=${WPA_GROUP:-wheel}" >> "$WPA_CONF/wpa.conf"
+ [[ $WPA_COUNTRY ]] && echo "country=$WPA_COUNTRY" >> "$WPA_CONF/wpa.conf"
echo "$WPA_CONF/wpa.conf"
}
# vim: ft=sh ts=4 et sw=4:
-
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 1775247..20ee545 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -31,10 +31,10 @@ ethernet_up() {
if checkyesno "${AUTH8021X:-no}"; then
. "$SUBR_DIR/8021x"
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
- [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired"
+ [[ -z "$WPA_DRIVER" ]] && WPA_DRIVER="wired"
- report_debug ethernet_iproute_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
- if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"; then
+ report_debug ethernet_iproute_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"
+ if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi
diff --git a/src/connections/wireless b/src/connections/wireless
index 6e99952..413c5db 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -115,7 +115,11 @@ wireless_up() {
;;
wep)
WPA_CONF="$(make_wpa_config $1)"
- echo -e "network={ \nssid=\"$ESSID\" \nkey_mgmt=NONE \nwep_key0=\"$KEY\" \nwep_tx_keyidx=0 \n}" >> "$WPA_CONF"
+ if [[ ${KEY:0:2} == "s:" ]]; then # TODO: does wpa_supplicant handle this as expected?
+ echo -e "network={ \nssid=\"$ESSID\" \nkey_mgmt=NONE \nwep_key0=\"${KEY:2}\" \nwep_tx_keyidx=0 \n}" >> "$WPA_CONF"
+ else
+ echo -e "network={ \nssid=\"$ESSID\" \nkey_mgmt=NONE \nwep_key0=$KEY \nwep_tx_keyidx=0 \n}" >> "$WPA_CONF"
+ fi
;;
none)
WPA_CONF="$(make_wpa_config $1)"
@@ -151,15 +155,15 @@ wireless_up() {
;;
wpa-configsection)
. "$SUBR_DIR/8021x"
- WPA_CONF="$(make_wpa_config $1)"
- echo -e "$CONFIGSECTION" >> "$WPA_CONF"
+ WPA_CONF="$(make_wpa_config $1)"
+ echo -e "network={ \n$CONFIGSECTION \n}">> "$WPA_CONF"
;;
esac
if [[ ${SECURITY:(-4)} != "-old" ]]; then
- [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
- report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
- if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"; then
+ [[ -z "$WPA_DRIVER" ]] && WPA_DRIVER="wext"
+ report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"
+ if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_DRIVER" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi