mirror of
https://github.com/inspec/inspec
synced 2024-11-23 05:03:07 +00:00
bugfix: handle edge-cases in upstart service
e.g. when a service could not be found and command outputs become empty / matchers dont hit'
This commit is contained in:
parent
f8c2b3fc1c
commit
ee82c3a2ff
1 changed files with 6 additions and 2 deletions
|
@ -311,6 +311,8 @@ class Upstart < ServiceManager
|
|||
config = inspec.file("/etc/init/#{service_name}.conf").content
|
||||
end
|
||||
|
||||
# disregard if the config does not exist
|
||||
return nil if config.nil?
|
||||
enabled = !config[/^\s*start on/].nil?
|
||||
|
||||
# implement fallback for Ubuntu 10.04
|
||||
|
@ -325,8 +327,10 @@ class Upstart < ServiceManager
|
|||
end
|
||||
|
||||
def version
|
||||
@version ||= Gem::Version.new(inspec.command("#{service_ctl} --version")
|
||||
.stdout.match(/\(upstart ([^\)]+)\)/)[1])
|
||||
@version ||= (
|
||||
out = inspec.command("#{service_ctl} --version").stdout
|
||||
Gem::Version.new(out[/\(upstart ([^\)]+)\)/, 1])
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue