From b5a091591b55765c2a6f4a35b65453cdd0ab1069 Mon Sep 17 00:00:00 2001 From: c-bordon Date: Thu, 26 Sep 2024 16:19:40 -0300 Subject: [PATCH] Fixed API password change to match the user in wazuh.yml --- passwords_tool/passwordsFunctions.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/passwords_tool/passwordsFunctions.sh b/passwords_tool/passwordsFunctions.sh index 2316640..b1c884f 100644 --- a/passwords_tool/passwordsFunctions.sh +++ b/passwords_tool/passwordsFunctions.sh @@ -85,6 +85,7 @@ function passwords_changePassword() { function passwords_changePasswordApi() { #Change API password tool if [ -n "${changeall}" ]; then + wazuh_yml_user=$(awk '/- default:/ {found=1} found && /username:/ {print $2}' /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml) for i in "${!api_passwords[@]}"; do if [ -n "${wazuh_installed}" ]; then passwords_getApiUserId "${api_users[i]}" @@ -99,7 +100,7 @@ function passwords_changePasswordApi() { common_logger -nl $"The password for Wazuh API user ${api_users[i]} is ${api_passwords[i]}" fi fi - if [ "${api_users[i]}" == "wazuh-wui" ] && [ -n "${dashboard_installed}" ]; then + if [ "${api_users[i]}" == "${wazuh_yml_user}" ] && [ -n "${dashboard_installed}" ]; then passwords_changeDashboardApiPassword "${api_passwords[i]}" fi done @@ -112,7 +113,7 @@ function passwords_changePasswordApi() { common_logger -nl $"The password for Wazuh API user ${nuser} is ${password}" fi fi - if [ "${nuser}" == "wazuh-wui" ] && [ -n "${dashboard_installed}" ]; then + if [ "${nuser}" == "${wazuh_yml_user}" ] && [ -n "${dashboard_installed}" ]; then passwords_changeDashboardApiPassword "${password}" fi fi