Skip to content

Commit 68baf40

Browse files
maipbuipull[bot]
authored andcommitted
[database] make Redis process runs as non-root user (sonic-net#16326)
Why I did it Running the Redis server as the "root" user is not recommended. It is suggested that the server should be operated by a non-privileged user. Work item tracking Microsoft ADO (number only): 15895240 How I did it Ensure the Redis process is operating under the 'redis' user in supervisord and make redis user own REDIS_DIR inside db container. How to verify it Built new image, verify redis process is running as 'redis' user and all containers are up. Signed-off-by: Mai Bui <[email protected]>
1 parent 34676f7 commit 68baf40

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

dockers/docker-database/docker-database-init.sh

+2
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@ TZ=$(cat /etc/timezone)
9999
rm -rf /etc/localtime
100100
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
101101

102+
chown -R redis:redis $REDIS_DIR
103+
102104
exec /usr/local/bin/supervisord

dockers/docker-database/supervisord.conf.j2

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependent_startup=true
3838
{%- endif -%}
3939
command=/bin/bash -c "{ [[ -s /var/lib/{{ redis_inst }}/dump.rdb ]] || rm -f /var/lib/{{ redis_inst }}/dump.rdb; } && mkdir -p /var/lib/{{ redis_inst }} && exec /usr/bin/redis-server /etc/redis/redis.conf --bind {{ LOOPBACK_IP }} {{ redis_items['hostname'] }} --port {{ redis_items['port'] }} --unixsocket {{ redis_items['unix_socket_path'] }} --pidfile /var/run/redis/{{ redis_inst }}.pid --dir /var/lib/{{ redis_inst }}"
4040
priority=2
41+
user=redis
4142
autostart=false
4243
autorestart=false
4344
stdout_logfile=syslog

0 commit comments

Comments
 (0)