Sha256: 214bb374013506ff01976a9e7ae7bff4d4c6d87d9fa117ce3425790dd28480ae
Contents?: true
Size: 1.08 KB
Versions: 50
Compression:
Stored size: 1.08 KB
Contents
module Serverspec::Type class LinuxAuditSystem < Base def initialize(name=nil) @name = 'linux_audit_system' @runner = Specinfra::Runner @rules_content = nil end def enabled? status_of('enabled') == '1' end def running? pid = status_of('pid') (!pid.nil? && pid.size > 0 && pid != '0') end def rules if @rules_content.nil? @rules_content = @runner.run_command('/sbin/auditctl -l').stdout || '' end @rules_content end private def status_of(part) cmd = "/sbin/auditctl -s" status_str = @runner.run_command(cmd).stdout.chomp status_map = parse_status(status_str) status_map[part] || '' end def parse_status(status_str) map = nil if status_str =~ /^AUDIT_STATUS/ then map = status_str.split(' ')[1..-1].inject({}) { |res,elem| a = elem.split('='); res.store(a[0],a[1] || ''); res } else map = status_str.split("\n").inject({}) { |res,elem| a = elem.split(' '); res.store(a[0],a[1] || ''); res } end map end end end
Version data entries
50 entries across 50 versions & 3 rubygems