diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index a5c7643b8..9413636bc 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -554,19 +554,21 @@ class SetupUtils return new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server"); } - clearstatcache(); - if (!is_file($sGraphvizPath) || ! is_executable($sGraphvizPath)){ - //N°3412 avoid shell injection - return new CheckResult(CheckResult::ERROR, "$sGraphvizPath could not be executed: Please make sure it is installed and in the path"); - } - - $sGraphvizPath = escapeshellcmd($sGraphvizPath); - // availability of dot / dot.exe if (empty($sGraphvizPath)) { $sGraphvizPath = 'dot'; + } else { + clearstatcache(); + if (!is_file($sGraphvizPath) || !is_executable($sGraphvizPath)) { + //N°3412 avoid shell injection + return new CheckResult(CheckResult::ERROR, + "$sGraphvizPath could not be executed: Please make sure it is installed and in the path"); + } + + $sGraphvizPath = escapeshellcmd($sGraphvizPath); } + $sCommand = "\"$sGraphvizPath\" -V 2>&1"; $aOutput = array(); diff --git a/test/setup/SetupUtilsTest.php b/test/setup/SetupUtilsTest.php index 3ce4cee77..efa110ec1 100644 --- a/test/setup/SetupUtilsTest.php +++ b/test/setup/SetupUtilsTest.php @@ -55,6 +55,11 @@ class SetupUtilsTest extends ItopTestCase 2, "", ], + "empty command => dot by default" => [ + "", + 2, + "", + ], "command failed" => [ "/bin/ls", 1,