Harden NordVPN reconciliation and WebGUI testing
This commit is contained in:
parent
a115d2a012
commit
b4a30ca190
1 changed files with 777 additions and 97 deletions
|
|
@ -1,11 +1,43 @@
|
|||
<?php
|
||||
|
||||
require_once '/usr/local/etc/inc/config.inc';
|
||||
require_once '/usr/local/etc/inc/auth.inc';
|
||||
|
||||
use OPNsense\Core\Config;
|
||||
use OPNsense\Firewall\Alias;
|
||||
|
||||
$password = trim((string)file_get_contents('/mnt/ui-password'));
|
||||
if (!preg_match('/^[a-f0-9]{64}$/', $password)) {
|
||||
throw new RuntimeException('The UI test password is invalid.');
|
||||
}
|
||||
$root =& getUserEntry('root');
|
||||
if ($root === false) {
|
||||
throw new RuntimeException('The root user is unavailable.');
|
||||
}
|
||||
local_user_set_password($root, $password);
|
||||
local_user_set($root, true);
|
||||
write_config('Set disposable WebGUI test password');
|
||||
|
||||
$users = Config::getInstance()->object()->system->user;
|
||||
foreach ($users as $user) {
|
||||
if ((string)$user->name === 'root' && password_verify($password, (string)$user->password)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($user) || (string)$user->name !== 'root' || !password_verify($password, (string)$user->password)) {
|
||||
throw new RuntimeException('The disposable WebGUI password was not saved.');
|
||||
}
|
||||
exec('/usr/local/sbin/configctl webgui restart', $output, $status);
|
||||
if ($status !== 0) {
|
||||
throw new RuntimeException('The WebGUI did not restart.');
|
||||
}
|
||||
|
||||
$aliases = new Alias();
|
||||
foreach ($aliases->aliases->alias->iterateItems() as $alias) {
|
||||
if ((string)$alias->name === 'UI_TEST_NETWORK') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$alias = $aliases->aliases->alias->add();
|
||||
$alias->setNodes([
|
||||
'enabled' => '1',
|
||||
|
|
|
|||
Loading…
Reference in a new issue