[arch-projects] [netctl][PATCH] Move away from using wpa_actiond
Jouke Witteveen
j.witteveen at gmail.com
Thu Feb 7 14:49:45 UTC 2019
The same functionality is provided by wpa_supplicant, so we do not need
an extra and Arch Linux specific dependency.
---
README | 4 ++--
contrib/PKGBUILD.in | 1 -
src/lib/auto.action | 31 ++++++++++++++-----------------
src/netctl-auto | 30 +++++++++++++-----------------
4 files changed, 29 insertions(+), 37 deletions(-)
diff --git a/README b/README
index 95df087..f3ca634 100644
--- a/README
+++ b/README
@@ -9,8 +9,8 @@ Optional:
- dhcpcd or dhclient: for DHCP support
- wpa_supplicant: for WPA support
- dialog: for the interactive assistant
-- ifplugd: for automatic connection
-- wpa_actiond: for automatic connection
+- ifplugd: for automatic wired connections
+- ppp: for PPP support
For documentation generation:
- asciidoc
diff --git a/contrib/PKGBUILD.in b/contrib/PKGBUILD.in
index b5ce44c..f3359c6 100644
--- a/contrib/PKGBUILD.in
+++ b/contrib/PKGBUILD.in
@@ -15,7 +15,6 @@ optdepends=('dialog: for the menu based wifi assistant'
'dhcpcd: for DHCP support (or dhclient)'
'wpa_supplicant: for wireless networking support'
'ifplugd: for automatic wired connections through netctl-ifplugd'
- 'wpa_actiond: for automatic wireless connections through netctl-auto'
'ppp: for PPP connections'
'openvswitch: for Open vSwitch connections'
)
diff --git a/src/lib/auto.action b/src/lib/auto.action
index f81d4e3..999f66f 100755
--- a/src/lib/auto.action
+++ b/src/lib/auto.action
@@ -5,16 +5,17 @@
. "$SUBR_DIR/ip"
export INTERFACE="$1"
-export SSID="$2"
-export ACTION="$4"
+export ACTION="$2"
+PROFILE_STATE="$STATE_DIR/netctl-auto-$INTERFACE.profile"
-load_profile "$3"
load_interface_config "$INTERFACE"
case $ACTION in
- CONNECT)
+ CONNECTED)
+ load_profile "$WPA_ID_STR"
DhcpcdOptions+=" -K -L"
ip_set || exit 1
+ echo "$Profile" > "$PROFILE_STATE"
# Sandbox the eval
if ! ( do_debug eval "$ExecUpPost" ); then
# Failing ExecUpPost will take the connection down
@@ -22,20 +23,16 @@ case $ACTION in
exit 1
fi
;;
- DISCONNECT)
- # Sandbox the eval
- if ! ( do_debug eval "$ExecDownPre" ); then
- exit 1
+ DISCONNECTED)
+ if [[ -s "$PROFILE_STATE" ]]; then
+ load_profile "$(< "$PROFILE_STATE")"
+ rm -f "$PROFILE_STATE"
+ # Sandbox the eval
+ if ! ( do_debug eval "$ExecDownPre" ); then
+ exit 1
+ fi
+ ip_unset
fi
- ip_unset
- ;;
- LOST|REESTABLISHED)
- # Not handled.
- exit 0
- ;;
- *)
- # ???
- exit 1
;;
esac
diff --git a/src/netctl-auto b/src/netctl-auto
index 18d2e10..7e4062e 100755
--- a/src/netctl-auto
+++ b/src/netctl-auto
@@ -6,7 +6,6 @@
. "$SUBR_DIR/rfkill"
. "$SUBR_DIR/wpa"
-: ${ACTIOND:=wpa_actiond -p /run/wpa_supplicant}
: ${ACTION_SCRIPT:=$SUBR_DIR/auto.action}
@@ -193,11 +192,10 @@ list() {
done
}
-## Start and generate config file for the WPA supplicant, start wpa_actiond
+## Start and generate config file for the WPA supplicant, monitor for changes
# $1: interface
start() {
local interface="$1"
- local pidfile="$STATE_DIR/wpa_actiond-$interface.pid"
if interface_is_up "$interface"; then
exit_error "The interface '$interface' is already up"
@@ -206,12 +204,11 @@ start() {
rf_enable "$interface" "$RFKill" || return 1
fi
- local wpa_conf
- if ! wpa_conf=$(wpa_make_config_file "$interface"); then
+ if ! WPAConfigFile=$(wpa_make_config_file "$interface"); then
exit_error "Could not create the configuration file for interface '$interface'"
fi
- # Disable p2p to prevent wpa_supplicant from creating another control interface.
- echo "p2p_disabled=1" >> "$wpa_conf"
+ # Disable p2p to prevent wpa_supplicant from creating another control interface
+ echo "p2p_disabled=1" >> "$WPAConfigFile"
local profile
list_profiles | while IFS= read -r profile; do
@@ -222,16 +219,16 @@ start() {
is_yes "${ExcludeAuto:-no}" && exit
# Set default and exclude wpa-config as it does not fit this scheme
[[ ${Security:=none} != "wpa-config" ]] || exit
- printf '%s\n' "network={" "$(wpa_make_config_block)" "id_str=\"$profile\"" "}" >> "$wpa_conf"
+ printf '%s\n' "network={" "$(wpa_make_config_block)" "id_str=\"$profile\"" "}" >> "$WPAConfigFile"
report_notice "Included profile '$profile'"
)
done
- # Start the WPA supplicant and wpa_actiond
+ # Start the WPA supplicant and wpa_cli
: ${WPADriver:=nl80211,wext}
WPAOptions+=" -W"
- if wpa_start "$interface" "$WPADriver" "$wpa_conf"; then
- if $ACTIOND -i "$interface" -P "$pidfile" -a "$ACTION_SCRIPT"; then
+ if wpa_start "$interface" "$WPADriver" "$WPAConfigFile"; then
+ if wpa_call "$interface" -B -a "$ACTION_SCRIPT"; then
return 0
fi
wpa_stop "$interface"
@@ -241,17 +238,16 @@ start() {
return 1
}
-## Stop the WPA supplicant and wpa_actiond
+## Stop the WPA supplicant, which automatically stops wpa_cli
# $1: interface
stop() {
local interface="$1"
- local pidfile="$STATE_DIR/wpa_actiond-$interface.pid"
- [[ -e "$pidfile" ]] && kill "$(< "$pidfile")"
- timeout_wait 1 '! wpa_is_active "$interface"' || wpa_stop "$interface"
+ wpa_stop "$interface"
bring_interface_down "$interface"
- [[ $RFKill ]] && rf_disable "$interface" "$RFKill"
- return 0
+ if [[ $RFKill ]]; then
+ rf_disable "$interface" "$RFKill"
+ fi
}
## Remove WPA supplicant configuration files
--
2.20.1
More information about the arch-projects
mailing list