Issue #3898 has been updated by Alan Barrett.
There are probably still systems where "hostname -f" performs
sethostname("-f"), so please don't do that. There are certainly systems where
"hostname -f" prints an error message due to invalid usage.
I'd prefer the library functions uname(), gethostname(), and domainname() (or
their Ruby equivalants) to be used, rather than parsing the output from
commands.
----------------------------------------
Bug #3898: fqdn fact requires reverse PTR matches the forward
http://projects.puppetlabs.com/issues/3898
Author: micah -
Status: Accepted
Priority: Normal
Assigned to: Rein Henrichs
Category: library
Target version: 1.5.8
Keywords:
Branch:
It seems like the patch applied in #2085
(commit:dca615c98b864d75e2ac5899d98d04a2bd979eba) changes the way the fqdn fact
is determined.
What it does now is: name = Socket.gethostbyname(Socket.gethostname).first and
then it parses that output to pull out the hostname ($1) and then the fqdn $2.
The gethostname call seems like the right way to get the hostname (its a much
better improvement from parsing the output of the 'hostname' command, which
essentially just does that).
However, running gethostbyname over that hostname means that the fqdn is looked
up by taking the hostname and then doing a DNS resolution of that hostname to
get an IP, and then doing a reverse lookup of that IP to end up with the fqdn.
That means that if your reverse does not match the forward, then your fqdn fact
is going to end up with something different from your hostname fact.
For example, if my gethostname() returns "nuthatch", and then gethostbyname
does a lookup of that using my configured resolver setup, it will result in the
IP 204.13.164.1, and then if you lookup the reverse on that IP, you end up with
'seattle.riseup.net'. So my hostname fact will be set to 'nuthatch', but my
fqdn will be set to 'seattle.riseup.net'.
This would be a surprise from how it previously worked (hostname --fqdn) which
would produce "nuthatch.riseup.net" for the fqdn, and "nuthatch" for the
hostname.
Looking at hostname --fqdn it seems to use getaddrinfo() for that process.
Looking at ruby, it seems like Socket.gethostbyname uses both gethostbyname and
getaddrinfo. First it looks up your hostname with getaddrinfo(), then it runs
gethostbyname() on the answer it gets from getaddrinfo(). It seems to me that
this fact shouldn't be doing doing reverse lookups to get the fqdn, but rather
do what hostname -f does, which is something like:
<pre>
require 'socket'
addrinfo = Socket.getaddrinfo(Socket.gethostname, nil, nil, Socket::SOCK_DGRAM,
nil, Socket::AI_CANONNAME)
af, port, name, addr = addrinfo.first
puts "fqdn: " + name
</pre>
NOTE: i am sure there are better ways to do this in ruby
NOTE2: yes, it is better for me to have the reverse match the forward, but that
isn't the point here :)
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.