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