Sha256: fe7b5ec96f820370acdc9e407fb2956db1993ce39c33ea6eefbbaaaf0691ce8d

Contents?: true

Size: 1.25 KB

Versions: 33

Compression:

Stored size: 1.25 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]
      Puppet::Util.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

33 entries across 33 versions & 2 rubygems

Version Path
puppet-3.3.2 lib/puppet/provider/exec/posix.rb
puppet-3.3.1 lib/puppet/provider/exec/posix.rb
puppet-3.3.1.rc3 lib/puppet/provider/exec/posix.rb
puppet-3.3.1.rc2 lib/puppet/provider/exec/posix.rb
puppet-3.3.1.rc1 lib/puppet/provider/exec/posix.rb
puppet-3.3.0 lib/puppet/provider/exec/posix.rb
puppet-3.3.0.rc3 lib/puppet/provider/exec/posix.rb
puppet-3.3.0.rc2 lib/puppet/provider/exec/posix.rb
puppet-3.2.4 lib/puppet/provider/exec/posix.rb
puppet-3.2.3 lib/puppet/provider/exec/posix.rb
puppet-3.2.3.rc1 lib/puppet/provider/exec/posix.rb
puppet-3.2.2 lib/puppet/provider/exec/posix.rb
puppet-3.2.1 lib/puppet/provider/exec/posix.rb
puppet-3.2.1.rc1 lib/puppet/provider/exec/posix.rb
puppet-3.2.0.rc2 lib/puppet/provider/exec/posix.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/provider/exec/posix.rb
puppet-3.2.0.rc1 lib/puppet/provider/exec/posix.rb
puppet-3.1.1 lib/puppet/provider/exec/posix.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/provider/exec/posix.rb
puppet-3.1.0 lib/puppet/provider/exec/posix.rb