summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/8021x36
-rw-r--r--src/connections/wireless55
2 files changed, 52 insertions, 39 deletions
diff --git a/src/8021x b/src/8021x
index 27e674d..6184da3 100644
--- a/src/8021x
+++ b/src/8021x
@@ -47,9 +47,10 @@ stop_wpa()
fi
}
-# $1 is interface
-make_wpa_config() {
- local WPA_CONF="${TMPDIR:-/tmp}/wpa.${INTERFACE}" # substitute spaces out
+# Requires already loaded profile
+make_wpa_config_file() {
+ local interface=$1
+ local WPA_CONF="${TMPDIR:-/tmp}/wpa.${interface}" # substitute spaces out
# make empty tmp dir with correct permissions, rename it
rm -rf "$WPA_CONF"
@@ -60,5 +61,34 @@ make_wpa_config() {
echo "$WPA_CONF/wpa.conf"
}
+# Requires already loaded profile
+make_wpa_config() {
+ case $SECURITY in
+ wep)
+ if [[ ${KEY:0:2} == "s:" ]]; then # TODO: does wpa_supplicant handle this as expected?
+ echo "ssid=\"$ESSID\" \nkey_mgmt=NONE \nwep_key0=\"${KEY:2}\" \nwep_tx_keyidx=0"
+ else
+ echo "ssid=\"$ESSID\" \nkey_mgmt=NONE \nwep_key0=$KEY \nwep_tx_keyidx=0"
+ fi
+ ;;
+ none)
+ echo "ssid=\"$ESSID\" \nkey_mgmt=NONE"
+ ;;
+ wpa)
+ if [[ "${#KEY}" -eq 64 ]]; then
+ echo "ssid=\"$ESSID\" \npsk=$KEY"
+ else
+ echo "ssid=\"$ESSID\" \npsk=\"$KEY\""
+ fi
+ ;;
+ wpa-configsection)
+ echo "$CONFIGSECTION"
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
# vim: ft=sh ts=4 et sw=4:
diff --git a/src/connections/wireless b/src/connections/wireless
index 6de7379..6c51068 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -27,15 +27,15 @@ iwconfig_up() {
quirk prescan && iwlist "$INTERFACE" scan &> /dev/null # bcm43xx
# 'none' uses iwconfig like wep. Use sane default if WEP_OPTS=""
- if [[ -z "$WEP_OPTS" ]]; then
- if [[ "$SECURITY" = "wep" ]]; then
+ if [[ -z $WEP_OPTS ]]; then
+ if [[ "$SECURITY" = "wep-old" ]]; then
if [[ -n "$AP" ]]; then
WEP_OPTS="ap \"$AP\" key $KEY"
else
WEP_OPTS="essid \"$ESSID\" key $KEY"
fi
- elif [[ "$SECURITY" = "none" ]]; then
- if [[ -n "$AP" ]]; then
+ elif [[ "$SECURITY" = "none-old" ]]; then
+ if [[ -n $AP ]]; then
WEP_OPTS="ap \"$AP\""
else
WEP_OPTS="essid \"$ESSID\""
@@ -47,7 +47,7 @@ iwconfig_up() {
report_debug wireless_up iwconfig "$INTERFACE" $WEP_OPTS
- if ! iwconfig "$INTERFACE" "$WEP_OPTS"; then
+ if ! iwconfig "$INTERFACE" $WEP_OPTS; then
report_fail "Could not set wireless configuration."
return 1
fi
@@ -109,37 +109,20 @@ wireless_up() {
[[ -z "$SECURITY" ]] && SECURITY="none"
case "$SECURITY" in
- *-old)
- report_debug "Using older iwconfig based path"
- iwconfig_up || return 1
- ;;
- wep)
- WPA_CONF="$(make_wpa_config $INTERFACE)"
- 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 $INTERFACE)"
- echo -e "network={ \nssid=\"$ESSID\" \nkey_mgmt=NONE \n}" >> "$WPA_CONF"
- ;;
- wpa)
- WPA_CONF="$(make_wpa_config $INTERFACE)"
- if [[ "${#KEY}" -eq 64 ]]; then
- echo -e "network={ \nssid=\"$ESSID\" \npsk=$KEY \n}" >> "$WPA_CONF"
- else
- echo -e "network={ \nssid=\"$ESSID\" \npsk=\"$KEY\"\n}" >> "$WPA_CONF"
- fi
- ;;
- wpa-config)
- [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
- ;;
- wpa-configsection)
- WPA_CONF="$(make_wpa_config $INTERFACE)"
- echo -e "network={ \n$CONFIGSECTION \n}">> "$WPA_CONF"
- ;;
+ *-old)
+ report_debug "Using older iwconfig based path"
+ iwconfig_up || return 1
+ ;;
+ wpa-config)
+ [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
+ ;;
+ none|wep|wpa|wpa-configsection)
+ WPA_CONF="$(make_wpa_config_file $INTERFACE)"
+ echo -e "network={ \n$(make_wpa_config) \n}">> "$WPA_CONF"
+ ;;
+ *)
+ report_fail "Invalid SECURITY setting: $SECURITY"
+ ;;
esac
if [[ ${SECURITY:(-4)} != "-old" ]]; then