[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 51bcebe38cab6088c901f1006339bbe40a36d161

Rein Henrichs rein at puppetlabs.com
Wed Aug 18 05:55:59 UTC 2010


The following commit has been merged in the upstream branch:
commit b7fe98952af64c98bf7e82a1ea31f6223d78b6a6
Author: Rein Henrichs <rein at puppetlabs.com>
Date:   Thu Aug 5 15:31:50 2010 -0700

    [#2330] Update uptime calculation to use /bin/cat
    
    * Per #4466, Ruby has trouble reading files in /proc [1]. The
      alternative is to use `bin/cat`.
    
    * Also refactored methods to explicitly redirect standard error to
      /dev/null for *nix and BSD system calls.
    
      [1] http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/155745

diff --git a/lib/facter/util/uptime.rb b/lib/facter/util/uptime.rb
index f8a17db..353ebf5 100644
--- a/lib/facter/util/uptime.rb
+++ b/lib/facter/util/uptime.rb
@@ -16,20 +16,19 @@ module Facter::Util::Uptime
     private
 
     def self.uptime_proc_uptime
-        if File.exists? uptime_file
-            r = File.read uptime_file
-            r.split(" ").first.to_i
+        if output = `/bin/cat #{uptime_file} 2>/dev/null` and $?.success?
+            output.chomp.split(" ").first.to_i
         end
     end
 
     def self.uptime_sysctl
-        if (output = `#{uptime_sysctl_cmd}`) and $?.success?
+        if output = `#{uptime_sysctl_cmd} 2>/dev/null` and $?.success?
             compute_uptime(Time.at(output.unpack('L').first))
         end
     end
 
     def self.uptime_who_dash_b
-        if (output = `#{uptime_who_cmd}`) and $?.success?
+        if output = `#{uptime_who_cmd} 2>/dev/null` and $?.success?
             compute_uptime(Time.parse(output))
         end
     end
@@ -43,10 +42,10 @@ module Facter::Util::Uptime
     end
 
     def self.uptime_sysctl_cmd
-        'sysctl -b kern.boottime 2>/dev/null'
+        'sysctl -b kern.boottime'
     end
 
     def self.uptime_who_cmd
-        'who -b 2>/dev/null'
+        'who -b'
     end
 end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list