Sha256: b12b2c62e7abbe1f77698fa25298b48e86c8c3e2b9c77c482e92e83e0191dc69

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

require 'puppet/ssl/certificate_authority'

# This class wraps a given command and invokes it with a CSR name and body to
# determine if the given CSR should be autosigned
#
# @api private
class Puppet::SSL::CertificateAuthority::AutosignCommand

  class CheckFailure < Puppet::Error; end

  def initialize(path)
    @path = path
  end

  # Run the autosign command with the given CSR name as an argument and the
  # CSR body on stdin.
  #
  # @param name [String] The CSR name to check for autosigning
  # @return [true, false] If the CSR should be autosigned
  def allowed?(csr)
    name = csr.name
    cmd = [@path, name]

    output = Puppet::FileSystem::Tempfile.open('puppet-csr') do |csr_file|
      csr_file.write(csr.to_s)
      csr_file.flush

      execute_options = {:stdinfile => csr_file.path, :combine => true, :failonfail => false}
      Puppet::Util::Execution.execute(cmd, execute_options)
    end

    output.chomp!

    Puppet.debug "Autosign command '#{@path}' exit status: #{output.exitstatus}"
    Puppet.debug "Autosign command '#{@path}' output: #{output}"

    case output.exitstatus
    when 0
      true
    else
      false
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
puppet-3.5.1 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.1-x86-mingw32 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.1.rc1 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.1.rc1-x86-mingw32 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc3 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc3-x86-mingw32 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc2 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc2-x86-mingw32 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc1 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.5.0.rc1-x86-mingw32 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.3 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.2 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.1 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.0 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.0.rc2 lib/puppet/ssl/certificate_authority/autosign_command.rb
puppet-3.4.0.rc1 lib/puppet/ssl/certificate_authority/autosign_command.rb