diff --git a/src/etc/rc.initial.password b/src/etc/rc.initial.password index d96a03252..227783dcb 100755 --- a/src/etc/rc.initial.password +++ b/src/etc/rc.initial.password @@ -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";