From 0fb3f74120d5f407fd156147503d337a6c1d4577 Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Fri, 15 Oct 2010 16:25:05 -0400 Subject: [PATCH] Initscripts do not conform to LSB specification (bz 621562) Signed-off-by: Steve Dickson --- nfs-utils.spec | 5 ++++- nfs.init | 49 +++++++++++++++++++++++++++++++++---------------- nfslock.init | 29 ++++++++++++++++++----------- rpcgssd.init | 23 +++++++++++++++-------- rpcidmapd.init | 17 ++++++++++++----- rpcsvcgssd.init | 22 ++++++++++++++-------- 6 files changed, 96 insertions(+), 49 deletions(-) diff --git a/nfs-utils.spec b/nfs-utils.spec index 71fecc0..c22632d 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser Name: nfs-utils URL: http://sourceforge.net/projects/nfs Version: 1.2.3 -Release: 0.1%{?dist} +Release: 2%{?dist} Epoch: 1 # group all 32bit related archs @@ -251,6 +251,9 @@ fi %attr(4755,root,root) /sbin/umount.nfs4 %changelog +* Fri Oct 15 2010 Steve Dickson 1.2.3-2 +- Initscripts do not conform to LSB specification (bz 621562) + * Thu Oct 14 2010 Steve Dickson 1.2.3-1 - Updated to latest upstream release: nfs-utils-1-2-4-rc1 diff --git a/nfs.init b/nfs.init index 6e9d691..5be95f4 100755 --- a/nfs.init +++ b/nfs.init @@ -12,7 +12,7 @@ ### BEGIN INIT INFO # Provides: nfs -# Required-Start: $local_fs $network $syslog +# Required-Start: $local_fs $network $syslog $portmap # Required-Stop: $local_fs $network $syslog # Default-Stop: 0 1 6 # Short-Description: Start up the NFS server sevice @@ -35,6 +35,7 @@ [ -z "$RQUOTAD" ] && RQUOTAD=`type -path rpc.rquotad` RETVAL=0 +uid=`id | cut -d\( -f1 | cut -d= -f2` # See how we were called. case "$1" in @@ -52,6 +53,9 @@ case "$1" in exit 0 fi + # Only root can start the service + [ $uid -ne 0 ] && exit 4 + # Don't fail if /etc/exports doesn't exist; create a bare-bones # version and continue. [ -r /etc/exports ] || \ @@ -119,24 +123,32 @@ case "$1" in daemon rpc.mountd $RPCMOUNTDOPTS RETVAL=$? echo - touch /var/lock/subsys/nfs + touch /var/lock/subsys/rpc.mountd + touch /var/lock/subsys/nfsd # Let rpc.idmapd know that rpc.mountd just started [ -x /usr/sbin/rpc.idmapd ] && /sbin/service rpcidmapd condstart ;; stop) + # Only root can stop the service + [ $uid -ne 0 ] && exit 4 + # Stop daemons. echo -n $"Shutting down NFS mountd: " killproc rpc.mountd + RETVAL=$? echo echo -n $"Shutting down NFS daemon: " killproc nfsd -2 + rval=$? + [ $RETVAL -eq 0 ] && RETVAL=$rval echo if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then echo -n $"Shutting down NFS quotas: " killproc rpc.rquotad - RETVAL=$? + rval=$? + [ $RETVAL -eq 0 ] && RETVAL=$rval echo fi # Reset the lockd ports if they were set @@ -151,31 +163,36 @@ case "$1" in cnt=`/usr/sbin/exportfs -v | /usr/bin/wc -l` if [ $cnt -gt 0 ]; then action $"Shutting down NFS services: " /usr/sbin/exportfs -au - else - action $"Shutting down NFS services: " /bin/false + rval=$? + [ $RETVAL -eq 0 ] && RETVAL=$rval fi [ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd stop - rm -f /var/lock/subsys/nfs + rm -f /var/lock/subsys/nfsd + rm -f /var/lock/subsys/rpc.mountd ;; status) [ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd status status rpc.mountd + RETVAL=$? status nfsd + rval=$? + [ $RETVAL -eq 0 ] && RETVAL=$rval if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then status rpc.rquotad + rval=$? + [ $RETVAL -eq 0 ] && RETVAL=$rval fi - RETVAL=$? ;; restart) $0 stop $0 start ;; - reload) + reload | force-reload) /usr/sbin/exportfs -r - touch /var/lock/subsys/nfs + touch /var/lock/subsys/nfsd ;; probe) - if [ ! -f /var/lock/subsys/nfs ] ; then + if [ ! -f /var/lock/subsys/nfsd ] ; then echo $"start"; exit 0 fi /sbin/pidof rpc.mountd >/dev/null 2>&1; MOUNTD="$?" @@ -183,13 +200,13 @@ case "$1" in if [ $MOUNTD = 1 -o $NFSD = 1 ] ; then echo $"restart"; exit 0 fi - if [ /etc/exports -nt /var/lock/subsys/nfs ] ; then + if [ /etc/exports -nt /var/lock/subsys/nfsd ] ; then echo $"reload"; exit 0 fi ;; - condrestart) + condrestart | try-restart) [ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condrestart - [ -f /var/lock/subsys/nfs ] && { + [ -f /var/lock/subsys/nfsd ] && { $0 stop $0 start RETVAL=$? @@ -197,14 +214,14 @@ case "$1" in ;; condstop) [ -x /usr/sbin/rpc.svcgssd ] && /sbin/service rpcsvcgssd condstop - [ -f /var/lock/subsys/nfs ] && { + [ -f /var/lock/subsys/nfsd ] && { $0 stop RETVAL=$? } ;; *) - echo $"Usage: nfs {start|stop|status|restart|reload|condrestart|condstop}" - RETVAL=3 + echo $"Usage: nfs {start|stop|status|restart|reload|force-reload|condrestart|try-restart|condstop}" + RETVAL=2 ;; esac diff --git a/nfslock.init b/nfslock.init index 71a9940..e914f1e 100755 --- a/nfslock.init +++ b/nfslock.init @@ -11,7 +11,7 @@ ### BEGIN INIT INFO # Provides: nfslock -# Required-Start: $network $syslog +# Required-Start: $network $syslog $portmap # Required-Stop: $network $syslog # Default-Start: 3 4 5 # Default-Stop: 0 1 6 @@ -36,6 +36,7 @@ STATDARG="" [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network +uid=`id | cut -d\( -f1 | cut -d= -f2` RETVAL=0 start() { # Check that networking is up. @@ -43,11 +44,14 @@ start() { [ -x /sbin/rpc.statd ] || exit 5 + # Only root can start the service + [ $uid -ne 0 ] && exit 4 + # Make sure the rpc.statd is not already running. if status rpc.statd > /dev/null ; then exit 0 fi - rm -f /var/lock/subsys/nfslock + rm -f /var/lock/subsys/rpc.statd # Make sure locks are recovered rm -f /var/run/sm-notify.pid @@ -79,11 +83,14 @@ start() { daemon rpc.statd "$STATDARG" RETVAL=$? echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nfslock + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rpc.statd return $RETVAL } stop() { + # Only root can stop the service + [ $uid -ne 0 ] && exit 4 + # Stop daemons. if [ -n "`pidofproc lockd`" ]; then echo -n $"Stopping NFS locking: " @@ -95,7 +102,7 @@ stop() { killproc rpc.statd RETVAL=$? echo - rm -f /var/lock/subsys/nfslock + rm -f /var/lock/subsys/rpc.statd rm -f /var/run/sm-notify.pid return $RETVAL } @@ -112,12 +119,12 @@ case "$1" in status rpc.statd RETVAL=$? ;; - restart) + restart | force-reload | reload) stop start ;; probe) - if [ ! -f /var/lock/subsys/nfslock ] ; then + if [ ! -f /var/lock/subsys/rpc.statd ] ; then echo $"start"; exit 0 fi /sbin/pidof rpc.statd >/dev/null 2>&1 @@ -125,22 +132,22 @@ case "$1" in echo $"restart"; exit 0 fi ;; - condrestart) - [ -f /var/lock/subsys/nfslock ] && { + condrestart | try-restart) + [ -f /var/lock/subsys/rpc.statd ] && { stop start RETVAL=$? } ;; condstop) - [ -f /var/lock/subsys/nfslock ] && { + [ -f /var/lock/subsys/rpc.statd ] && { stop RETVAL=$? } ;; *) - echo $"Usage: $0 {start|stop|status|restart|probe|condrestart|condstop}" - RETVAL=3 + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|probe|condrestart|try-restart|condstop}" + RETVAL=2 ;; esac diff --git a/rpcgssd.init b/rpcgssd.init index 1b548a9..29b4954 100755 --- a/rpcgssd.init +++ b/rpcgssd.init @@ -27,19 +27,20 @@ # Check for and source configuration file otherwise set defaults [ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs -# See if we are configured to start -[ "${SECURE_NFS}" != "yes" ] && exit 6 - # Try to use machine credentials by default RETVAL=0 -LOCKFILE=/var/lock/subsys/rpcgssd +uid=`id | cut -d\( -f1 | cut -d= -f2` + prog="rpc.gssd" +LOCKFILE=/var/lock/subsys/$prog case "$1" in start|condstart) # Check that networking is up. [ "${NETWORKING}" != "yes" ] && exit 6 [ ! -x /usr/sbin/rpc.gssd ] && exit 5 + # Only root can start the service + [ $uid -ne 0 ] && exit 4 # Make sure the daemon is not already running. if status $prog > /dev/null ; then @@ -94,6 +95,12 @@ case "$1" in [ $RETVAL -eq 0 ] && touch $LOCKFILE ;; stop) + # Just exit if not configured + [ "${SECURE_NFS}" != "yes" ] && exit 6 + + # Only root can stop the service + [ $uid -ne 0 ] && exit 4 + # Stop daemon. echo -n $"Stopping RPC gssd: " killproc $prog @@ -105,12 +112,12 @@ case "$1" in status rpc.gssd RETVAL=$? ;; - restart|reload) + restart|reload|force-reload) $0 stop $0 start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f $LOCKFILE ]; then $0 restart RETVAL=$? @@ -123,8 +130,8 @@ case "$1" in fi ;; *) - echo $"Usage: $0 {start|stop|restart|condstart|condrestart|status|condstop}" - RETVAL=3 + echo $"Usage: $0 {start|stop|restart|force-reload|condstart|condrestart|try-restart|status|condstop}" + RETVAL=2 ;; esac diff --git a/rpcidmapd.init b/rpcidmapd.init index c944454..0ce1507 100755 --- a/rpcidmapd.init +++ b/rpcidmapd.init @@ -28,8 +28,9 @@ [ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs RETVAL=0 -LOCKFILE=/var/lock/subsys/rpcidmapd prog="rpc.idmapd" +LOCKFILE=/var/lock/subsys/$prog +uid=`id | cut -d\( -f1 | cut -d= -f2` case "$1" in start|condstart) @@ -38,6 +39,9 @@ case "$1" in [ ! -x /usr/sbin/rpc.idmapd ] && exit 5 + # Only root can start the service + [ $uid -ne 0 ] && exit 4 + # Make sure the daemon is not already running. [ "$1" = "condstart" -a -n "`pidofproc $prog`" ] && { killproc $prog "-SIGHUP" > /dev/null @@ -78,6 +82,9 @@ case "$1" in [ $RETVAL -eq 0 ] && touch $LOCKFILE ;; stop) + # Only root can stop the service + [ $uid -ne 0 ] && exit 4 + # Stop daemon. echo -n $"Stopping RPC idmapd: " killproc $prog @@ -89,12 +96,12 @@ case "$1" in status rpc.idmapd RETVAL=$? ;; - restart|reload) + restart|reload|force-reload) $0 stop $0 start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f $LOCKFILE ]; then $0 restart RETVAL=$? @@ -107,8 +114,8 @@ case "$1" in fi ;; *) - echo $"Usage: $0 {start|stop|restart|condstart|condrestart|status|condstop}" - RETVAL=3 + echo $"Usage: $0 {start|stop|restart|force-reload|condstart|condrestart|try-restart|status|condstop}" + RETVAL=2 ;; esac diff --git a/rpcsvcgssd.init b/rpcsvcgssd.init index 6f5659d..5f99b86 100755 --- a/rpcsvcgssd.init +++ b/rpcsvcgssd.init @@ -26,12 +26,10 @@ # Check for and source configuration file otherwise set defaults [ -f /etc/sysconfig/nfs ] && . /etc/sysconfig/nfs -# See if we are configured to start -[ "${SECURE_NFS}" != "yes" ] && exit 6 - RETVAL=0 -LOCKFILE=/var/lock/subsys/rpcsvcgssd prog="rpc.svcgssd" +LOCKFILE=/var/lock/subsys/$prog +uid=`id | cut -d\( -f1 | cut -d= -f2` case "$1" in start|condstart) @@ -39,6 +37,8 @@ case "$1" in [ "${NETWORKING}" != "yes" ] && exit 6 [ "${SECURE_NFS}" != "yes" ] && exit 6 [ ! -x /usr/sbin/rpc.svcgssd ] && exit 5 + # Only root can start the service + [ $uid -ne 0 ] && exit 4 # Make sure the daemon is not already running. if status $prog > /dev/null ; then @@ -91,6 +91,12 @@ case "$1" in [ $RETVAL -eq 0 ] && touch $LOCKFILE ;; stop) + # Just exit if not configured + [ "${SECURE_NFS}" != "yes" ] && exit 6 + + # Only root can stop the service + [ $uid -ne 0 ] && exit 4 + # Stop daemon. echo -n $"Shutting down RPC svcgssd: " killproc $prog @@ -102,12 +108,12 @@ case "$1" in status rpc.svcgssd RETVAL=$? ;; - restart|reload) + restart|reload|force-reload) $0 stop $0 start RETVAL=$? ;; - condrestart) + condrestart|try-restart) if [ -f $LOCKFILE ]; then $0 restart RETVAL=$? @@ -120,8 +126,8 @@ case "$1" in fi ;; *) - echo $"Usage: $0 {start|stop|restart|condstart|condrestart|status|condstop}" - RETVAL=3 + echo $"Usage: $0 {start|stop|restart|force-reload|condstart|condrestart|try-restart|status|condstop}" + RETVAL=2 ;; esac