From df2c2b5c04393ed72c2798407f50f99a6298b673 Mon Sep 17 00:00:00 2001 From: James Rayner Date: Sun, 27 Sep 2009 23:45:41 +1000 Subject: Rename autowifi->wpa_actiond, add makefile, bugfix --- Makefile | 1 + autowifi/autowifi-netcfg | 54 ----------------------------------- autowifi/autowifi-netcfg-action | 54 ----------------------------------- src/8021x | 4 +-- wpa_actiond/netcfg-wpa_actiond | 54 +++++++++++++++++++++++++++++++++++ wpa_actiond/netcfg-wpa_actiond-action | 54 +++++++++++++++++++++++++++++++++++ 6 files changed, 111 insertions(+), 110 deletions(-) delete mode 100755 autowifi/autowifi-netcfg delete mode 100755 autowifi/autowifi-netcfg-action create mode 100755 wpa_actiond/netcfg-wpa_actiond create mode 100755 wpa_actiond/netcfg-wpa_actiond-action diff --git a/Makefile b/Makefile index d350c89..ab6bfbd 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ install: # 'Binaries' install -m755 src/netcfg $(DESTDIR)/usr/bin/netcfg2 install -m755 src/netcfg-menu $(DESTDIR)/usr/bin/netcfg-menu + install -m755 wpa_actiond/netcfg-wpa_actiond{,-action} $(DESTDIR)/usr/bin # Daemons install -m755 src/net-profiles src/net-rename $(DESTDIR)/etc/rc.d diff --git a/autowifi/autowifi-netcfg b/autowifi/autowifi-netcfg deleted file mode 100755 index f2dc266..0000000 --- a/autowifi/autowifi-netcfg +++ /dev/null @@ -1,54 +0,0 @@ - -. /usr/lib/network/network -. /usr/lib/network/8021x -. /usr/lib/network/wireless - -interface=$1; shift - -AUTOWIFI="/usr/sbin/autowifi" -ACTION_SCRIPT="/usr/bin/autowifi-netcfg-action" -PIDFILE="/var/run/wpa_supplicant_${interface}.pid" -EXTRA_AUTOWIFI_OPTIONS="$*" - -if [[ -z $interface ]]; then - echo "No interface specified" - exit 1 -fi - -# Load interface specific config -[[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface" - -if [[ -n "$RFKILL" ]]; then # Enable radio if necessary - set_rf_state "$interface" up || exit $? -fi - -WPA_CONF="$(make_wpa_config_file $interface)" - -for profile in $(list_profiles); do - echo $profile - ( - load_profile $profile - - [[ $CONNECTION != "wireless" ]] && exit 1 - [[ $INTERFACE != $interface ]] && exit 1 - - config=$(make_wpa_config) - - echo -e "network={ \n$config \nid_str=\"$profile\" \n}" >> $WPA_CONF - ) -done - - -[[ -z $WPA_DRIVER ]] && WPA_DRIVER="wext" - -# Kill any existing wpa_supplicant on this interface -stop_wpa "$interface" - -if start_wpa $interface $WPA_CONF $WPA_DRIVER $WPA_OPTS; then - if $AUTOWIFI -i ${interface} -P {PIDFILE} -a ${ACTION_SCRIPT} ${EXTRA_AUTOWIFI_OPTIONS}; then - exit 0 - fi -fi - -exit 1 - diff --git a/autowifi/autowifi-netcfg-action b/autowifi/autowifi-netcfg-action deleted file mode 100755 index f273b3b..0000000 --- a/autowifi/autowifi-netcfg-action +++ /dev/null @@ -1,54 +0,0 @@ -#! /bin/bash - -interface=$1 -ssid=$2 -profile=$3 -action=$4 - -. /usr/lib/network/network -[[ $profile ]] && load_profile "$profile" - -case $action in - CONNECT) - if [[ -z $profile ]]; then - dhcpcd $interface - exit $? - fi - if ! $CONN_DIR/ethernet up "$profile"; then - exit 1 # what to do if fail? - fi - - set_profile up "$profile" - - if ! ( eval $POST_UP ); then # JP: sandbox the eval - # failing POST_UP will take interface down - "$CONN_DIR/$ethernet" down "$profile" - exit 1 - fi - ;; - DISCONNECT) - if [[ -z $profile ]]; then - dhcpcd -k $interface - exit $? - fi - if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval - exit 1 - fi - if ! "$CONN_DIR/ethernet" down "$profile"; then - exit 1 - fi - if ! ( eval $POST_DOWN ); then # JP: sandbox the eval - exit 1 - fi - set_profile down "$profile" - ;; - LOST|REESTABLISHED) - # Not handled. - exit 0 - ;; - *) - # ??? - exit 1 - ;; -esac - diff --git a/src/8021x b/src/8021x index 6184da3..ce4fbf2 100644 --- a/src/8021x +++ b/src/8021x @@ -64,14 +64,14 @@ make_wpa_config_file() { # Requires already loaded profile make_wpa_config() { case $SECURITY in - wep) + wep|wep-old) 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) + none|none-old) echo "ssid=\"$ESSID\" \nkey_mgmt=NONE" ;; wpa) diff --git a/wpa_actiond/netcfg-wpa_actiond b/wpa_actiond/netcfg-wpa_actiond new file mode 100755 index 0000000..02901c6 --- /dev/null +++ b/wpa_actiond/netcfg-wpa_actiond @@ -0,0 +1,54 @@ + +. /usr/lib/network/network +. /usr/lib/network/8021x +. /usr/lib/network/wireless + +interface=$1; shift + +AUTOWIFI="/usr/sbin/wpa_actiond" +ACTION_SCRIPT="/usr/bin/netcfg-wpa_actiond-action" +PIDFILE="/var/run/wpa_supplicant_${interface}.pid" +EXTRA_AUTOWIFI_OPTIONS="$*" + +if [[ -z $interface ]]; then + echo "No interface specified" + exit 1 +fi + +# Load interface specific config +[[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface" + +if [[ -n "$RFKILL" ]]; then # Enable radio if necessary + set_rf_state "$interface" up || exit $? +fi + +WPA_CONF="$(make_wpa_config_file $interface)" + +for profile in $(list_profiles); do + echo $profile + ( + load_profile $profile + + [[ $CONNECTION != "wireless" ]] && exit 1 + [[ $INTERFACE != $interface ]] && exit 1 + + config=$(make_wpa_config) + + echo -e "network={ \n$config \nid_str=\"$profile\" \n}" >> $WPA_CONF + ) +done + + +[[ -z $WPA_DRIVER ]] && WPA_DRIVER="wext" + +# Kill any existing wpa_supplicant on this interface +stop_wpa "$interface" + +if start_wpa $interface $WPA_CONF $WPA_DRIVER $WPA_OPTS; then + if $AUTOWIFI -i ${interface} -P {PIDFILE} -a ${ACTION_SCRIPT} ${EXTRA_AUTOWIFI_OPTIONS}; then + exit 0 + fi +fi + +exit 1 + diff --git a/wpa_actiond/netcfg-wpa_actiond-action b/wpa_actiond/netcfg-wpa_actiond-action new file mode 100755 index 0000000..f273b3b --- /dev/null +++ b/wpa_actiond/netcfg-wpa_actiond-action @@ -0,0 +1,54 @@ +#! /bin/bash + +interface=$1 +ssid=$2 +profile=$3 +action=$4 + +. /usr/lib/network/network +[[ $profile ]] && load_profile "$profile" + +case $action in + CONNECT) + if [[ -z $profile ]]; then + dhcpcd $interface + exit $? + fi + if ! $CONN_DIR/ethernet up "$profile"; then + exit 1 # what to do if fail? + fi + + set_profile up "$profile" + + if ! ( eval $POST_UP ); then # JP: sandbox the eval + # failing POST_UP will take interface down + "$CONN_DIR/$ethernet" down "$profile" + exit 1 + fi + ;; + DISCONNECT) + if [[ -z $profile ]]; then + dhcpcd -k $interface + exit $? + fi + if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval + exit 1 + fi + if ! "$CONN_DIR/ethernet" down "$profile"; then + exit 1 + fi + if ! ( eval $POST_DOWN ); then # JP: sandbox the eval + exit 1 + fi + set_profile down "$profile" + ;; + LOST|REESTABLISHED) + # Not handled. + exit 0 + ;; + *) + # ??? + exit 1 + ;; +esac + -- cgit v1.2.3-24-g4f1b