[Pkg-puppet-devel] [facter] 170/180: (FACT-599) Don't hardcode location of `sysctl`

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 36911449c7d577d079dd401934647f6e1588c447
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Mon Jun 23 17:35:01 2014 -0700

    (FACT-599) Don't hardcode location of `sysctl`
    
    `sysctl` is found in `/sbin` on OpenBSD but is in `/usr/bin` on OSX.
    Because we can't assume the location it's easier to allow
    `Facter::Core::Execution.which` to locate the executable to invoke.
---
 lib/facter/util/posix.rb     |  2 +-
 spec/unit/util/posix_spec.rb | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/facter/util/posix.rb b/lib/facter/util/posix.rb
index dfcca55..62c71a3 100644
--- a/lib/facter/util/posix.rb
+++ b/lib/facter/util/posix.rb
@@ -7,7 +7,7 @@ module POSIX
   #
   # @api private
   def sysctl(mib)
-    Facter::Util::Resolution.exec("/sbin/sysctl -n #{mib} 2>/dev/null")
+    Facter::Util::Resolution.exec("sysctl -n #{mib} 2>/dev/null")
   end
 
   module_function :sysctl
diff --git a/spec/unit/util/posix_spec.rb b/spec/unit/util/posix_spec.rb
new file mode 100644
index 0000000..d2c3cb5
--- /dev/null
+++ b/spec/unit/util/posix_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+require 'facter/util/posix'
+
+describe Facter::Util::POSIX do
+  describe "retrieving values via sysctl" do
+    it "returns the result of the sysctl command" do
+      Facter::Util::Resolution.expects(:exec).with("sysctl -n hw.pagesize 2>/dev/null").returns("somevalue")
+      expect(described_class.sysctl("hw.pagesize")).to eq "somevalue"
+    end
+  end
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list