/etc/init.d/hostname should use $(cat /etc/hostname | cut -f 1 -d .) for the value of $myhost, and $(cat /etc/hostname | cut -f 2- -d ._) to set domainname. Setting hostname to the whole show is wrong. Reproducible: Always Steps to Reproduce: 1. 2. 3.
Created attachment 7843 [details] /etc/init.d/hostname Have a look if this one is fine, thanks.
No offense, but this breaks DNS resolving among things for me. Guys, can you have a look please ? Ill admit im not the best of network guru out there.
usually you have the domain in your /etc/resolv.conf and you have the host actually defined in your dns records or in your /etc/hosts ...
Right. Ok, I want to resolve this ... Mike, everything looks ok for you ? Should we export a DOMAINNAME as welL ?
problem: this breaks the default postfix configuration. It uses "gethostname" and expects a fully qualified domain name ( After using the new script I rebooted upon reboot, my mailserver started rejecting all mail as invalid relay, it was a good thing I was logwatching at the time for other reasons. ) Shouldn't hostname be fully qualified?
None of the Linux systems (RH, Slack, etc) I have seen returns the entire hostname with domainname from gethostname. On the other hand, Solaris 5.8 does. I have nothing else booted at the moment. I think sendmail pulls some stunt. See the (commented out) entry in the config file for the $j macro.
I have a few bugs because of this change. Is there a known fix ? How should we treat them ?
I don't know exactly how to fix this, but it is perfectly OK that "gethostname" does _not_ return a name including a domain part. A systems FQDN is defined as the resolved name returned by "gethostbyname" called for the hostname "gethostname" returns. Of course, for this to work there needs to be an entry like "192.168.0.1 host.fqdn host" in /etc/hosts or you need DNS/NIS up and working. If postfix does really use only gehtosname to get a FQDN, I propose it't time for asking a question on postfix-users or perhaps look at other distributions if their postfix-sources are patched. Setting the hostname could be simplified to writing only the unqualified hostname to /etc/hostname and only calling "hostname --file /etc/hostname". No, this should _not_ break stuff for carefully programmed applications. Correct me if I'm telling bullshit.
Grant, thoughts?
Please do also have a look at bugs 18158 and 18801. These problems derive from errors in the name resolution setup of particular users and are _not_ bugs in baselayout.
This is true but if domainname isn't set at all, other things break. This seems like a convenient place to set it.
Ok, should we split it then to use /etc/hostname to set the hostname, and /etc/domainname to set the domainname ? Currently it will split whatever is in /etc/hostname ...
There isn't really any point is there? But then again there isn't any difference. Nothing else reads /etc/hostname. I only did it from one file because that's what Slackware did, except I think it called it /etc/HOSTNAME at the time.
What do you mean with "if domainname isn't set at all, other things break"? And how do you _set_ a domainname? And why would you want to do that?
There is an equivalent call getdomainname which is used by some lazy programs to get the domain name of the machine, and an equivalent /bin/domainname. I don't remember what breaks since I got into the habit of setting it. I think it's mostly NIS related and I don't run NIS any more.
/bin/domainname is indeed only used for setting the NIS-domainname, at least for the distributions I checked. If we do not perform the necessary steps to setup NIS in baselayout, I suggest we don't call /bin/domainname with the domain part stored in /etc/hostname but instead remove the domain part from /etc/hostname. I don't know how NIS setup works on Gentoo, but I strongly assume it uses a different file to store the NIS-domain (/etc/defaultdomain comes to my mind). And again, domainname works nice even if you never set it explicitely - at least if your name resolution ist set up correctly. BTW - is there any native German speaker who reads this and whom I may contact in German? As you might have noticed, I have some problems expressing these technical things in English, sorry guys.
Try with C[XX]FLAGS="-march=i686 -O2 -pipe" .. or even just with -O2 ?
Err, whoops, too many bugs open =)
Ok, so how about just reverting like we did ? Things that are broke, works, and other things that are not, handle this as well ...
Created attachment 10770 [details] hostname I had found the same problem and modified the hostname file in this way and worked.
Ok, basically according to docs, etc, domainname is the NIS domain, and I think we should not touch it if NIS is not setup properly, and this the user will usually do (or this we rather expect to not make fatal decisions). What you guys are looking for, is what /bin/dnsdomainname gives. And this works fine if your /etc/hosts or /etc/resolv.conf is setup correctly. Whatever stuff that borks thus because we set hostname properly, we need to fix, or get upstream to fix. I will thus remove the domainname stuff from the hostname rc-script.
Anyhow, I think this can be closed, as the next baselayout will properly fix this.
i think /etc/init.d/hostname is trying to be more clever than it should be. if i put the FQDN in /etc/hostname, thats what i want the hostname to be. if i put a single name in there, then obviously thats what i want it to be. please can we revert to the original original behaviour from way back? otherwise i have to hack the config files of my daemons expecting an FQDN. (postfix, apache, etc).
Ok, I think I am going with last suggestion as well. 1) Leave domainname alone 2) Set whatever is in /etc/hostname, as the user might want to have a FQDN in there (even if its not the proper way).
While we are at it, should we set the NIS/DNS domainname ? What about this for a /etc/init.d/domainname: --------------------------------------------------------- depend() { need checkroot hostname } checkconfig_nis() { if [ ! -f /etc/nisdomainname ] || [ -z "$(< /etc/nisdomainname)" ] then # eerror "You need to set /etc/nisdomainname to a valid NIS domainname" return 1 fi return 0 } checkconfig_dns() { if [ ! -f /etc/dnsdomainname ] || [ -z "$(< /etc/dnsdomainname)" ] then # eerror "You need to set /etc/nisdomainname to a valid DNS domainname" return 1 fi return 0 } start() { local mynisdomain= local mydnsdomain= local retval=0 if checkconfig_nis then mynisdomain="$(< /etc/nisdomainname)" ebegin "Setting NIS domainname to ${mydomain}" /bin/domainname "${mydomain}" retval=$? eend ${retval} "Failed to set the domainname" fi if checkconfig_dns then mydnsdomain="$(< /etc/dnsdomainname)" [ ! -f /etc/resolv.conf ] && touch /etc/resolv.conf ebegin "Setting DNS domainname to ${mydomain}" gawk -v DOMAIN="${mydomain}" \ 'BEGIN { print "domain " DOMAIN } $0 !~ /^[[:space:]]*domain/ { print }' \ /etc/resolv.conf > /etc/resolv.conf retval=$(($retval + $?)) eend ${retval} "Failed to set the domainname" fi return ${retval} }
Err, skip that one: ---------------------------------------------------------------- depend() { need checkroot hostname } checkconfig_nis() { if [ ! -f /etc/nisdomainname ] || [ -z "$(< /etc/nisdomainname)" ] then # eerror "You need to set /etc/nisdomainname to a valid NIS domainname" return 1 fi return 0 } checkconfig_dns() { if [ ! -f /etc/dnsdomainname ] || [ -z "$(< /etc/dnsdomainname)" ] then # eerror "You need to set /etc/nisdomainname to a valid DNS domainname" return 1 fi return 0 } start() { local mynisdomain= local mydnsdomain= local retval=0 if checkconfig_nis then mynisdomain="$(< /etc/nisdomainname)" ebegin "Setting NIS domainname to ${mynisdomain}" /bin/domainname "${mynisdomain}" retval=$? eend ${retval} "Failed to set the NIS domainname" fi if checkconfig_dns then mydnsdomain="$(< /etc/dnsdomainname)" [ ! -f /etc/resolv.conf ] && touch /etc/resolv.conf ebegin "Setting DNS domainname to ${mydnsdomain}" gawk -v DOMAIN="${mydnsdomain}" \ 'BEGIN { print "domain " DOMAIN } $0 !~ /^[[:space:]]*domain/ { print }' \ /etc/resolv.conf > /etc/resolv.conf retval=$(($retval + $?)) eend ${retval} "Failed to set the DNS domainname" fi return ${retval} }
The start() part needs to look like this: ---------------------------------------------------------- start() { local mynisdomain= local mydnsdomain= local retval=0 local retval2=2 if checkconfig_nis then mynisdomain="$(< /etc/nisdomainname)" ebegin "Setting NIS domainname to ${mynisdomain}" /bin/domainname "${mynisdomain}" retval=$? eend ${retval} "Failed to set the NIS domainname" fi if checkconfig_dns then mydnsdomain="$(< /etc/dnsdomainname)" [ ! -f /etc/resolv.conf ] && touch /etc/resolv.conf ebegin "Setting DNS domainname to ${mydnsdomain}" gawk -v DOMAIN="${mydnsdomain}" \ 'BEGIN { print "domain " DOMAIN } $0 !~ /^[[:space:]]*domain/ { print }' \ /etc/resolv.conf > /etc/resolv.conf.new retval2=$? [ "${retval2}" -eq 0 ] \ && (mv -f /etc/resolv.conf.new /etc/resolv.conf) \ || (rm -f /etc/resolv.conf.new) eend ${retval2} "Failed to set the DNS domainname" fi retval=$((retval + retval2)) return ${retval} }
*** Bug 20352 has been marked as a duplicate of this bug. ***
Why is retval2 initialized to 2 and not 0? The way it is now, "/etc/init.d/domainname start" will fail without printing an error message if /etc/dnsdomainname doesn't exist, even if it successfully set the NIS domainname.
you're looking at an outdated init script review cvs and/or baselayout-1.11.6