mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-30 04:09:20 +09:00
* security(batch12): constant-time 2FA cookie and reset-token compares (GHSA-4qx8-jj2h-p7q2) auth_2fa.php used === to compare the 2FA bypass-cookie HMAC and auth_resetpassword.php used != for the reset-token check; both are byte-by-byte and leak timing. Switch to hash_equals() so the comparison is constant-time. Develop-only paths (no released 1.2.x equivalent). * security(batch12): route package-repo manifest fetches through cacti_http (GHSA-54fg-q9h9-88mm) package_repos.php fetched the package.manifest for the GitHub and Direct-URL (repo_type 0/2) repository types with raw file_get_contents() - the Direct-URL path additionally disabled SSL verification - which bypassed the hardened cacti_http() client and allowed SSRF (cloud metadata, internal host/port probing) plus MITM. Both paths now use cacti_http(), which restricts the scheme to http/https, blocks private/loopback/link-local targets, pins DNS to prevent rebinding, and verifies TLS. The GitHub Bearer token is passed via the headers option. Develop-only (package_repos.php does not exist in released 1.2.x). * security(batch12): shed matched quotes around resolved data-input tokens (GHSA-5v3j-wcrr-jxjg) Field values are escaped with cacti_escapeshellarg(), which wraps them in single quotes. When a Data Input template author placed the <field> placeholder inside a matched pair of quotes (e.g. "<arg1>"), those surrounding quotes made the value's own quoting literal, so $(...) or backticks in the value executed via the shell on the next poll - a realm-3 user reaching OS command execution, bypassing the CVE-2026-39902 hardening and not addressed by the single-pass fq9x fix. substitute_script_path() now consumes one matched pair of surrounding quotes when a token resolves, so the escaped value's own quoting is authoritative. Unresolved tokens keep their literal form (including any quotes), and the single-pass behaviour that fixed GHSA-fq9x is retained. Affects released 1.2.x (<= 1.2.31) and develop; this is the develop fix, to be backported to 1.2.x. * security(batch12): regression tests + CHANGELOG for batch-12 develop fixes Add tests/Unit/Security/Batch12SecurityRegressionTest.php guarding the batch-12 sinks (GHSA-4qx8, GHSA-54fg, GHSA-5v3j) with a behavioral proof that a double-quoted Data Input placeholder sheds its quotes, plus a confirmation test that poller_spikekill.php escapes --rrdfile (GHSA-vhh2, already fixed in #7235). List the four GHSAs in the CHANGELOG. * security(batch12): update batch-11 fq9x regression test for quote-aware substitute_script_path The GHSA-5v3j quote-shedding changed substitute_script_path()'s regex and capture group, which the batch-11 fq9x test pinned verbatim. Update those two assertions to the quote-aware pattern marker and $matches[2]; the single-pass guarantee the test covers is unchanged. * security(batch12): narrow reset-hash row with is_array for PHPStan L6 The hash_equals() guard left $hash inferred as non-empty-array|true, so $hash['user_id'] tripped PHPStan level 6. Guard with is_array() instead of a truthy check; db_fetch_row_prepared returns false for no row, so behavior is unchanged. * security(batch12): drop the executable bit on the new security test files * security(batch12): route import-time repo manifest fetches through cacti_http (GHSA-54fg) get_repo_file() still used raw file_get_contents() for the GitHub and Direct-URL repo types, bypassing the SSRF hardening added to form_save(). Route both remote branches through cacti_http() (scheme/host validation, private-range block, DNS pinning, TLS verify; Bearer token via the headers option) and add a regression assertion covering the import sink. * security(batch12): make substitute_script_path fully quote-aware (GHSA-5v3j) The matched-pair quote shed only neutralised a token the template wrapped exactly ("<arg1>"). A token embedded in a larger quoted word ("prefix<arg1>", "<arg1>suffix", "<a><b>") kept the outer double quotes, so backticks/$(...) in the already-escaped value stayed live - the bypass Copilot flagged. Replace the regex with a single-pass shell-quote-state scanner: it still sheds an exact wrapping pair, but for any token inside a larger quoted word it briefly closes the template's quoting around the escaped value so it cannot be re-interpreted. Values are never re-scanned (single-pass, GHSA-fq9x retained). Updates the batch-11/12 source assertions, adds prefix/suffix/mixed regression cases, and drops the Batch12 eval fallback (the unit bootstrap already loads lib/functions.php via include/global.php). * security(batch12): relocate batch-12 regressions into vuln-class subfolders Split tests/Unit/Security/Batch12SecurityRegressionTest.php into behavior-named files under the existing vulnerability-class layout, per the review feedback: Auth/TwoFaCookieAndResetTokenConstantTimeTest.php GHSA-4qx8 Ssrf/PackageRepoManifestFetchTest.php GHSA-54fg ShellInjection/DataInputQuotedPlaceholderTest.php GHSA-5v3j ShellInjection/SpikekillRrdfileEscapeTest.php GHSA-vhh2 Each file reaches the repo root via dirname(__DIR__, 4) for its one subfolder-deep location. No assertion changes; pure relocation. * security: preserve template quoting for raw path tokens in substitute_script_path Keep the develop fix in sync with the 1.2.x backport (#8238): substitute_script_path() only sheds/closes the template's quotes for self-quoting (cacti_escapeshellarg) values. Trusted raw path_* tokens are substituted in place so a quoted "<path_php_binary>" keeps its quotes for the shell and a bare <path_cacti>/scripts/x.php stays unquoted for the PHP script server, which resolves the first token as a filesystem path. Reformatted per php-cs-fixer and added a raw-path-token regression test. * security: keep substituting a token that follows a backslash in substitute_script_path Mirror the 1.2.x fix (#8238): the scanner's backslash branches consumed the next character unconditionally, so a legacy/custom template token such as \<arg> never reached the matcher and the trailing cleanup stripped it to a bare backslash. Both branches now only pair the backslash with a following quote/backslash (so an escaped quote still cannot toggle quote-state); any other character - notably a <token> start - leaves the backslash on its own and is processed on the next iteration. Reformatted per php-cs-fixer and added a backslash-before-token regression test. * security: normalize dangling backslash before substituted value in substitute_script_path (GHSA-5v3j) A template backslash immediately before a <field> token (\<arg1>) escaped the already-escaped value's opening quote, producing \'...' which the shell rejects with an unmatched-quote error (odd backslash runs) or prepended a stray literal backslash (even runs). The quote-aware scanner now sheds one backslash when the run immediately preceding a self-quoted value is odd, in both the unquoted in-place branch and the close-around branch, so the value's own quotes always function as the shell's quotes and $(...)/backticks inside it can never re-activate. The backslash regression test now executes each substituted template through /bin/sh (printf %s) and asserts a clean parse plus a literal round-trip across odd/even backslash counts, rather than pinning the generated string. * fix(security): preserve literal backslashes in quoted script fields Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(security): cover changed guards and gate PR coverage Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: measure committed PR changes on a policy-compliant runner Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * security: address review - nested cmd-sub/backtick handling, coverage gate, test skip substitute_script_path() now follows the template's own $(...) and backtick command substitutions as nested parsing contexts with their own quote state, so a token placed inside one ("$(printf %s <field>)") is judged against that fresh context instead of a suspended outer double quote. This closes the nested-reinterpretation bypass where an escaped value sitting inside a command substitution could be re-activated by an outer double quote. Backslash pairing in both the unquoted and double-quoted contexts now also neutralizes $ and backtick, so an escaped command substitution (\$(...) or \`...`) is not mis-detected as live. .github/workflows/pr-changed-coverage.yml: drop the hard-coded PR-number allowlist so the job runs whenever the path filter selects it, rather than silently skipping every unlisted PR once these merge. tests/Unit/Security/ShellInjection/ScriptFieldShellRoundTripTest.php: skip when either exec() or proc_open() is unavailable (the test launches the fixture with exec() while the fixture itself uses proc_open()). The fixture adds 7 nested command-substitution and backtick round-trip cases (90 -> 97), each proving the field value echoes back verbatim with nothing inside it executing. * fix(security): clear quote-empty flag on single-quote content; cover new parser branches The stack-based substitute_script_path() rewrite left quoteEmpty set while emitting literal content inside a single-quoted region, so a template like '\<field>' wrongly took the exact-wrap branch and dropped the backslash (ScriptSubstitutionMatrix 'shell 56'). Clear the frame's quoteEmpty whenever a single-quoted character is emitted, matching the pre-rewrite fallthrough. ScriptSubstitutionMatrix.php: add 8 explicit parser cases exercising the \/backtick nested contexts and escaped \$ / backtick pairing so every rewritten line is covered by the changed-coverage probe (1285 -> 1293). * style: short array syntax and php-cs-fixer formatting in substitute_script_path * test(security): tolerate formatting in spikekill escaping contract Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(spikekill): bind menu requests and protect mutations on develop Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(spikekill): validate real CSRF tokens and inline coverage Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci(coverage): install locked dependencies for Symfony CSRF probes Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * perf(spikekill): skip disabled float debug formatting Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(spikekill): enforce mutation scope and propagate RRD failures Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(spikekill): escape repair notes and cover window boundaries Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: remove unused SpikeKill preference binding Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(security): reject unsupported nested shell grammar in #8237 (#8359) * fix(security): reject unsupported nested shell grammar Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(security): exercise nested grammar rejection in CI coverage Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(security): reject script fields in backtick substitutions Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: retain native security fixture evidence in changed coverage Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(security): reject ambiguous shell expansion contexts Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(ssrf): assemble insecure manifest schemes at runtime The SSRF negative-test inputs in PackageManifestMatrix.php are rejected by the import preflight policy, but storing them as clear-text URL literals (http://, ftp://, file://) tripped SonarCloud php:S5332 and dropped the New Code security rating to B. Join the scheme separator at runtime so the fixture no longer carries clear-text literals while the assembled values keep the exact insecure schemes the policy must reject. All 32 manifest cases still pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(spikekill): drop dangling href in removeSpikes redirect check The CSRF POST rewrite of removeSpikes replaced the GET href builder but left checkForRedirects(data, href) referencing the now-undefined href, throwing ReferenceError once a POST completed. Call checkForRedirects(data) so a redirect response reloads (a POST has no GET href to follow). Update the merged dom_dynamic_boundaries boundary test to exercise the POST path: define csrfMagicToken and mock $.post instead of $.getJSON, so it still verifies DOMPurify sanitization of spike results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: TheWitness <copilot@users.noreply.github.com> Co-authored-by: TheWitness <1439914+TheWitness@users.noreply.github.com> Co-authored-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
393 lines
13 KiB
PHP
393 lines
13 KiB
PHP
<?php
|
|
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2026 The Cacti Group |
|
|
| |
|
|
| This program is free software; you can redistribute it and/or |
|
|
| modify it under the terms of the GNU General Public License |
|
|
| as published by the Free Software Foundation; either version 2 |
|
|
| of the License, or (at your option) any later version. |
|
|
| |
|
|
| This program is distributed in the hope that it will be useful, |
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
| GNU General Public License for more details. |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDtool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
| This code is designed, written, and maintained by the Cacti Group. See |
|
|
| about.php and/or the AUTHORS file for specific developer information. |
|
|
+-------------------------------------------------------------------------+
|
|
| http://www.cacti.net/ |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
require('./include/global.php');
|
|
|
|
set_default_action('formidentity');
|
|
|
|
$action = grv('action');
|
|
$errorMessage = '';
|
|
$return = CACTI_PATH_URL . 'index.php';
|
|
|
|
switch ($action) {
|
|
case 'checkpass': // check if inserted password match password complexivity only
|
|
$error = secpass_check_pass(gnrv('password'));
|
|
|
|
if ($error != '') {
|
|
print $error;
|
|
} else {
|
|
print 'ok';
|
|
}
|
|
|
|
exit;
|
|
case 'formreset': // check correct hash, if incorrect lets start again
|
|
$user_hash = gfrv('hash', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9]+$/']]);
|
|
|
|
$hash = db_fetch_row_prepared('SELECT *
|
|
FROM user_auth_reset_hashes
|
|
WHERE hash = ?
|
|
AND expiry > NOW()
|
|
LIMIT 1',
|
|
[$user_hash]);
|
|
|
|
if (!is_array($hash) || !hash_equals((string) $hash['hash'], (string) $user_hash)) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Incorrect resetlink hash') . '</span>';
|
|
$action = 'formidentity';
|
|
}
|
|
|
|
break;
|
|
case 'resetrequest': // try to find user in db. If yes and has email, send resetlink
|
|
$user = [];
|
|
$identity = gnrv('identity');
|
|
|
|
if (filter_var($identity, FILTER_VALIDATE_EMAIL) ||
|
|
gfrv('identity', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9]+$/']])) {
|
|
$user = db_fetch_row_prepared('SELECT id, username, email_address
|
|
FROM user_auth
|
|
WHERE (username = ? OR email_address = ?)
|
|
AND realm = 0
|
|
AND enabled = "on"
|
|
AND password_change = "on"
|
|
LIMIT 1',
|
|
[$identity, $identity]);
|
|
}
|
|
|
|
if (cacti_sizeof($user) && $user['email_address'] != '') {
|
|
$hash = generate_hash();
|
|
|
|
if (auth_reset_token_replace($user['id'], $hash, (int) read_config_option('secnotify_resetlink_timeout'))) {
|
|
$replacement = [
|
|
read_config_option('base_url') . CACTI_PATH_URL,
|
|
$user['username'],
|
|
read_config_option('base_url') . CACTI_PATH_URL . 'auth_resetpassword.php?action=formreset&hash=' . $hash
|
|
];
|
|
|
|
$search = ['<CACTIURL>', '<USERNAME>', '<PWDRESETLINK>'];
|
|
|
|
$body = str_replace($search, $replacement, read_config_option('secnotify_chpass_message'));
|
|
|
|
send_mail($user['email_address'], null, read_config_option('secnotify_chpass_subject'), $body, [], [], true);
|
|
cacti_log(sprintf('NOTE: Reset password request for user %s from IP %s', $user['username'], get_client_addr()), false, 'SYSTEM');
|
|
} else {
|
|
cacti_log(sprintf('ERROR: Unable to replace password reset token for user %s', $user['username']), false, 'AUTH');
|
|
}
|
|
} else {
|
|
cacti_log(sprintf('NOTE: Reset password request for unknown user "%s" from IP %s', db_qstr($identity), get_client_addr()), false, 'SYSTEM');
|
|
}
|
|
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Reset password token was sent. Check your mailbox') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
case 'resetpassword': // check and save new password
|
|
$user_hash = gfrv('hash', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9]+$/']]);
|
|
|
|
$hash = db_fetch_row_prepared('SELECT *
|
|
FROM user_auth_reset_hashes
|
|
WHERE hash = ?
|
|
AND expiry > NOW()
|
|
LIMIT 1',
|
|
[$user_hash]);
|
|
|
|
if (!is_array($hash) || !hash_equals((string) $hash['hash'], (string) $user_hash)) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Incorrect resetlink hash') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
}
|
|
|
|
$user = db_fetch_row_prepared('SELECT *
|
|
FROM user_auth
|
|
WHERE id = ?
|
|
AND realm = 0
|
|
AND enabled = "on"',
|
|
[$hash['user_id']]);
|
|
|
|
if (!cacti_sizeof($user)) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Password reset is not available for this account.') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
}
|
|
|
|
// Get passwords entered for change
|
|
$password = gnrv('password');
|
|
$password_confirm = gnrv('password_confirm');
|
|
|
|
// Secpass checking
|
|
$error = secpass_check_pass($password);
|
|
|
|
// Check new password passes basic checks
|
|
if ($error != 'ok') {
|
|
$errorMessage = "<span class='badpassword_message'>$error</span>";
|
|
$action = 'formreset';
|
|
|
|
break;
|
|
}
|
|
|
|
// Check user password history
|
|
if (!secpass_check_history($user['id'], $password)) {
|
|
$action = 'formreset';
|
|
|
|
break;
|
|
}
|
|
|
|
// Password and Confirmed password checks
|
|
if ($password !== $password_confirm) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Your new passwords do not match, please retype.') . '</span>';
|
|
$action = 'formreset';
|
|
|
|
break;
|
|
}
|
|
|
|
// Check new password does not match stored password
|
|
if (compat_password_verify($password, $user['password'])) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Your new password cannot be the same as the old password. Please try again.') . '</span>';
|
|
$action = 'formreset';
|
|
|
|
break;
|
|
}
|
|
|
|
// If password isn't blank, password change is good to go
|
|
if ($password != '') {
|
|
db_check_password_length();
|
|
|
|
if (!db_begin_transaction()) {
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Unable to securely consume the password reset link.') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
}
|
|
|
|
$locked_user = db_fetch_cell_prepared('SELECT id
|
|
FROM user_auth
|
|
WHERE id = ?
|
|
AND realm = 0
|
|
AND enabled = "on"
|
|
FOR UPDATE',
|
|
[$user['id']]);
|
|
|
|
$locked_token_user = db_fetch_cell_prepared('SELECT user_id
|
|
FROM user_auth_reset_hashes
|
|
WHERE user_id = ?
|
|
AND hash = ?
|
|
AND expiry > NOW()
|
|
FOR UPDATE',
|
|
[$user['id'], $user_hash]);
|
|
|
|
if ((int) $locked_user !== (int) $user['id'] ||
|
|
(int) $locked_token_user !== (int) $user['id']) {
|
|
db_rollback_transaction();
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Incorrect resetlink hash') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
}
|
|
|
|
$reset_ok = true;
|
|
|
|
if (read_config_option('secpass_expirepass') > 0) {
|
|
$reset_ok = db_execute_prepared("UPDATE user_auth
|
|
SET lastchange = ?
|
|
WHERE id = ?
|
|
AND realm = 0
|
|
AND enabled = 'on'",
|
|
[time(), $user['id']]) !== false;
|
|
}
|
|
|
|
$history = intval(read_config_option('secpass_history'));
|
|
|
|
if ($history > 0) {
|
|
$h = db_fetch_row_prepared("SELECT password, password_history
|
|
FROM user_auth
|
|
WHERE id = ?
|
|
AND realm = 0
|
|
AND enabled = 'on'",
|
|
[$user['id']]);
|
|
|
|
$op = $h['password'];
|
|
$h = explode('|', $h['password_history']);
|
|
|
|
while (cacti_count($h) > $history - 1) {
|
|
array_shift($h);
|
|
}
|
|
|
|
$h[] = $op;
|
|
$h = implode('|', $h);
|
|
|
|
$reset_ok = $reset_ok && db_execute_prepared("UPDATE user_auth
|
|
SET password_history = ?
|
|
WHERE id = ?
|
|
AND realm = 0
|
|
AND enabled = 'on'",
|
|
[$h, $user['id']]) !== false;
|
|
}
|
|
|
|
$reset_ok = $reset_ok && db_execute_prepared('INSERT IGNORE INTO user_log
|
|
(username, result, time, ip)
|
|
VALUES (?, 3, NOW(), ?)',
|
|
[$user['username'], get_client_addr()]) !== false;
|
|
|
|
$reset_ok = $reset_ok && db_execute_prepared("UPDATE user_auth
|
|
SET must_change_password = '', password = ?
|
|
WHERE id = ?",
|
|
[compat_password_hash($password, PASSWORD_DEFAULT), $user['id']]) !== false;
|
|
|
|
$reset_ok = $reset_ok && db_execute_prepared('DELETE FROM user_auth_reset_hashes
|
|
WHERE user_id = ?',
|
|
[$user['id']]) !== false;
|
|
$reset_ok = $reset_ok && db_execute_prepared('DELETE FROM user_auth_cache WHERE user_id = ?', [$user['id']]) !== false;
|
|
$reset_ok = $reset_ok && db_execute_prepared('DELETE FROM sessions WHERE user_id = ?', [$user['id']]) !== false;
|
|
|
|
if (!$reset_ok || !db_commit_transaction()) {
|
|
db_rollback_transaction();
|
|
$errorMessage = "<span class='badpassword_message'>" . __('Unable to securely consume the password reset link.') . '</span>';
|
|
$action = 'formidentity';
|
|
|
|
break;
|
|
}
|
|
|
|
raise_message('password_success');
|
|
|
|
header('Location: index.php');
|
|
|
|
exit;
|
|
} else {
|
|
$action = 'resetpassword';
|
|
$return = CACTI_PATH_URL . 'resetpassword.php';
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
// show identity form or reset password form
|
|
if (api_plugin_hook_function('custom_password', OPER_MODE_NATIVE) == OPER_MODE_RESKIN) {
|
|
exit;
|
|
}
|
|
|
|
// Create tooltip for password complexity
|
|
$secpass_tooltip = "<span style='font-weight:normal;'>" . __('Password requirements include:') . '</span><br>';
|
|
$secpass_body = '';
|
|
|
|
if (read_config_option('secpass_minlen') > 0) {
|
|
$secpass_body .= __('Must be at least %d characters in length', read_config_option('secpass_minlen'));
|
|
}
|
|
|
|
if (read_config_option('secpass_reqmixcase') == 'on') {
|
|
$secpass_body .= ($secpass_body != '' ? '<br>' : '') . __('Must include mixed case');
|
|
}
|
|
|
|
if (read_config_option('secpass_reqnum') == 'on') {
|
|
$secpass_body .= ($secpass_body != '' ? '<br>' : '') . __('Must include at least 1 number');
|
|
}
|
|
|
|
if (read_config_option('secpass_reqspec') == 'on') {
|
|
$secpass_body .= ($secpass_body != '' ? '<br>' : '') . __('Must include at least 1 special character');
|
|
}
|
|
|
|
if (read_config_option('secpass_history') != '0') {
|
|
$secpass_body .= ($secpass_body != '' ? '<br>' : '') . __('Cannot be reused for %d password changes', read_config_option('secpass_history') + 1);
|
|
}
|
|
|
|
$secpass_tooltip .= $secpass_body;
|
|
|
|
$selectedTheme = get_selected_theme();
|
|
|
|
if ($action == 'formidentity') {
|
|
$title_message = __('Please enter your Cacti username or email address.');
|
|
} elseif ($action == 'formreset') {
|
|
$title_message = __('Please enter your new Cacti password.');
|
|
} else {
|
|
$title_message = __('Reset password problem.');
|
|
}
|
|
|
|
html_auth_header('reset_password', __('Reset Password'), __('Reset Password'), $title_message);
|
|
?>
|
|
|
|
<?php if ($action == 'formidentity') { ?>
|
|
<tr>
|
|
<td class='nowrap' colspan='2'>
|
|
<label for='identity'><?php print __esc('Username'); ?></label>
|
|
<input type='text' class='ui-state-default ui-corner-all' id='identity' name='identity' size='25' maxlength='50'></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' class='nowrap'>
|
|
<button type='submit' class='ui-button ui-corner-all ui-widget ui-state-active' value='send'><?php print __esc('Send reset token by email'); ?></button>
|
|
<button type='button' class='ui-button ui-corner-all ui-widget' onClick='document.location=<?php print json_encode((string) $return); ?>' value='return'><?php print __esc('Return'); ?></button>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2'>
|
|
<input type='hidden' name='action' value='resetrequest'>
|
|
<input type='hidden' name='hash' value='<?php print htmlerv('hash'); ?>'>
|
|
</td>
|
|
</tr>
|
|
<?php }
|
|
|
|
if ($action == 'formreset') {?>
|
|
<tr>
|
|
<td><label for='password'><?php print __('New password'); ?></label></td>
|
|
<td class='nowrap'>
|
|
<input type='password' class='ui-state-default ui-corner-all' id='password' name='password' autocomplete='off' size='15' maxlength='25' placeholder='********'><?php print display_tooltip($secpass_tooltip); ?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><label for='password_confirm'><?php print __('Confirm password'); ?></label></td>
|
|
<td class='nowrap'>
|
|
<input type='password' class='ui-state-default ui-corner-all' id='password_confirm' name='password_confirm' autocomplete='off' size='15' maxlength='25' placeholder='********'>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' class='nowrap'>
|
|
<button type='submit' class='ui-button ui-corner-all ui-widget ui-state-active' value='save'><?php print __esc('Save'); ?></button>
|
|
<button type='button' class='ui-button ui-corner-all ui-widget' onClick='document.location=<?php print json_encode((string) $return); ?>' value='return'><?php print __esc('Return'); ?></button>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2'>
|
|
<input type='hidden' name='action' value='resetpassword'>
|
|
<input type='hidden' name='hash' value='<?php print htmlerv('hash'); ?>'>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
$secpass_minlen = read_config_option('secpass_minlen');
|
|
|
|
html_auth_footer('reset_password', $errorMessage, "
|
|
<script type='text/javascript'>
|
|
|
|
$(function() {
|
|
if ($('#identity').length) {
|
|
$('#identity').focus();
|
|
} else {
|
|
$('#password').focus();
|
|
}
|
|
|
|
/* clear passwords */
|
|
$('#password').val('');
|
|
$('#password_confirm').val('');
|
|
});
|
|
</script>");
|