mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 08:09:42 +00:00
allow to run this with args to change the password
This commit is contained in:
parent
5cb149d7fc
commit
76eb058d32
@ -31,6 +31,19 @@
|
||||
require_once('config.inc');
|
||||
require_once('auth.inc');
|
||||
|
||||
$password = isset($argv[1]) ? $argv[1] : '';
|
||||
$confirm = isset($argv[2]) ? $argv[2] : '';
|
||||
|
||||
if (!empty($password) && $password === $confirm) {
|
||||
/* the installer needs this code to change the password */
|
||||
$admin_user = &getUserEntryByUID(0);
|
||||
if ($admin_user) {
|
||||
local_user_set_password($admin_user, $password);
|
||||
write_config('Root user reset from console');
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$fp = fopen('php://stdin', 'r');
|
||||
|
||||
echo "The root user login behaviour will be restored to its defaults.\n\nDo you want to proceed? [y/N]: ";
|
||||
@ -88,6 +101,6 @@ if ($password !== $confirm) {
|
||||
local_user_set_password($admin_user, $password);
|
||||
local_user_set($admin_user);
|
||||
|
||||
write_config('Root user reset from console menu');
|
||||
write_config('Root user reset from console');
|
||||
|
||||
echo "\nThe root user has been reset successfully.\n";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user