common/rc: fix check for yp
authorJohannes Thumshirn <jthumshirn@suse.de>
Fri, 12 Oct 2018 11:50:55 +0000 (13:50 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Oct 2018 14:26:47 +0000 (22:26 +0800)
Only testing if a domainname is set and ypcat is installed is not a
sufficient criteria to check if NIS is actually active.

Check for a running ypbind in rpcinfo as well.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc

index f7d0c35..38d9de7 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1991,7 +1991,9 @@ _yp_active()
        local dn
        dn=$(domainname 2>/dev/null)
        local ypcat=$(type -P ypcat)
-       test -n "${dn}" -a "${dn}" != "(none)" -a "${dn}" != "localdomain" -a -n "${ypcat}"
+       local rpcinfo=$(type -P rpcinfo)
+       test -n "${dn}" -a "${dn}" != "(none)" -a "${dn}" != "localdomain" -a -n "${ypcat}" -a -n "${rpcinfo}" && \
+               "${rpcinfo}" -p localhost 2>/dev/null | grep -q ypbind
        echo $?
 }