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