Bug 751427

Summary: ypinit incorrectly identifies domainname when none is set.
Product: [Fedora] Fedora Reporter: Shannon Petry <shannon.petry>
Component: ypservAssignee: Honza Horak <hhorak>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 15CC: hhorak, kklic
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: ypserv-2.26-8.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-10 19:39:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Modified ypinit script none

Description Shannon Petry 2011-11-04 17:16:59 UTC
Description of problem: ypinit does not properly detect cases where a domainname is not set.  


Version-Release number of selected component (if applicable):ypbind-1.32-8.fc15.1


How reproducible: do not set domain name, or unset domain name.  run "ypinit -m".  Directory structure called "(none)" shows in /var/yp, domainname returns "(none)"


Steps to Reproduce:
1.  Vanilla System
2.  Run "ypinit -m"
3.  Test "domainname" and directory structure in /var/yp
  
Actual results: domainname returns "(none)", maps will attempt to be built under "(none)" directory in /var/yp.


Expected results:  ypinit should exit with the proper message of "Domain Name not set"


Additional info:  Will submit updated script to package owner possibly correcting the issue.

Comment 1 Shannon Petry 2011-11-04 17:51:25 UTC
[spetry@nyfinhost1 ~]$ git diff ypinit ./ypinit
diff --git a/ypinit b/ypinit
index 3c0dc1c..c76c849 100755
--- a/ypinit
+++ b/ypinit
@@ -149,15 +149,14 @@ then
        exit 1
 fi

-DOMAIN=`domainname`
-if [ $? -ne 0 ]
-then
-       echo "Can't find domainname. Please fix your PATH"
+if [ -x /bin/domainname ] ; then
+       DOMAIN=`domainname`
+else
+       echo "'domainname' command not found. Exiting."
        exit 1
 fi

-if [ -z "$DOMAIN" ]
-then
+if [ "${DOMAIN}x" = "x" ] || [ "${DOMAIN}" = "(none)" ] ; then
        echo "The local host's domain name hasn't been set.  Please set it."
        exit 1
 fi

Comment 2 Shannon Petry 2011-11-04 17:59:22 UTC
Created attachment 531826 [details]
Modified ypinit script

diff is included in comments.

Comment 3 Shannon Petry 2011-11-04 22:48:01 UTC
It would be relatively easy for me to change the ypinit script to read in /etc/sysconfig/network to determine if NISDOMAIN or YPDOMAIN is set.  An option of setting the domain name inside the script could be presented to the user.

In addition, I would also be able to add functionality to the ypinit script to update the NISDOMAIN in /etc/sysconfig/network, similar to Sun's original functionality with ypinit where an /etc/defaultdomain is created.  This would record the settings for next boot without manual intervention.

Please let me know if you want me to proceed with the additions.

Comment 4 Honza Horak 2011-11-25 14:48:04 UTC
Hi Shannon, 

thanks for the suggested fix. I've already applied the following change into Rawhide and will update it in f16 soon:

-if [ -z "$DOMAIN" ]
+if [ "${DOMAIN}x" = "x" ] || [ "${DOMAIN}" = "(none)" ]

However, I don't think it is really necessary to apply the other one, since I don't see any use case when it should help something. If you do, describe the use case a bit, please.

Comment 5 Fedora Update System 2011-11-28 09:53:33 UTC
ypserv-2.26-7.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/ypserv-2.26-7.fc16

Comment 6 Fedora Update System 2011-11-28 11:15:24 UTC
ypserv-2.24-6.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/ypserv-2.24-6.fc15

Comment 7 Fedora Update System 2011-11-28 11:47:46 UTC
ypserv-2.26-8.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/ypserv-2.26-8.fc16

Comment 8 Fedora Update System 2011-11-29 00:08:25 UTC
Package ypserv-2.26-8.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing ypserv-2.26-8.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-16503/ypserv-2.26-8.fc16
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2011-12-10 19:39:09 UTC
ypserv-2.24-6.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2011-12-10 19:45:29 UTC
ypserv-2.26-8.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.