[meta-lsi] [PATCH 38/86] nis: fix ypdomainname configuration in ypbind init script

Daniel Dragomir daniel.dragomir at windriver.com
Wed Oct 29 08:35:46 PDT 2014


From: "Hong H. Pham" <hong.pham at windriver.com>

ypdomainname could return "" or "(none)" if the domain name is not
configured.  The ypbind init script does not check for "(none)" at
start up, so it thinks that the domain name is already configured.
The end result is that the domain name is not set per /etc/defaultdomain
and NIS initialialization fails.

Signed-off-by: Hong H. Pham <hong.pham at windriver.com>
---
 recipes-support/nis/files/ypbind-yocto.init | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/recipes-support/nis/files/ypbind-yocto.init b/recipes-support/nis/files/ypbind-yocto.init
index 5f50a53..e417b25 100644
--- a/recipes-support/nis/files/ypbind-yocto.init
+++ b/recipes-support/nis/files/ypbind-yocto.init
@@ -26,19 +26,35 @@ pidfile=/var/run/ypbind.pid
 
 [ -f /etc/default/ypbind ] && . /etc/default/ypbind
 
+
+function _ypdomainname_is_set() {
+    _ypdomainname="`/bin/ypdomainname 2>/dev/null`"
+ 
+    if test $? -ne 0 ; then
+        return 0
+    fi
+ 
+    if test "x${_ypdomainname}" = "x" -o "x${_ypdomainname}" = "x(none)"; then
+        return 0
+    fi
+
+    return 1
+}
+
+
 case "$1" in
     start)
 	echo -n "Starting ypbind"
 	## If the domainname is not set, skip starting of ypbind
 	## and return with "program not configured"
-        /bin/ypdomainname &> /dev/null
-        if [ $? -ne 0 -o -z "`/bin/ypdomainname 2>/dev/null`" ]; then
+	_ypdomainname_is_set
+	if [ $? -eq 0 ]; then
            if [ -f /etc/defaultdomain ]; then
              XDOMAINNAME=`cat /etc/defaultdomain`
              /bin/ypdomainname "$XDOMAINNAME"
 	   fi
-           /bin/ypdomainname &> /dev/null
-           if [ $? -ne 0 -o -z "`/bin/ypdomainname 2>/dev/null`" ]; then
+           _ypdomainname_is_set
+           if [ $? -eq 0 ]; then
 	     # Tell the user this has skipped
 	     echo -n " . . . . . . . . . . No domainname set"
              # service is not configured
-- 
1.8.1.4



More information about the meta-lsi mailing list