Codebase list facter / 3168927
(#7484) Domain Fact should handle TLD Before this commit, using hostname -f was opt-out. With this commit it has been changed to be opt-in, to prevent problems on certain operating systems like Solaris and HP-UX. Hailee Kenney 12 years ago
2 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2222 # Get the domain from various sources; the order of these
2323 # steps is important
2424
25 hostname_command = (Facter.value(:kernel) =~ /SunOS/i) ? 'hostname' : 'hostname -f'
25 # In some OS 'hostname -f' will change the hostname to '-f'
26 # We know that Solaris and HP-UX exhibit this behavior
27 # On good OS, 'hostname -f' will return the FQDN which is preferable
28 # Due to dangerous behavior of 'hostname -f' on old OS, we will explicitly opt-in
29 # 'hostname -f' --hkenney May 9, 2012
30 hostname_command = 'hostname'
31 can_do_hostname_f = Regexp.union /Linux/i, /FreeBSD/i, /Darwin/i
32 hostname_command = 'hostname -f' if Facter.value(:kernel) =~ can_do_hostname_f
33
2634
2735 if name = Facter::Util::Resolution.exec(hostname_command) \
2836 and name =~ /.*?\.(.+$)/
77 :solaris => {:kernel => "SunOS", :hostname_command => "hostname"},
88 :darwin => {:kernel => "Darwin", :hostname_command => "hostname -f"},
99 :freebsd => {:kernel => "FreeBSD", :hostname_command => "hostname -f"},
10 :hpux => {:kernel => "HP-UX", :hostname_command => "hostname"},
1011 }.each do |key, nested_hash|
1112
1213 describe "on #{key}" do