From 0bb8a5400e89f2620caf6042484bae70116bae4c Mon Sep 17 00:00:00 2001 From: Nicolas Ramz Date: Tue, 22 Oct 2024 17:27:31 +0200 Subject: [PATCH] Use sed instead of grep+cut to capture the passphrase Current method would crop any passphrase containing an '=' sign. For eg. wpa_passwphrase=Foo=Bar would return 'Foo' instead of 'Foo=Bar'. --- api/modules/ap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/modules/ap.py b/api/modules/ap.py index 25dffdad..53397cf0 100644 --- a/api/modules/ap.py +++ b/api/modules/ap.py @@ -32,7 +32,7 @@ def ieee80211n(): return subprocess.run("cat /etc/hostapd/hostapd.conf | grep ieee80211n= | cut -d'=' -f2", shell=True, capture_output=True, text=True).stdout.strip() def wpa_passphrase(): - return subprocess.run("cat /etc/hostapd/hostapd.conf | grep wpa_passphrase= | cut -d'=' -f2", shell=True, capture_output=True, text=True).stdout.strip() + return subprocess.run("sed -En 's/wpa_passphrase=(.*)/\1/p' /etc/hostapd/hostapd.conf", shell=True, capture_output=True, text=True).stdout.strip() def interface(): return subprocess.run("cat /etc/hostapd/hostapd.conf | grep interface= | cut -d'=' -f2 | head -1", shell=True, capture_output=True, text=True).stdout.strip()