Sha256: f3711e7847b1a643629d31a342977789ec0c6e3f3e8ef10c6bf26d02ea1f728b
Contents?: true
Size: 1.37 KB
Versions: 10
Compression:
Stored size: 1.37 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$/ then return :off elsif status =~ / on$/ then return :on else status.chomp! raise Puppet::Error, "Invalid response '%s' returned from getsebool" % [status] end end def value=(new) persist = "" if @resource[:persistent] == :true self.debug "Enabling persistence" persist = "-P" end execoutput("#{command(:setsebool)} #{persist} #{@resource[:name]} #{new}") return :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 return output end end
Version data entries
10 entries across 10 versions & 1 rubygems