fix mysql resource (#1971)

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
Christoph Hartmann 2017-06-27 03:26:47 -07:00 committed by Dominik Richter
parent 8f247673e5
commit 50e762e492

View file

@ -33,7 +33,7 @@ module Inspec::Resources
# run the query
command = "mysql -u#{@user} -p#{@pass}"
if !socket.nil?
if !@socket.nil?
command += " -S #{@socket}"
else
command += " -h #{@host}"
@ -43,10 +43,9 @@ module Inspec::Resources
cmd = inspec.command(command)
out = cmd.stdout + "\n" + cmd.stderr
if out =~ /Can't connect to .* MySQL server/ or
out.downcase =~ /^error/
if out =~ /Can't connect to .* MySQL server/ || out.downcase =~ /^error/
# skip this test if the server can't run the query
skip_resource("Can't connect to MySQL instance for SQL checks.")
warn("Can't connect to MySQL instance for SQL checks.")
end
# return the raw command output