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
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.18 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.6.17 lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.17 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.16 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.14 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.6.16 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.13 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.6.15 lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.12 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.7.11 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-2.6.14 lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/provider/selboolean/getsetsebool.rb