mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
service resource for solaris 10 and 11
This commit is contained in:
parent
913191fb9e
commit
bd1e5e4085
1 changed files with 39 additions and 2 deletions
|
@ -88,6 +88,8 @@ class Service < Inspec.resource(1)
|
|||
Systemd.new(inspec, service_ctl)
|
||||
elsif %w{aix}.include?(family)
|
||||
SrcMstr.new(inspec)
|
||||
elsif os.solaris?
|
||||
Svcs.new(inspec)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -185,6 +187,8 @@ class SrcMstr < ServiceManager
|
|||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def status?
|
||||
status_cmd = inspec.command("lssrc -s #{@name}")
|
||||
return nil if status_cmd.exit_status.to_i != 0
|
||||
|
@ -195,8 +199,6 @@ class SrcMstr < ServiceManager
|
|||
enabled_rc_tcpip? || enabled_inittab?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# #rubocop:disable Style/TrailingComma
|
||||
def enabled_rc_tcpip?
|
||||
inspec.command(
|
||||
|
@ -480,6 +482,41 @@ class WindowsSrv < ServiceManager
|
|||
end
|
||||
end
|
||||
|
||||
# Solaris services
|
||||
class Svcs < ServiceManager
|
||||
def initialize(service_name, service_ctl = nil)
|
||||
@service_ctl ||= 'svcs'
|
||||
super
|
||||
end
|
||||
|
||||
def info(service_name)
|
||||
# get the status of runit service
|
||||
cmd = inspec.command("#{service_ctl} -l #{service_name}")
|
||||
return nil if cmd.exit_status != 0
|
||||
|
||||
params = SimpleConfig.new(
|
||||
cmd.stdout.chomp,
|
||||
assignment_re: /^(\w+)\s*(.*)$/,
|
||||
multiple_values: false,
|
||||
).params
|
||||
|
||||
installed = cmd.exit_status == 0
|
||||
running = installed && (params['state'] == 'online')
|
||||
enabled = installed && (params['enabled'] == 'true')
|
||||
|
||||
{
|
||||
name: service_name,
|
||||
description: params['name'],
|
||||
installed: installed,
|
||||
running: running,
|
||||
enabled: enabled,
|
||||
type: 'svcs',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# specific resources for specific service managers
|
||||
|
||||
class SystemdService < Service
|
||||
name 'systemd_service'
|
||||
desc 'Use the systemd_service InSpec audit resource to test if the named service (controlled by systemd) is installed, running and/or enabled.'
|
||||
|
|
Loading…
Reference in a new issue