1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Merge pull request #884 from RaspAP/feature/reinitialize-wpa

Feature: reinitialize wpa_supplicant
This commit is contained in:
Bill Zimmerman 2021-05-10 11:13:04 +02:00 committed by GitHub
commit fabc48c7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 1 deletions

View File

@ -19,6 +19,11 @@ function DisplayWPAConfig()
$result = 0;
exec('sudo wpa_cli -i ' . $_SESSION['wifi_client_interface'] . ' select_network '.strval($_POST['connect']));
$status->addMessage('New network selected', 'success');
} elseif (isset($_POST['wpa_reinit'])) {
$status->addMessage('Reinitializing wpa_supplicant', 'info', false);
$force_remove = true;
$result = reinitializeWPA($force_remove);
$status->addMessage($result, 'info');
} elseif (isset($_POST['client_settings'])) {
$tmp_networks = $networks;
if ($wpa_file = fopen('/tmp/wifidata', 'w')) {

View File

@ -157,3 +157,20 @@ function getWifiInterface()
}
}
/*
* Reinitializes wpa_supplicant for the wireless client interface
* The 'force' parameter deletes the socket in /var/run/wpa_supplicant/
*
* @param boolean $force
*/
function reinitializeWPA($force)
{
if ($force == true) {
$cmd = escapeshellcmd("sudo /bin/rm /var/run/wpa_supplicant/".$_SESSION['wifi_client_interface']);
$result = exec($cmd);
}
$cmd = escapeshellcmd("sudo /sbin/wpa_supplicant -B -Dnl80211 -c/etc/wpa_supplicant/wpa_supplicant.conf -i". $_SESSION['wifi_client_interface']);
$result = shell_exec($cmd);
return $result;
}

View File

@ -4,6 +4,8 @@ www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_supplicant -B -Dnl80211 -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan[0-9]
www-data ALL=(ALL) NOPASSWD:/bin/rm /var/run/wpa_supplicant/wlan[0-9]
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan_results
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] reconfigure

Binary file not shown.

View File

@ -150,6 +150,21 @@ msgstr "Not configured"
msgid "<strong>Note:</strong> WEP access points appear as 'Open'. RaspAP does not currently support connecting to WEP"
msgstr "<strong>Note:</strong> WEP access points appear as 'Open'. RaspAP does not currently support connecting to WEP"
msgid "No Wifi stations found"
msgstr "No Wifi stations found"
msgid "Reinitializing wpa_supplicant"
msgstr "Reinitializing wpa_supplicant"
msgid "Click 'Rescan' to search for nearby Wifi stations."
msgstr "Click 'Rescan' to search for nearby Wifi stations."
msgid "Click 'Reinitialize' to force reinitialize <code>wpa_supplicant</code>."
msgstr "Click 'Reinitialize' to force reinitialize <code>wpa_supplicant</code>."
msgid "Reinitialize"
msgstr "Reinitialize"
#: includes/dashboard.php
msgid "Interface Information"
msgstr "Interface Information"

View File

@ -1,7 +1,16 @@
<?php if (empty($networks)) { ?>
<div class="col-md-6 ml-6">
<p class="lead text-center"><?php echo _('No Wifi stations found') ?></p>
<p class="text-center"><?php echo _('Click "Rescan" to search for nearby Wifi stations.') ?></p>
<p class="text-center"><?php echo _("Click 'Rescan' to search for nearby Wifi stations.") ?></p>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<p class="text-center"><?php echo _("Click 'Reinitialize' to force reinitialize <code>wpa_supplicant</code>.") ?></p>
<form method="POST" action="wpa_conf" name="wpa_conf_form" class="row">
<?php echo CSRFTokenFieldTag() ?>
<div class="col-xs mr-3 mb-3">
<input type="submit" class="btn btn-warning btn-block float-right" name="wpa_reinit" value="<?php echo _("Re-initialize"); ?>" />
</div>
</form>
<?php endif ?>
</div>
<?php } elseif (count($networks) == 1) {
$prop_col = "col-sm-12";