Sha256: a71e17fc44120f264d79490ffd2cfd404e8f32d0d2a57f4b2866ccec08ffcc9d

Contents?: true

Size: 1.23 KB

Versions: 102

Compression:

Stored size: 1.23 KB

Contents

Puppet::Type.type(:selboolean).provide(:getsetsebool) do
  desc "Manage SELinux booleans using the getsebool and setsebool binaries."

  commands :getsebool => "/usr/sbin/getsebool"
  commands :setsebool => "/usr/sbin/setsebool"

  def value
    self.debug "Retrieving value of selboolean #{@resource[:name]}"

    status = getsebool(@resource[:name])

    if status =~ / off$/
      return :off
    elsif status =~ / on$/ then
      return :on
    else
      status.chomp!
      raise Puppet::Error, "Invalid response '#{status}' returned from getsebool"
    end
  end

  def value=(new)
    persist = ""
    if @resource[:persistent] == :true
      self.debug "Enabling persistence"
      persist = "-P"
    end
    execoutput("#{command(:setsebool)} #{persist} #{@resource[:name]} #{new}")
    :file_changed
  end

  # Required workaround, since SELinux policy prevents setsebool
  # from writing to any files, even tmp, preventing the standard
  # 'setsebool("...")' construct from working.

  def execoutput (cmd)
    output = ''
    begin
      execpipe(cmd) do |out|
        output = out.readlines.join('').chomp!
      end
    rescue Puppet::ExecutionFailure
      raise Puppet::ExecutionFailure, output.split("\n")[0]
    end
    output
  end
end

Version data entries

102 entries across 102 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/provider/selboolean/getsetsebool.rb
puppet-parse-0.1.3 lib/vendor/puppet/provider/selboolean/getsetsebool.rb
puppet-parse-0.1.2 lib/vendor/puppet/provider/selboolean/getsetsebool.rb
puppet-parse-0.1.1 lib/vendor/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.26 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.3 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.25 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.2 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.24 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.1 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.0 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.0.rc2 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.4.0.rc1 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.2 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.1 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.1.rc3 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.1.rc2 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.1.rc1 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.0 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-3.3.0.rc3 lib/puppet/provider/selboolean/getsetsebool.rb