Sha256: 9e26c283879d95bdd0151db6a187a7d2e7fa53aedca0ec3f975ea6780421297e

Contents?: true

Size: 1.24 KB

Versions: 391

Compression:

Stored size: 1.24 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], $!.backtrace
    end
    output
  end
end

Version data entries

391 entries across 391 versions & 3 rubygems

Version Path
bolt-0.21.5 vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb
bolt-0.21.4 vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb
bolt-0.21.3 vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.3 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.3-x86-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.3-x64-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.3-universal-darwin lib/puppet/provider/selboolean/getsetsebool.rb
bolt-0.21.2 vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb
bolt-0.21.1 vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.2 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.2-x86-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.2-x64-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.5.2-universal-darwin lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.3.7 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.3.7-x86-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.3.7-x64-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-5.3.7-universal-darwin lib/puppet/provider/selboolean/getsetsebool.rb
puppet-4.10.12 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-4.10.12-x86-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb
puppet-4.10.12-x64-mingw32 lib/puppet/provider/selboolean/getsetsebool.rb