rpms/ypbind/devel ypbind.init,1.16,1.17 ypbind.spec,1.40,1.41

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Apr 17 19:51:00 UTC 2007


Author: steved

Update of /cvs/dist/rpms/ypbind/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv11502

Modified Files:
	ypbind.init ypbind.spec 
Log Message:
- Changed init script to look in /etc/yp.conf for the
  domain name when not already set. (bz 113386)
- Reworked init script to eliminate unreasonable
  hangs when ypbind cannot bind to nis server. (bz 112770)



Index: ypbind.init
===================================================================
RCS file: /cvs/dist/rpms/ypbind/devel/ypbind.init,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ypbind.init	17 Apr 2007 13:18:53 -0000	1.16
+++ ypbind.init	17 Apr 2007 19:50:58 -0000	1.17
@@ -22,14 +22,16 @@
 # Check for and source configuration file otherwise set defaults
 [ -f /etc/sysconfig/ypbind ] && . /etc/sysconfig/ypbind
 
-[ -z "$NISTIMEOUT" ] && NISTIMEOUT=20
+# NISTIMEOUT should be a multiple of 15 since
+# ypwhich has a hardcoded 15sec timeout
+[ -z "$NISTIMEOUT" ] && NISTIMEOUT=45
 
 # Check that networking is configured.
 [ "${NETWORKING}" = "no" ] && exit 0
 
 selinux_on() {
         [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || return
-	echo $"Turning on allow_ypbind SELinux boolean"
+	#echo $"Turning on allow_ypbind SELinux boolean"
         setsebool allow_ypbind=1
 }
 
@@ -41,7 +43,7 @@
 		. /etc/selinux/${SELINUXTYPE}/modules/active/booleans.local
 	fi
 	if [ $allow_ypbind == 0 ]; then
-		echo $"Turning off allow_ypbind SELinux boolean"
+		#echo $"Turning off allow_ypbind SELinux boolean"
 		setsebool allow_ypbind=$allow_ypbind
 	fi
 }
@@ -49,63 +51,79 @@
 start() {
 	DOMAINNAME=`domainname`
 	if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
-	   if [ -n "$NISDOMAIN" ]; then
-		action $"Setting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN
-	   else
-	        exit 1
-	   fi
+		echo -n $"Setting  NIS domain: "
+		if [ -n "$NISDOMAIN" ]; then
+			action $"domain is '$NISDOMAIN' " domainname $NISDOMAIN
+		else # See if the domain is set in config file
+			NISDOMAIN=`grep "domain" /etc/yp.conf | grep -v ^# | \
+				awk '{print $2}'`
+	   		if [ -n "$NISDOMAIN" ]; then
+				action $"domain is '$NISDOMAIN' " \
+					domainname $NISDOMAIN
+	   		else
+				action $"domain not found" /bin/false
+				logger -t ypbind $"domain not found"
+	        		return 1
+			fi
+		fi
 	fi
-        selinux_on
-	echo -n $"Binding to the NIS domain: "
+	echo -n $"Starting NIS service: "
+	selinux_on
 	daemon ypbind $OTHER_YPBIND_OPTS
 	RETVAL=$?
 	echo
 	if [ $RETVAL -ne 0 ]; then
 	    selinux_off
+	    logger -t ypbind "failed to start!"
 	    return $RETVAL
 	fi
+	echo -n $"Binding  NIS service: "
 	# the following fixes problems with the init scripts continuing
 	# even when we are really not bound yet to a server, and then things
 	# that need NIS fail.
-	echo -n $"Listening for an NIS domain server."
-	for (( times = 1; times < $NISTIMEOUT; times++ )); do
-	    /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind && ypwhich > /dev/null 2>&1
+	timeout=$NISTIMEOUT
+	while [ $timeout -gt 0 ]; do
+	    /usr/sbin/rpcinfo -p | LC_ALL=C fgrep -q ypbind && \
+			/usr/bin/ypwhich > /dev/null 2>&1
 	    RETVAL=$?
 	    if [ $RETVAL -eq 0 ]; then
 		break;
 	    fi
-	    sleep 1
-	    echo -n "."
+	    echo -n "..."
+	    # ypwhich has a hardcode 15sec timeout
+	    # so subtract that from NISTIMEOUT to
+	    # to see of we should continue to wait
+	    timeout=`expr $timeout - 15` 
 	done
 	if [ $RETVAL -eq 0 ]; then
-	    logger -t ypbind "bound to NIS server `ypwhich 2> /dev/null`"
+	    logger -t ypbind \
+	    	"NIS domain: `domainname`, NIS server: `ypwhich 2> /dev/null`"
 	    touch /var/lock/subsys/ypbind
+	    success
 	else
-	    killproc ypbind
-	    # if  we used brute force (like kill -9) we don't want those around
-	    if [ x$(domainname) != x ] ; then
-		rm -f /var/yp/binding/$(domainname)*
-	    fi
-	    failure "attempting to contact yp server"
+	    logger -t ypbind \
+	    	"NIS server for domain `domainname` is not responding."
+	    failure
 	    selinux_off
+		RETVAL=100
 	fi
 	echo
 	return $RETVAL
 }
 
 stop() {
-	echo -n $"Shutting down NIS services: "
+	echo -n $"Shutting down NIS service: "
 	killproc ypbind
 	RETVAL=$?
 	if [ $RETVAL -eq 0 ] ; then
-	  rm -f /var/lock/subsys/ypbind
-	  # if  we used brute force (like kill -9) we don't want those around
-	  if [ x$(domainname) != x ] ; then
-	    rm -f /var/yp/binding/$(domainname)*
-	  fi
+		rm -f /var/lock/subsys/ypbind
+		# if  we used brute force (like kill -9) we don't want those around
+		if [ x$(domainname) != x ] ; then
+			rm -f /var/yp/binding/$(domainname)*
+		fi
 	fi
 	echo
-       	selinux_off
+	selinux_off
 	return $RETVAL
 }
 
@@ -119,7 +137,8 @@
 # See how we were called.
 case "$1" in
   start)
-	start
+	start 
+	[ $? -eq 100 ] && stop
 	;;
   stop)
 	stop


Index: ypbind.spec
===================================================================
RCS file: /cvs/dist/rpms/ypbind/devel/ypbind.spec,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ypbind.spec	17 Apr 2007 13:18:53 -0000	1.40
+++ ypbind.spec	17 Apr 2007 19:50:58 -0000	1.41
@@ -92,6 +92,10 @@
 %changelog
 * Tue Apr 17 2007 Steve Dickson <steved at redhat.com> - 3:1.19-9
 - Fixed typo in init script (bz 233459)
+- Changed init script to look in /etc/yp.conf for the
+  domain name when not already set. (bz 113386)
+- Reworked init script to eliminate unreasonable
+  hangs when ypbind cannot bind to nis server. (bz 112770)
 
 * Tue Apr  3 2007 Steve Dickson <steved at redhat.com> - 3:1.19-8
 - Replace portmap dependency with an rpcbind dependency (bz 228894)




More information about the fedora-cvs-commits mailing list