Issue #12831 has been updated by Ken Barber.

Category set to library
Status changed from In Topic Branch Pending Review to Merged - Pending Release
Target version set to 1.6.8
Affected Facter version set to 1.6.7

Merged here:

<https://github.com/puppetlabs/facter/commit/656019cfa43d238e2997b08a1874bf1d2e09c292>
----------------------------------------
Bug #12831: recursion on fact resultion: kernel
https://projects.puppetlabs.com/issues/12831#change-59785

Author: Stefan Schulte
Status: Merged - Pending Release
Priority: Normal
Assignee: 
Category: library
Target version: 1.6.8
Keywords: 
Branch: https://github.com/puppetlabs/facter/pull/178
Affected Facter version: 1.6.7


The kernel fact triggers a recursion:

to retrieve the value of the kernel fact we have to call the codeblock that is 
provided with the kernel fact. Inside this codeblock we call the exec method to 
run a command.

<pre>
Facter::Util::Resolution.exec("uname -s")
</pre>

The exec method now tries to find out if we can use `which`. Unfortunately this 
method now tries to query the kernel fact. Boom: Recursion detected
<pre>
  def self.have_which
    if ! defined?(@have_which) or @have_which.nil?
      if Facter.value(:kernel) == 'windows'
        @have_which = false
      else
        %x{which which >/dev/null 2>&1}
        @have_which = ($? == 0)
      end
    end
    @have_which
  end
</pre>
The current behaviour of facter is to return nil as a factvalue so we will 
always end up in the else tree. So the above kind of works accidentally.

Instead of checking
<pre>
if Facter.value(:kernel) == 'windows'
</pre>
we should probably do
<pre>
if Facter::Util::Config.is_windows?
</pre>
which does not rely on external facts.




-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to