Allow special character inside redis password

pull/176/head
Stefano Ortolani 2024-10-28 11:37:17 +00:00
parent f23186129b
commit 3855224c7c
3 changed files with 7 additions and 5 deletions

View File

@ -9,6 +9,7 @@ term_proc() {
trap term_proc SIGTERM trap term_proc SIGTERM
change_php_vars() { change_php_vars() {
ESCAPED=$(printf '%s\n' "$REDIS_PASSWORD" | sed -e 's/[\/&]/\\&/g')
for FILE in /etc/php/*/fpm/php.ini for FILE in /etc/php/*/fpm/php.ini
do do
[[ -e $FILE ]] || break [[ -e $FILE ]] || break
@ -23,8 +24,8 @@ change_php_vars() {
echo "Configure PHP | Setting 'max_input_time = ${PHP_MAX_INPUT_TIME}'" echo "Configure PHP | Setting 'max_input_time = ${PHP_MAX_INPUT_TIME}'"
sed -i "s/max_input_time = .*/max_input_time = ${PHP_MAX_INPUT_TIME}/" "$FILE" sed -i "s/max_input_time = .*/max_input_time = ${PHP_MAX_INPUT_TIME}/" "$FILE"
sed -i "s/session.save_handler = .*/session.save_handler = redis/" "$FILE" sed -i "s/session.save_handler = .*/session.save_handler = redis/" "$FILE"
echo "Configure PHP | Setting 'session.save_path = '$(echo $REDIS_HOST | grep -E '^\w+://' || echo tcp://$REDIS_HOST):6379?auth=${REDIS_PASSWORD}'" echo "Configure PHP | Setting 'session.save_path = '$(echo $REDIS_HOST | grep -E '^\w+://' || echo tcp://$REDIS_HOST):$REDIS_PORT?auth=${ESCAPED}'"
sed -i "s|.*session.save_path = .*|session.save_path = '$(echo $REDIS_HOST | grep -E '^\w+://' || echo tcp://$REDIS_HOST):6379?auth=${REDIS_PASSWORD}'|" "$FILE" sed -i "s|.*session.save_path = .*|session.save_path = '$(echo $REDIS_HOST | grep -E '^\w+://' || echo tcp://$REDIS_HOST):$REDIS_PORT?auth=${ESCAPED}'|" "$FILE"
sed -i "s/session.sid_length = .*/session.sid_length = 64/" "$FILE" sed -i "s/session.sid_length = .*/session.sid_length = 64/" "$FILE"
sed -i "s/session.use_strict_mode = .*/session.use_strict_mode = 1/" "$FILE" sed -i "s/session.use_strict_mode = .*/session.use_strict_mode = 1/" "$FILE"
done done

View File

@ -13,9 +13,9 @@ services:
redis: redis:
image: valkey/valkey:7.2 image: valkey/valkey:7.2
command: "--requirepass ${REDIS_PASSWORD:-redispassword}" command: "--requirepass '${REDIS_PASSWORD:-redispassword}'"
healthcheck: healthcheck:
test: "valkey-cli -a ${REDIS_PASSWORD:-redispassword} ping || exit 1" test: "valkey-cli -a '${REDIS_PASSWORD:-redispassword}' -p ${REDIS_PORT:-6379} ping | grep -q PONG || exit 1"
interval: 2s interval: 2s
timeout: 1s timeout: 1s
retries: 3 retries: 3

View File

@ -83,9 +83,10 @@ SYNCSERVERS_1_PULL_RULES=
# MYSQL_ROOT_PASSWORD= # MYSQL_ROOT_PASSWORD=
# MYSQL_DATABASE= # MYSQL_DATABASE=
# optional and used to set redis password # optional and used to set redis
# REDIS_HOST= # REDIS_HOST=
# REDIS_PORT= # REDIS_PORT=
# remember to escape special character '$', e.g., 'test1%<$1323>' becomes 'test1%<$$1323>'
# REDIS_PASSWORD= # REDIS_PASSWORD=
# These variables allows overriding some MISP email values. # These variables allows overriding some MISP email values.