Skip to content

Commit

Permalink
Fixed API password change to match the user in wazuh.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bordon committed Sep 26, 2024
1 parent 0e5b606 commit b5a0915
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions passwords_tool/passwordsFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b5a0915

Please sign in to comment.