chef / ohai

Ohai profiles your system and emits JSON
https://docs.chef.io/ohai.html
Apache License 2.0
681 stars 452 forks source link

Add getnameinfo as a fall through case for fqdn resolution #1810

Closed tpowell-progress closed 11 months ago

tpowell-progress commented 11 months ago

Description

node['fqdn'] missing the DNS Suffix on windows nodes

If canonname includes multiple parts ('.'), then assume that that is a FQDN and return.

Otherwise, use getnameinfo as a fallback. If that return value is not an IP, return it.

If all else fails, just return what we originally received as an argument.

Related Issue

Internal issue: CHEF-605

Broken in PR #1705

Fixes #1733

Types of changes

Checklist:

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

johnmccrae commented 11 months ago

On non-domain joined devices, there is no FQDN

Important

By default the computer name of a computer that is not joined to a domain is a host name, and not a fully qualified domain name (FQDN). Topology Builder uses FQDNs, not host names. So, you must configure a DNS suffix on the name of the computer to be deployed as an Edge Server that is not joined to a domain. Use only standard characters (including A-Z, a-z, 0-9, and hyphens) when assigning FQDNs to your servers running Skype for Business Server. Do not use Unicode characters or underscores. Nonstandard characters in an FQDN are often not supported by external DNS and public CAs (that is, when the FQDN must be assigned to the SN in the certificate).

Source - Microsoft

Stromweld commented 11 months ago

That's M$ narrow minded attempt to say that you have to be joined to an active directory domain and should be using their AD managed DNS. In reality if there is a DNS server defining a domain and a host entry for it, then there is a FQDN for a host It's just being managed by other means.

jaymzh commented 11 months ago

On non-domain joined devices, there is no FQDN

Important

By default the computer name of a computer that is not joined to a domain is a host name, and not a fully qualified domain name (FQDN). Topology Builder uses FQDNs, not host names. So, you must configure a DNS suffix on the name of the computer to be deployed as an Edge Server that is not joined to a domain. Use only standard characters (including A-Z, a-z, 0-9, and hyphens) when assigning FQDNs to your servers running Skype for Business Server. Do not use Unicode characters or underscores. Nonstandard characters in an FQDN are often not supported by external DNS and public CAs (that is, when the FQDN must be assigned to the SN in the certificate).

Source - Microsoft

That's just garbage. That's only true in the "Windows Domain" sense, not in the "real world of networks" sense. If you have a DNS name pointing at you from a domain, you have an FQDN.

tpowell-progress commented 11 months ago

I'm going forward with this. The fall through handles the (mostly Windows-specific) use case, restoring the previous functionality there. If all else fails we'll return the original hostname.