1 #!/bin/sh 2 # 3 # restorecond: Daemon used to maintain path file context 4 # 5 # chkconfig: - 12 87 6 # description: restorecond uses inotify to look for creation of new files \ 7 # listed in the /etc/selinux/restorecond.conf file, and restores the \ 8 # correct security context. 9 # 10 # processname: /usr/sbin/restorecond 11 # config: /etc/selinux/restorecond.conf 12 # pidfile: /var/run/restorecond.pid 13 # 14 # Return values according to LSB for all commands but status: 15 # 0 - success 16 # 1 - generic or unspecified error 17 # 2 - invalid or excess argument(s) 18 # 3 - unimplemented feature (e.g. "reload") 19 # 4 - insufficient privilege 20 # 5 - program is not installed 21 # 6 - program is not configured 22 # 7 - program is not running 23 24 PATH=/sbin:/bin:/usr/bin:/usr/sbin 25 26 # Source function library. 27 . /etc/rc.d/init.d/functions 28 29 [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7 30 31 # Check that we are root ... so non-root users stop here 32 test $EUID = 0 || exit 4 33 34 test -x /usr/sbin/restorecond || exit 5 35 test -f /etc/selinux/restorecond.conf || exit 6 36 37 RETVAL=0 38 39 start() 40 { 41 echo -n $"Starting restorecond: " 42 unset HOME MAIL USER USERNAME 43 daemon /usr/sbin/restorecond 44 RETVAL=$? 45 touch /var/lock/subsys/restorecond 46 echo 47 return $RETVAL 48 } 49 50 stop() 51 { 52 echo -n $"Shutting down restorecond: " 53 killproc restorecond 54 RETVAL=$? 55 rm -f /var/lock/subsys/restorecond 56 echo 57 return $RETVAL 58 } 59 60 restart() 61 { 62 stop 63 start 64 } 65 66 # See how we were called. 67 case "$1" in 68 start) 69 start 70 ;; 71 stop) 72 stop 73 ;; 74 status) 75 status restorecond 76 RETVAL=$? 77 ;; 78 force-reload|restart|reload) 79 restart 80 ;; 81 condrestart) 82 [ -e /var/lock/subsys/restorecond ] && restart || : 83 ;; 84 *) 85 echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart}" 86 RETVAL=3 87 esac 88 89 exit $RETVAL 90