[Pkg-puppet-devel] [facter] 180/352: (#9546) Do not execute com, cmd, exe, or bat files if not on windows

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:43 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 5e369e062571022e41c88465309f853d165688c2
Author: John Julien <john at julienfamily.com>
Date:   Tue Oct 15 22:23:15 2013 -0500

    (#9546) Do not execute com, cmd, exe, or bat files if not on windows
    
    Facter currently only executes com, exe, and bat files if on a windows
    system.  It should also exclude these on unix flavored systems since
    the interpreter for these "cmd.exe" will not be present.
    
    This also supports the use of pluginsync for external facts where in a
    hybrid environment external facts for windows may end up getting syncd
    to a unix system.
    
    Conflicts:
    	spec/unit/util/parser_spec.rb
---
 spec/unit/util/parser_spec.rb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/spec/unit/util/parser_spec.rb b/spec/unit/util/parser_spec.rb
index 54bc1e4..f6e28e5 100755
--- a/spec/unit/util/parser_spec.rb
+++ b/spec/unit/util/parser_spec.rb
@@ -149,6 +149,28 @@ describe Facter::Util::Parser do
       end
     end
 
+    context "exe, bat, cmd, and com files" do
+      let :cmds do ["/tmp/foo.bat", "/tmp/foo.cmd", "/tmp/foo.exe", "/tmp/foo.com"] end
+
+      before :each do
+        cmds.each {|cmd|
+          File.stubs(:executable?).with(cmd).returns(true)
+          File.stubs(:file?).with(cmd).returns(true)
+        }
+      end
+
+      it "should return nothing parser if not on windows" do
+        Facter::Util::Config.stubs(:is_windows?).returns(false)
+        cmds.each {|cmd| Facter::Util::Parser.parser_for(cmd).should be_an_instance_of(Facter::Util::Parser::NothingParser) }
+      end
+
+      it "should return script  parser if on windows" do
+        Facter::Util::Config.stubs(:is_windows?).returns(true)
+        cmds.each {|cmd| Facter::Util::Parser.parser_for(cmd).should be_an_instance_of(Facter::Util::Parser::ScriptParser) }
+      end
+
+     end
+
     describe "powershell parser" do
       let(:ps1) { "/tmp/foo.ps1" }
 

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