From 2f61dcad0a253f70cece2f63aff7e4bb1e7227b1 Mon Sep 17 00:00:00 2001 From: Sean Champ Date: Wed, 20 Apr 2022 22:17:28 -0700 Subject: [PATCH 1/2] resolvers/networking.rb: avoid calling ipconfig unless Windows 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 614213a104971ffb89c1728d58081f60d7f65af2) --- lib/facter/resolvers/networking.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/facter/resolvers/networking.rb b/lib/facter/resolvers/networking.rb index 9ffec26461..9156767a24 100644 --- a/lib/facter/resolvers/networking.rb +++ b/lib/facter/resolvers/networking.rb @@ -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)) result = Facter::Core::Execution.execute("ipconfig getoption #{interface_name} " \ 'server_identifier', logger: log) From 5ef49734c6a01b7da3473797bd02981b80aa4b37 Mon Sep 17 00:00:00 2001 From: Sean Champ Date: Mon, 25 Apr 2022 22:02:29 -0700 Subject: [PATCH 2/2] extract_dhcp: Updating previous :windows test => :macosx Updating the previous change for Facter::Resolvers::Networking.extract_dhcp to check for :macosx instead of :windows before calling the platform's ipconfig cmd --- lib/facter/resolvers/networking.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/resolvers/networking.rb b/lib/facter/resolvers/networking.rb index 9156767a24..e0f01f6e83 100644 --- a/lib/facter/resolvers/networking.rb +++ b/lib/facter/resolvers/networking.rb @@ -72,7 +72,7 @@ def extract_mac(raw_data, parsed_interface_data) def extract_dhcp(interface_name, raw_data, parsed_interface_data) return unless ((raw_data =~ /status:\s+active/) && - (OsDetector.instance.identifier == :windows)) + (OsDetector.instance.identifier == :macosx)) result = Facter::Core::Execution.execute("ipconfig getoption #{interface_name} " \ 'server_identifier', logger: log)