Issue #22060 has been updated by Mark Zeren.

I have updated my pull request to suggest reverting the original commit:

The enhancement introduced in 4b926d0 never actually took effect because this
exception was normally ignored causing the new (faster) MAC detection code to
always return nil. Spec tests were never written for this enhancement nor for
its interaction with ifconfig based MAC detection. Thus the safest path forward
is to just revert the offending commit.

----------------------------------------
Bug #22060: undefined local variable or method `path' in macaddress.rb
https://projects.puppetlabs.com/issues/22060#change-95987

* Author: Mark Zeren
* Status: Unreviewed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* Keywords: 
* Branch: master
* Affected Facter version: 
----------------------------------------
When I run `puppet agent --no-daemonize --debug` and in the code somewhere set 
the global $DEBUG = true, then Ctrl-C to kill puppet I hit the following 
exception:

> Exception `NilClass' at .../facter/lib/facter/macaddress.rb:19 - undefined 
> local variable or method `path' for :Facter::Util::Resolution

after that I see an "infinite" recursion which leads to a stack overflow/segv. 
The behavior is not seen if I don't set $DEBUG. The fix looks trivial:
<pre>
diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb
index 3bcc927..993f2d5 100644
--- a/lib/facter/macaddress.rb
+++ b/lib/facter/macaddress.rb
@@ -15,7 +15,7 @@ Facter.add(:macaddress) do
   has_weight  10                # about an order of magnitude faster
   setcode do
     begin
-      Dir.glob('/sys/class/net/*').reject {|x| x[-3..-1] == '/lo' }.first
+      path = Dir.glob('/sys/class/net/*').reject {|x| x[-3..-1] == '/lo' 
}.first
       path and File.read(path + '/address')
     rescue Exception
       nil
</pre>

This code was introduced here:
commit 4b926d0df3bb02a0492908fd13479e0a148ae19e
Author: Daniel Pittman <[email protected]>
Date:   Thu Jul 19 19:11:46 2012
Faster MAC address load on Linux via sysfs



-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to