Wireless support - allow initial plain username and password

When user name and password are stored in plain text, these will be encrypted at start up.
This commit is contained in:
bergware
2025-02-12 03:09:00 +01:00
parent 3d7aa0fb7b
commit b772e017b1
3 changed files with 46 additions and 8 deletions
@@ -11,12 +11,11 @@
*/
?>
<?
$ssl = '/etc/rc.d/rc.ssl.input';
if (is_readable($ssl)) extract(parse_ini_file($ssl));
$open_ssl = "/usr/local/emhttp/webGui/scripts/open_ssl";
// encrypt username and password before saving (if existing)
if (!empty($_POST['USERNAME']) && isset($cipher,$key,$iv)) $_POST['USERNAME'] = openssl_encrypt($_POST['USERNAME'],$cipher,$key,0,$iv);
if (!empty($_POST['PASSWORD']) && isset($cipher,$key,$iv)) $_POST['PASSWORD'] = openssl_encrypt($_POST['PASSWORD'],$cipher,$key,0,$iv);
if (!empty($_POST['USERNAME'])) $_POST['USERNAME'] = exec("$open_ssl encrypt \"{$_POST['USERNAME']}\"");
if (!empty($_POST['PASSWORD'])) $_POST['PASSWORD'] = exec("$open_ssl encrypt \"{$_POST['PASSWORD']}\"");
// update active wifi selection
foreach ($keys as $key => $val) if (isset($val['GROUP'])) $keys[$key]['GROUP'] = 'saved';