Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolvers/networking.rb: avoid calling ipconfig unless Windows #2481

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/facter/resolvers/networking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def extract_mac(raw_data, parsed_interface_data)
end

def extract_dhcp(interface_name, raw_data, parsed_interface_data)
return unless raw_data =~ /status:\s+active/
return unless ((raw_data =~ /status:\s+active/) &&
(OsDetector.instance.identifier == :windows))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ipconfig is valid on macOS too:

# uname -a
Darwin taxable-stump 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64
# ipconfig getoption en0 server_identifier
10.32.22.9

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candidly, I'm not familiar with the OS X environment, or so much of Windows networking. I was aware that there is an ipfconfig tool on Windows, did not take a look at the cmd syntax though.

It looks like :macosx is actually where the matching ipconfig would be found. I'll update the patch


result = Facter::Core::Execution.execute("ipconfig getoption #{interface_name} " \
'server_identifier', logger: log)
Expand Down