Sha256: 262654720260df5e5955e3bdcfec69c9219c85694b32f8b60a03fcdcdfd8d982

Contents?: true

Size: 1.24 KB

Versions: 42

Compression:

Stored size: 1.24 KB

Contents

require 'puppet/provider/exec'

Puppet::Type.type(:exec).provide :posix, :parent => Puppet::Provider::Exec do
  confine :feature => :posix
  defaultfor :feature => :posix

  desc <<-EOT
    Executes external binaries directly, without passing through a shell or
    performing any interpolation. This is a safer and more predictable way
    to execute most commands, but prevents the use of globbing and shell
    built-ins (including control logic like "for" and "if" statements).
  EOT

  # Verify that we have the executable
  def checkexe(command)
    exe = extractexe(command)

    if File.expand_path(exe) == exe
      if !File.exists?(exe)
        raise ArgumentError, "Could not find command '#{exe}'"
      elsif !File.file?(exe)
        raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file"
      elsif !File.executable?(exe)
        raise ArgumentError, "'#{exe}' is not executable"
      end
      return
    end

    if resource[:path]
      withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do
        return if which(exe)
      end
    end

    # 'which' will only return the command if it's executable, so we can't
    # distinguish not found from not executable
    raise ArgumentError, "Could not find command '#{exe}'"
  end
end

Version data entries

42 entries across 42 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.1.3 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.1.2 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.1.1 lib/vendor/puppet/provider/exec/posix.rb
puppet-2.7.26 lib/puppet/provider/exec/posix.rb
puppet-2.7.25 lib/puppet/provider/exec/posix.rb
puppet-2.7.24 lib/puppet/provider/exec/posix.rb
puppet-2.7.23 lib/puppet/provider/exec/posix.rb
puppet-2.7.22 lib/puppet/provider/exec/posix.rb
puppet-parse-0.1.0 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.0.6 lib/vendor/puppet/provider/exec/posix.rb
puppet-2.7.21 lib/puppet/provider/exec/posix.rb
puppet-parse-0.0.5 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.0.4 lib/vendor/puppet/provider/exec/posix.rb
puppet-parse-0.0.2 lib/vendor/puppet/provider/exec/posix.rb
puppet-2.7.20 lib/puppet/provider/exec/posix.rb
puppet-2.7.20.rc1 lib/puppet/provider/exec/posix.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/provider/exec/posix.rb
puppet-2.7.19 lib/puppet/provider/exec/posix.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/exec/posix.rb