Skip to content

Commit

Permalink
Adopt AppArmor Profile before starting hostapd
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepthiYV committed May 25, 2021
1 parent ac1ac30 commit a39a121
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/wpa_supplicant/wpa_supplicant_test.sh
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tests/console/wpa_supplicant.pm
Expand Up @@ -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 <felix.niederwanger@suse.de>

Expand All @@ -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;

0 comments on commit a39a121

Please sign in to comment.