Jira (FACT-1142) Facter FQDN resolution is incorrect on Windows

2 views
Skip to first unread message

Ethan Brown (JIRA)

unread,
Jul 22, 2015, 6:06:07 PM7/22/15
to puppe...@googlegroups.com
Ethan Brown created an issue
 
Facter / Bug FACT-1142
Facter FQDN resolution is incorrect on Windows
Issue Type: Bug Bug
Affects Versions: FACT 3.0.1
Assignee: Unassigned
Components: Windows
Created: 2015/07/22 3:05 PM
Priority: Normal Normal
Reporter: Ethan Brown

Native Facter has followed the previous model on Windows when resolving network facts. Unfortunately, it would seem that the method of calculating FQDN might be errant.

FQDN Is currently a combination of hostname + domain:

FQDN is later calculated by concatenating these 2 pieces of data at https://github.com/puppetlabs/facter/blob/89550ef649866692afff9c7bd94044fe6c67cf4c/lib/src/facts/resolvers/networking_resolver.cc#L48-L51

This might be correct, but a better way of doing this is likely to use GetComputerNameEx with a COMPUTER_NAME_FORMAT of ComputerNameDnsFullyQualified, given the registry parsing / interface spelunking is more complicated than necessary.

When I first ran across this code, I didn't realize that Native Facter was at least using the DNS host name resolution in GetComputerNameEx, and had suggested that Facter might want to use the Winsock gethostname function. This was a bad suggestion given GetComputerNameEx can handle DNS hostnames, and given gethostname may return a hostname or FQDN based on implementation details, which make it a less attractive solution.

Not sure if it's worth changing Facter 2.x, which uses Netbios name + DNS domain name to calculate a FQDN. That might work under a lot of circumstances, but is not accurate, given Netbios names do not have to match DNS hostnames on Windows.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.5#64020-sha1:78acd6c)
Atlassian logo

Michael Smith (JIRA)

unread,
Jul 22, 2015, 6:10:06 PM7/22/15
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Fix Version/s: FACT 3.x

Michael Smith (JIRA)

unread,
Jul 22, 2015, 6:10:09 PM7/22/15
to puppe...@googlegroups.com
Michael Smith commented on Bug FACT-1142
 
Re: Facter FQDN resolution is incorrect on Windows

My reading is that this was also broken in Facter 2.x, so scheduling for after we finish off adding other platforms.

Ethan Brown (JIRA)

unread,
Jul 22, 2015, 6:16:06 PM7/22/15
to puppe...@googlegroups.com
Ethan Brown updated an issue
 
Change By: Ethan Brown
Native Facter has followed  parts of  the previous model on Windows when resolving network facts.  Unfortunately, it would seem that the method of calculating FQDN might be errant.


FQDN Is currently a combination of hostname + domain:

* hostname is retrieved by [GetComputerNameEX|https://msdn.microsoft.com/en-us/library/windows/desktop/ms724301(v=vs.85).aspx] - in [networking_resolver|https://github.com/puppetlabs/facter/blob/0f2896b5224c22d0b2a708ddbc362322087d194a/lib/src/facts/windows/networking_resolver.cc#L43] with the flag {{ComputerNameDnsHostname}}, which should be appropriate - note that Facter 2.x used the {{hostname.exe}} command which I believe called {{GetComputerName}}, which returns a NetBIOS name
* domain still uses an [older mechanism of registry spleunking|https://github.com/puppetlabs/facter/blob/ebf3003a2492cd0ac2595d7c24be9ce7f46f872e/lib/src/facts/windows/networking_resolver.cc#L158-L159] with a fallback to the {{DnsSuffix}} returned from {{GetAdaptersAddresses}} at https://github.com/puppetlabs/facter/blob/ebf3003a2492cd0ac2595d7c24be9ce7f46f872e/lib/src/facts/windows/networking_resolver.cc#L202
This might be correct, but a better way of doing this is likely to use {{GetComputerNameEx}} with a {{COMPUTER_NAME_FORMAT}} of {{ComputerNameDnsFullyQualified}}, given the registry parsing / interface spelunking is more complicated than necessary.

When I first ran across this code, I didn't realize that Native Facter was at least using the DNS host name resolution in {{GetComputerNameEx}}, and had suggested that Facter might want to use the Winsock [gethostname|https://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx] function. This was a bad suggestion given {{GetComputerNameEx}} can handle DNS hostnames, and given {{gethostname}} may return a hostname or FQDN based on implementation details, which make it a less attractive solution.


Not sure if it's worth changing Facter 2.x, which uses Netbios name + DNS domain name to calculate a FQDN.  That might work under a lot of circumstances, but is not accurate, given Netbios names do not have to match DNS hostnames on Windows.

Michael Smith (JIRA)

unread,
Feb 7, 2017, 2:23:02 PM2/7/17
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Fix Version/s: FACT 3.y
Fix Version/s: FACT 4.0.0
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Sean McDonald (JIRA)

unread,
May 17, 2017, 1:33:03 PM5/17/17
to puppe...@googlegroups.com

Sean McDonald (JIRA)

unread,
May 17, 2017, 1:33:03 PM5/17/17
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
May 18, 2017, 1:49:06 PM5/18/17
to puppe...@googlegroups.com

Sean McDonald (JIRA)

unread,
Feb 21, 2018, 1:52:03 PM2/21/18
to puppe...@googlegroups.com
Sean McDonald updated an issue
Change By: Sean McDonald
Labels: facter_networking triaged windows
This message was sent by Atlassian JIRA (v7.5.1#75006-sha1:7df2574)
Atlassian logo

Casey Williams (JIRA)

unread,
May 15, 2018, 6:17:04 PM5/15/18
to puppe...@googlegroups.com
Casey Williams updated an issue
Change By: Casey Williams
Sprint: Platform OS Ready for Eng.
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Branan Riley (JIRA)

unread,
May 21, 2018, 3:55:31 PM5/21/18
to puppe...@googlegroups.com

Branan Riley (JIRA)

unread,
May 21, 2018, 3:55:38 PM5/21/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Sprint: Platform EOL - Blocked Tasks

Branan Riley (JIRA)

unread,
May 21, 2018, 4:01:09 PM5/21/18
to puppe...@googlegroups.com

Branan Riley (JIRA)

unread,
Jul 23, 2018, 1:44:03 PM7/23/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Labels: breaking networking windows

Branan Riley (JIRA)

unread,
Jul 23, 2018, 1:44:04 PM7/23/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Labels: facter_networking networking windows

Josh Cooper (Jira)

unread,
Sep 2, 2022, 3:40:03 PM9/2/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: FACT 4.0.0
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages