static function buildAmtcCommandline(Job $job) { $ou = Ou::find_one($job->ou_id); $optionset = Optionset::find_one($ou->optionset_id); // - throw error if optionset is nil (fresh install...) // - maxThreads was a per-optionset setting, but should be global/config $cmd_opts = array('-j'); // amtc shall always produce parsable json output $optionset->sw_scan22 && ($cmd_opts[] = '-s'); $optionset->sw_scan3389 && ($cmd_opts[] = '-r'); $optionset->sw_v5 && ($cmd_opts[] = '-5'); $optionset->sw_dash && ($cmd_opts[] = '-d'); $optionset->sw_usetls && ($cmd_opts[] = '-g'); $optionset->sw_skiptcertchk && ($cmd_opts[] = '-n'); $optionset->opt_timeout && ($cmd_opts[] = '-t ' . $optionset->opt_timeout); $optionset->opt_passfile && ($cmd_opts[] = '-p ' . $optionset->opt_passfile); $optionset->opt_cacertfile && ($cmd_opts[] = '-c ' . $optionset->opt_cacertfile); $job->amtc_delay && ($cmd_opts[] = '-w ' . $job->amtc_delay); // decide whether to act on whole OU or a given list of hosts if ($job->amtc_hosts) { $hosts = self::resolveHostIds($job->amtc_hosts); } else { $hosts = self::getOuHosts($job->ou_id); } $cmd = sprintf('%s %s -%s %s', AMTC_BIN, implode(' ', $cmd_opts), $job->amtc_cmd, $hosts); return $cmd; }