Skip to contentSkip to conversation

restorecond init cleanup

PATCH In review Steve G 2 participants 2 messages Feb 27, 2007 – Mar 1, 2007 SELinux security module

lore
Share & tools
lore

Steve G

author
#0 lore raw

PATCH 1/1 restorecond init cleanup

Hi,

The following patch changes restorecond to follow LSB return codes and most importantly, start after the audit daemon so that anything it changes gets recorded.

____________________________________________________________________________________
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile. Get started!
http://mobile.yahoo.com/services?promote=mail

restorecond/restorecond.init +34 -8
diff -ur policycoreutils-2.0.6.orig/restorecond/restorecond.init policycoreutils-2.0.6/restorecond/restorecond.init
@@ -1,43 +1,68 @@
 #!/bin/sh
 #
-# restorecond:		Daemo used to maintain path file context
+# restorecond:		Daemon used to maintain path file context
 #
-# chkconfig:	2345 10 90
+# chkconfig:	2345 12 87
 # description:	restorecond uses inotify to look for creation of new files \
 # listed in the /etc/selinux/restorecond.conf file, and restores the \
 # correct security context.
 #
+# processname: /usr/sbin/restorecond
+# config: /etc/selinux/restorecond.conf 
+# pidfile: /var/run/restorecond.pid
+#
+# Return values according to LSB for all commands but status:
+# 0 - success
+# 1 - generic or unspecified error
+# 2 - invalid or excess argument(s)
+# 3 - unimplemented feature (e.g. "reload")
+# 4 - insufficient privilege
+# 5 - program is not installed
+# 6 - program is not configured
+# 7 - program is not running
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 0
 
+# Check that we are root ... so non-root users stop here
+test $EUID = 0  || exit 4
+
+test -x /usr/sbin/restorecond  || exit 5
+test -f /etc/selinux/restorecond.conf  || exit 6
+
+RETVAL=0
+
 start() 
 {
         echo -n $"Starting restorecond: "
+	unset HOME MAIL USER USERNAME
         daemon /usr/sbin/restorecond 
-
+	RETVAL=$?
 	touch /var/lock/subsys/restorecond
         echo
+	return $RETVAL
 }
 
 stop() 
 {
         echo -n $"Shutting down restorecond: "
 	killproc restorecond
-
+	RETVAL=$?
 	rm -f  /var/lock/subsys/restorecond
         echo
+	return $RETVAL
 }
+
 restart() 
 {
     stop
     start
 }
 
-[ -f /usr/sbin/restorecond ] || exit 0
-
 # See how we were called.
 case "$1" in
   start)
@@ -57,7 +82,8 @@
 	;;
   *)
         echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
-        exit 1
+        RETVAL=3
 esac
 
-exit 0
+exit $RETVAL
+
#1 lore raw
Quoted 9 lines · Steve G

Hi,

The following patch changes restorecond to follow LSB return codes and most importantly, start after the audit daemon so that anything it changes gets recorded.

Thanks - merged into trunk and stable.

Quoted 5 lines

____________________________________________________________________________________
Never Miss an Email
Stay connected with Yahoo! Mail on your mobile. Get started!
http://mobile.yahoo.com/services?promote=mail

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.