dhcp/init-server: restorecon for dhcpd*.leases

dhcp-server fails to start with avc denied error:

  avc: denied { read } for pid=571 comm="dhcpd" \
  name="dhcpd.leases" dev="hda" ino=63911 \
  scontext=system_u:system_r:dhcpd_t:s0-s15:c0.c1023 \
  tcontext=system_u:object_r:dhcp_state_t:s0 tclass=file

The type for dhcpd.leases is not correct, just fix it before dhcp-
server started.

Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
Signed-off-by: Xin Ouyang <xin.ouyang@windriver.com>
This commit is contained in:
Wenzong Fan 2014-06-15 21:38:38 -04:00 committed by Xin Ouyang
parent f210f90cc8
commit da44a14831

View File

@ -15,11 +15,19 @@ fi
# should listen on.)
. /etc/default/dhcp-server
# Restorecon for /var/lib/dhcp/{dhcpd.leases,dhcpd6.leases}
restorecon_dhcpd_leases(){
test ! -x /sbin/restorecon || for x in dhcpd.leases dhcpd6.leases; do
[ -f /var/lib/dhcp/$x ] && /sbin/restorecon -F /var/lib/dhcp/$x
done
}
case "$1" in
start)
echo -n "Starting DHCP server: "
test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/
test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases
restorecon_dhcpd_leases
start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES
echo "."
;;