Skip to content

Commit

Permalink
Improved the update of the internal_users.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcr01 committed Sep 18, 2023
1 parent 6e316c2 commit 80090d8
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions unattended_installer/passwords_tool/passwordsFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 80090d8

Please sign in to comment.