[Pkg-puppet-devel] [facter] 89/180: Add fact for encrypted swap on OpenBSD

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:34 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 c85c08153b83e08603bf6baf403ef138e0cd300d
Author: Jasper Lievisse Adriaanse <jasper at humppa.nl>
Date:   Thu Jun 27 21:56:42 2013 +0200

    Add fact for encrypted swap on OpenBSD
    
    Conflicts:
    	lib/facter/memory.rb
---
 lib/facter/memory.rb     | 24 +++++++++++++++---------
 spec/unit/memory_spec.rb |  6 ++++++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 8ef0c4f..6300a28 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -82,15 +82,21 @@ end
   end
 end
 
-if Facter.value(:kernel) == "Darwin"
-  Facter.add("SwapEncrypted") do
-    confine :kernel => :Darwin
-    setcode do
-      swap = Facter::Core::Execution.exec('sysctl vm.swapusage')
-      encrypted = false
-      if swap =~ /\(encrypted\)/ then encrypted = true; end
-      encrypted
-    end
+Facter.add("SwapEncrypted") do
+  confine :kernel => :openbsd
+  setcode do
+    sysctl_encrypted = Facter::Core::Execution.exec("sysctl -n vm.swapencrypt.enable").to_i
+    !(sysctl_encrypted.zero?)
+  end
+end
+
+Facter.add("SwapEncrypted") do
+  confine :kernel => :Darwin
+  setcode do
+    swap = Facter::Core::Execution.exec('sysctl vm.swapusage')
+    encrypted = false
+    if swap =~ /\(encrypted\)/ then encrypted = true; end
+    encrypted
   end
 end
 
diff --git a/spec/unit/memory_spec.rb b/spec/unit/memory_spec.rb
index 04dc73c..fa92367 100755
--- a/spec/unit/memory_spec.rb
+++ b/spec/unit/memory_spec.rb
@@ -232,6 +232,8 @@ EOS
       Facter::Core::Execution.stubs(:exec).with('vmstat').returns(vmstat)
       Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.physmem').returns('267321344')
 
+      Facter::Core::Execution.stubs(:exec).with('sysctl -n vm.swapencrypt.enable').returns('1')
+
       Facter.collection.internal_loader.load(:memory)
     end
 
@@ -254,6 +256,10 @@ EOS
     it "should return the current memory size in MB" do
       Facter.fact(:memorysize_mb).value.should == "254.94"
     end
+
+    it "should return whether swap is encrypted" do
+      Facter.fact(:swapencrypted).value.should == true
+    end
   end
 
   describe "on Solaris" do

-- 
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