This commit is contained in:
Jason Ertel
2024-10-23 16:49:02 -04:00
parent 4611ef3713
commit 5e6dd2e8b3
10 changed files with 114 additions and 3 deletions

View File

@@ -136,6 +136,7 @@ bcryptRounds=${BCRYPT_ROUNDS:-12}
elasticUsersFile=${ELASTIC_USERS_FILE:-/opt/so/saltstack/local/salt/elasticsearch/files/users}
elasticRolesFile=${ELASTIC_ROLES_FILE:-/opt/so/saltstack/local/salt/elasticsearch/files/users_roles}
socRolesFile=${SOC_ROLES_FILE:-/opt/so/conf/soc/soc_users_roles}
clientRolesFile=${SOC_ROLES_FILE:-/opt/so/conf/soc/soc_client_roles}
esUID=${ELASTIC_UID:-930}
esGID=${ELASTIC_GID:-930}
soUID=${SOCORE_UID:-939}
@@ -282,6 +283,18 @@ function ensureRoleFileExists() {
fi
mv "${rolesTmpFile}" "${socRolesFile}"
fi
if [[ ! -f "$clientRolesFile" || ! -s "$clientRolesFile" ]]; then
# Generate the new client roles file
rolesTmpFile="${clientRolesFile}.tmp"
createFile "$rolesTmpFile" "$soUID" "$soGID"
if [[ -d "$clientRolesFile" ]]; then
echo "Removing invalid roles directory created by Docker"
rm -fr "$clientRolesFile"
fi
mv "${rolesTmpFile}" "${clientRolesFile}"
fi
}
function syncElasticSystemUser() {
@@ -374,6 +387,9 @@ function syncElastic() {
[[ $? != 0 ]] && fail "Unable to read role identities from database"
done < "$socRolesFile"
# Append the client roles
cat "$clientRolesFile" >> "$rolesTmpFile"
else
echo "Database file or soc roles file does not exist yet, skipping users export"
fi