mirror of
https://github.com/inspec/inspec
synced 2024-12-11 22:02:47 +00:00
Merge pull request #26 from chef/bugfix-windows-service
bugfix: catch cases, where no service is available
This commit is contained in:
commit
e51b18bd80
1 changed files with 16 additions and 2 deletions
|
@ -311,8 +311,22 @@ class WindowsSrv < ServiceManager
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
service['Service']['Status'] == 4 ? (running = true) : (running = false)
|
# check that we got a response
|
||||||
service['WMI']['StartMode'] == 'Auto' ? (enabled = true) : (enabled = false)
|
return nil if service.nil? || service['Service'].nil?
|
||||||
|
|
||||||
|
# detect if service is running
|
||||||
|
if !service['Service']['Status'].nil? && service['Service']['Status'] == 4
|
||||||
|
running = true
|
||||||
|
else
|
||||||
|
running = false
|
||||||
|
end
|
||||||
|
|
||||||
|
# detect if service is enabled
|
||||||
|
if !service['WMI'].nil? && !service['WMI']['StartMode'].nil? && service['WMI']['StartMode'] == 'Auto'
|
||||||
|
enabled = true
|
||||||
|
else
|
||||||
|
enabled = false
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
name: service['Service']['Name'],
|
name: service['Service']['Name'],
|
||||||
|
|
Loading…
Reference in a new issue