Issue #1571 has been updated by jamtur01. Status changed from Accepted to Closed
Pushed in commit:"cab5d85dea17f3ea09343955f29eb47c8b32a05d" in branch 0.24.x ---------------------------------------- Bug #1571: Puppet::Util::binary returns incorrect results http://projects.reductivelabs.com/issues/show/1571 Author: pirzyk Status: Closed Priority: Normal Assigned to: jamtur01 Category: plumbing Target version: 0.24.6 Complexity: Unknown Affected version: 0.24.5 Keywords: When calling the binary method, looking for 'rpm' command with the following path: /home/pirzyk/etc:/home/pirzyk/bin:/usr/local/sbin:/usr/local/etc:/usr/local/bin:/usr/local/games:/usr/share/games:/usr/sbin:/usr/etc:/usr/bin:/usr/games://sbin://etc://bin binary returns '/etc/rpm' /etc/rpm is a directory on most RPM based Linux systems. Following is to possible patches, one replaces the each loop with a call to which --- util.rb.orig 2008-09-10 15:09:14.000000000 -0400 +++ util.rb 2008-09-10 15:40:51.000000000 -0400 @@ -220,19 +220,14 @@ def binary(bin) if bin =~ /^\// - if FileTest.exists? bin + if FileTest.file? bin and FileTest.executable? bin return bin else return nil end else - # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] - x = ENV['PATH'].split(":").each do |dir| - if FileTest.exists? File.join(dir, bin) - return File.join(dir, bin) - end - end - return nil + x = %x{which #{bin} 2>/dev/null}.chomp + return x end end module_function :binary The second is more in keeping with the existing code, by calling FileTest.executeable? and FileTest.file? instead of FileTest.exists? --- util.rb.orig 2008-09-10 15:09:14.000000000 -0400 +++ util.rb.new 2008-09-10 15:38:27.000000000 -0400 @@ -220,7 +220,7 @@ def binary(bin) if bin =~ /^\// - if FileTest.exists? bin + if FileTest.file? bin and FileTest.executable? bin return bin else return nil @@ -228,7 +228,7 @@ else # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = ENV['PATH'].split(":").each do |dir| - if FileTest.exists? File.join(dir, bin) + if FileTest.file? File.join(dir, bin) and FileTest.executable? File.join(dir, bin) return File.join(dir, bin) end end ---------------------------------------- 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://reductivelabs.com/redmine/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 -~----------~----~----~----~------~----~------~--~---
