resolvers/networking.rb: avoid calling ipconfig unless Windows#2481
resolvers/networking.rb: avoid calling ipconfig unless Windows#2481spchamp wants to merge 2 commits intopuppetlabs:mainfrom
Conversation
The following message was observed when running 'puppet catalog compile' under RUBYOPT="--debug" with Puppet 7 and Facter 4.2.9 on FreeBSD 12.3 ~~~~ Exception `Errno::ENOENT' at /opt/puppet/puppet_wk/puppet_ctl/tools/bundle/ruby/3.0/gems/facter-4.2.9/lib/facter/custom_facts/core/execution/popen3.rb:17 - No such file or directory - ipconfig ~~~~ In order to prevent the call to the Microsoft Windows ipconfig tool, this changeset adds an additional test under the method Facter::Resolvers::Networking.extract_dhcp The patched networking.rb has been tested with Puppet 7 from a local installation under Ruby 3.0 from FreeBSD ports, on FreeBSD 12.3 (cherry picked from commit 614213a)
|
Can one of the admins verify this patch? |
lib/facter/resolvers/networking.rb
Outdated
| 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Updating the previous change for Facter::Resolvers::Networking.extract_dhcp to check for :macosx instead of :windows before calling the platform's ipconfig cmd
|
I wasn't sure of adding any |
|
@spchamp Thanks for your contribution! Could you squash your commit and update the commit summary (since we're only calling ipconfig on macOS)? It's a little bit of a code smell to check of macos in the "base" resolver, but I think it's ok for now. If we need more macOS specific networking behavior then we can move that to a subclass later. |
joshcooper
left a comment
There was a problem hiding this comment.
Hi @spchamp could you squash your commits?
The following message was observed when running
puppet catalog compileunderRUBYOPT=--debugwith Puppet 7 and Facter 4.2.9 on FreeBSD 12.3In order to prevent the call to the Microsoft Windows ipconfig tool on non-Microsoft Windows platforms, this changeset adds an additional test under the method Facter::Resolvers::Networking.extract_dhcp
The patched networking.rb has been tested with Puppet 7 from a local installation of Puppet, using Ruby 3.0 from FreeBSD ports, on a FreeBSD 12.3 platform
(cherry picked from commit 614213a)