From 6e316c209b6108d65586bda1683e51a452c302d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Fri, 15 Sep 2023 16:32:16 +0200 Subject: [PATCH 1/2] Update internal_users.yml file when changing passwords --- unattended_installer/passwords_tool/passwordsFunctions.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unattended_installer/passwords_tool/passwordsFunctions.sh b/unattended_installer/passwords_tool/passwordsFunctions.sh index bfd0c4b2a3..de3fc588d5 100644 --- a/unattended_installer/passwords_tool/passwordsFunctions.sh +++ b/unattended_installer/passwords_tool/passwordsFunctions.sh @@ -18,6 +18,8 @@ function passwords_changePassword() { do if [ -n "${indexer_installed}" ] && [ -f "/etc/wazuh-indexer/backup/internal_users.yml" ]; then awk -v new=${hashes[i]} 'prev=="'${users[i]}':"{sub(/\042.*/,""); $0=$0 new} {prev=$1} 1' /etc/wazuh-indexer/backup/internal_users.yml > internal_users.yml_tmp && mv -f internal_users.yml_tmp /etc/wazuh-indexer/backup/internal_users.yml + cp -f /etc/wazuh-indexer/backup/internal_users.yml /etc/wazuh-indexer/opensearch-security/internal_users.yml + chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch-security/internal_users.yml fi if [ "${users[i]}" == "admin" ]; then @@ -35,6 +37,8 @@ function passwords_changePassword() { fi if [ -n "${indexer_installed}" ] && [ -f "/etc/wazuh-indexer/backup/internal_users.yml" ]; then awk -v new="${hash}" 'prev=="'${nuser}':"{sub(/\042.*/,""); $0=$0 new} {prev=$1} 1' /etc/wazuh-indexer/backup/internal_users.yml > internal_users.yml_tmp && mv -f internal_users.yml_tmp /etc/wazuh-indexer/backup/internal_users.yml + cp -f /etc/wazuh-indexer/backup/internal_users.yml /etc/wazuh-indexer/opensearch-security/internal_users.yml + chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch-security/internal_users.yml fi if [ "${nuser}" == "admin" ]; then From 80090d82e0b6a427c423b8ed9701dcca6f3ee162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Mon, 18 Sep 2023 16:20:18 +0200 Subject: [PATCH 2/2] Improved the update of the internal_users.yml file --- unattended_installer/passwords_tool/passwordsFunctions.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/unattended_installer/passwords_tool/passwordsFunctions.sh b/unattended_installer/passwords_tool/passwordsFunctions.sh index de3fc588d5..78d1e346e4 100644 --- a/unattended_installer/passwords_tool/passwordsFunctions.sh +++ b/unattended_installer/passwords_tool/passwordsFunctions.sh @@ -18,8 +18,6 @@ function passwords_changePassword() { do if [ -n "${indexer_installed}" ] && [ -f "/etc/wazuh-indexer/backup/internal_users.yml" ]; then awk -v new=${hashes[i]} 'prev=="'${users[i]}':"{sub(/\042.*/,""); $0=$0 new} {prev=$1} 1' /etc/wazuh-indexer/backup/internal_users.yml > internal_users.yml_tmp && mv -f internal_users.yml_tmp /etc/wazuh-indexer/backup/internal_users.yml - cp -f /etc/wazuh-indexer/backup/internal_users.yml /etc/wazuh-indexer/opensearch-security/internal_users.yml - chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch-security/internal_users.yml fi if [ "${users[i]}" == "admin" ]; then @@ -37,8 +35,6 @@ function passwords_changePassword() { fi if [ -n "${indexer_installed}" ] && [ -f "/etc/wazuh-indexer/backup/internal_users.yml" ]; then awk -v new="${hash}" 'prev=="'${nuser}':"{sub(/\042.*/,""); $0=$0 new} {prev=$1} 1' /etc/wazuh-indexer/backup/internal_users.yml > internal_users.yml_tmp && mv -f internal_users.yml_tmp /etc/wazuh-indexer/backup/internal_users.yml - cp -f /etc/wazuh-indexer/backup/internal_users.yml /etc/wazuh-indexer/opensearch-security/internal_users.yml - chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch-security/internal_users.yml fi if [ "${nuser}" == "admin" ]; then @@ -607,6 +603,7 @@ function passwords_runSecurityAdmin() { common_logger -e "Could not load the changes." exit 1; fi + eval "cp /etc/wazuh-indexer/backup/internal_users.yml /etc/wazuh-indexer/opensearch-security/internal_users.yml" eval "rm -rf /etc/wazuh-indexer/backup/ ${debug}" if [[ -n "${nuser}" ]] && [[ -n ${autopass} ]]; then