From a39a121ee4095c2ae0b11ad143e60c33c090429c Mon Sep 17 00:00:00 2001 From: dvenkatachala Date: Fri, 21 May 2021 11:48:49 +0200 Subject: [PATCH] Adopt AppArmor Profile before starting hostapd --- data/wpa_supplicant/wpa_supplicant_test.sh | 2 +- tests/console/wpa_supplicant.pm | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/wpa_supplicant/wpa_supplicant_test.sh b/data/wpa_supplicant/wpa_supplicant_test.sh index 8e3e4640400d..300f4cb031c3 100755 --- a/data/wpa_supplicant/wpa_supplicant_test.sh +++ b/data/wpa_supplicant/wpa_supplicant_test.sh @@ -14,7 +14,7 @@ function cleanup() { kill $hostapd_pid fi modprobe -r mac80211_hwsim - rm -f wifi_scan.txt networks.txt status.txt hostapd.log hostapd.com dnsmasq.log dhclinet.log + rm -f wifi_scan.txt networks.txt status.txt hostapd.com dnsmasq.log dhclinet.log rm -f /etc/sysconfig/network/ifcfg-wlan1 wpa_cli -i wlan1 terminate >/dev/null 2>/dev/null ip netns pids wifi_master | xargs kill diff --git a/tests/console/wpa_supplicant.pm b/tests/console/wpa_supplicant.pm index 8f96bed3980c..345cf84591e2 100644 --- a/tests/console/wpa_supplicant.pm +++ b/tests/console/wpa_supplicant.pm @@ -20,7 +20,7 @@ # - Connect to WPA2 network # - Ping access point (static IP-addresses) # - Unassign static IP -# - Get new IP address using dhcp with wicked +# - Get new IP address using dhcp with wicked # - Ping access point (now dhcp IP-address) # Maintainer: Felix Niederwanger @@ -37,13 +37,23 @@ sub run { zypper_call 'in wpa_supplicant hostapd iw dnsmasq unzip'; assert_script_run 'cd $(mktemp -d)'; assert_script_run('curl -L -s ' . data_url('wpa_supplicant') . ' | cpio --make-directories --extract && cd data'); + $self->adopt_apparmor; assert_script_run('bash -x ./wpa_supplicant_test.sh 2>&1 | tee wpa-supplicant_test.txt', timeout => 600); } +sub adopt_apparmor { + if (script_output('systemctl is-active apparmor', proceed_on_failure => 1) eq 'active') { + assert_script_run('echo "# adopt AppArmor"'); + assert_script_run(q(test ! -e /etc/apparmor.d/usr.sbin.hostapd || sed -i "s|^}$| $PWD/\hostapd.conf r,\n}|g" /etc/apparmor.d/usr.sbin.hostapd)); + systemctl 'reload apparmor'; + } +} + sub post_fail_hook { # Upload logs if present upload_logs("wicked.log") if (script_run("stat wicked.log") == 0); upload_logs("wpa-supplicant_test.txt") if (script_run("stat wpa-supplicant_test.txt") == 0); + upload_logs("hostapd.log") if (script_run("stat hostapd.log") == 0); } 1;