Skip to content

Commit e37848c

Browse files
committed
SElinux context for /etc/redis/sentinel.conf* files
Add redis_conf_t Restore context in case file was recreated
1 parent 113cf80 commit e37848c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

configs/redis-sentinel.service

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Documentation=http://redis.io/documentation
55

66
[Service]
77
Type=notify
8+
# Try to restore context for sentinel.conf* as sentinel needs to write into these files
9+
ExecStartPre=-/bin/sh -c "[ -x /sbin/restorecon ] && /sbin/restorecon '/etc/redis/sentinel.conf*'"
810
ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel.conf
911
TimeoutStopSec=0
1012
Restart=always
@@ -22,6 +24,8 @@ ReadOnlyDirectories=/
2224
ReadWriteDirectories=-/var/lib/redis
2325
ReadWriteDirectories=-/var/log/redis
2426
ReadWriteDirectories=-/run/sentinel
27+
# To run restorecon in ExecStartPre
28+
PermissionsStartOnly=yes
2529

2630
NoNewPrivileges=true
2731
CapabilityBoundingSet=CAP_SYS_RESOURCE

scripts/postinstall.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ if command -v checkmodule &> /dev/null && command -v semodule_package &> /dev/nu
1010
semodule -i /usr/share/selinux/packages/redis-ce.pp
1111
fi
1212

13+
# Allow writing to /etc/redis/sentinel.conf* for redis-sentinel
14+
if command -v semanage &> /dev/null; then
15+
semanage fcontext -a -t redis_conf_t '/etc/redis/sentinel.conf*'
16+
fi
17+
1318
#
1419
# Handle service setup
1520
# $1 will be 1 for initial install and 2 for upgrade

0 commit comments

Comments
 (0)