[PATCH 2/3] wifi-scripts: save wpa_psk_file on permanent storage by default
Christian Marangi
ansuelsmth at gmail.com
Mon Mar 4 13:42:17 PST 2024
Save wpa_psk_file on permanent storage by default. Currently it's always
created in /var/run with the hostapd files.
Any user that would use this option would save this file on permanent
storage to declare specific PSK per devices or for each VLAN.
The file is also used for WPS to store the per-device PSK and keeping it
on /var/run on normal installation (excluding installation with
permanent /var) would result in the wpa_psk_file getting wiped on
reboot, losing all the per-device PSK saved by hostapd.
To fix this, move the wpa_psk_file to /etc/hostapd and set the default
value for the wpa_psk_file option to point to this directory.
Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
package/network/config/wifi-scripts/Makefile | 2 +-
.../config/wifi-scripts/files/lib/netifd/hostapd.sh | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/package/network/config/wifi-scripts/Makefile b/package/network/config/wifi-scripts/Makefile
index 085860d7c6..539d9a03c3 100644
--- a/package/network/config/wifi-scripts/Makefile
+++ b/package/network/config/wifi-scripts/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=wifi-scripts
PKG_VERSION:=1.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Felix Fietkau <nbd at nbd.name>
diff --git a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
index a357418fe1..71be4db67d 100644
--- a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
+++ b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh
@@ -687,7 +687,14 @@ hostapd_set_bss_options() {
wireless_setup_vif_failed INVALID_WPA_PSK
return 1
fi
- [ -z "$wpa_psk_file" ] && set_default wpa_psk_file /var/run/hostapd-$ifname.psk
+ [ -z "$wpa_psk_file" ] && {
+ [ -d /etc/hostapd ] || {
+ mkdir /etc/hostapd
+ chown network:netwrok /etc/hostapd
+ }
+ set_default wpa_psk_file /etc/hostapd/hostapd-$ifname.psk
+ ln -s /etc/hostapd/hostapd-$ifname.psk /var/run/hostapd-$ifname.psk
+ }
[ -n "$wpa_psk_file" ] && {
[ -e "$wpa_psk_file" ] || {
touch "$wpa_psk_file"
--
2.43.0
More information about the openwrt-devel
mailing list