mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Don't execute built-in commands on the master in remote command execution mode
fixes #7708
This commit is contained in:
parent
a07600a469
commit
06e79fe6fd
@ -171,7 +171,8 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
|||||||
BOOST_FOREACH(const Dictionary::Pair& kv, env) {
|
BOOST_FOREACH(const Dictionary::Pair& kv, env) {
|
||||||
String name = kv.second;
|
String name = kv.second;
|
||||||
|
|
||||||
Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult());
|
Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult(),
|
||||||
|
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
|
||||||
|
|
||||||
envMacros->Set(kv.first, value);
|
envMacros->Set(kv.first, value);
|
||||||
}
|
}
|
||||||
@ -187,8 +188,13 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
|
|||||||
if (it != l_Objects.end()) {
|
if (it != l_Objects.end()) {
|
||||||
vtObject = it->second;
|
vtObject = it->second;
|
||||||
} else {
|
} else {
|
||||||
String clr_assembly = MacroProcessor::ResolveMacros("$clr_assembly$", resolvers, checkable->GetLastCheckResult());
|
String clr_assembly = MacroProcessor::ResolveMacros("$clr_assembly$", resolvers, checkable->GetLastCheckResult(),
|
||||||
String clr_type = MacroProcessor::ResolveMacros("$clr_type$", resolvers, checkable->GetLastCheckResult());
|
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
|
||||||
|
String clr_type = MacroProcessor::ResolveMacros("$clr_type$", resolvers, checkable->GetLastCheckResult(),
|
||||||
|
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
|
||||||
|
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
vtObject = CreateClrType(clr_assembly, clr_type);
|
vtObject = CreateClrType(clr_assembly, clr_type);
|
||||||
l_Objects[checkable] = vtObject;
|
l_Objects[checkable] = vtObject;
|
||||||
|
@ -39,6 +39,9 @@ REGISTER_SCRIPTFUNCTION(ClusterCheck, &ClusterCheckTask::ScriptFunc);
|
|||||||
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
|
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
|
@ -56,7 +56,11 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
|||||||
resolvers.push_back(std::make_pair("command", commandObj));
|
resolvers.push_back(std::make_pair("command", commandObj));
|
||||||
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
||||||
|
|
||||||
String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult());
|
String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(),
|
||||||
|
NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
|
||||||
|
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
if (zoneName.IsEmpty()) {
|
if (zoneName.IsEmpty()) {
|
||||||
cr->SetOutput("Macro 'cluster_zone' must be set.");
|
cr->SetOutput("Macro 'cluster_zone' must be set.");
|
||||||
|
@ -35,6 +35,9 @@ REGISTER_SCRIPTFUNCTION(IcingaCheck, &IcingaCheckTask::ScriptFunc);
|
|||||||
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
double interval = Utility::GetTime() - Application::GetStartTime();
|
double interval = Utility::GetTime() - Application::GetStartTime();
|
||||||
|
|
||||||
if (interval > 60)
|
if (interval > 60)
|
||||||
|
@ -34,6 +34,9 @@ REGISTER_SCRIPTFUNCTION(NullCheck, &NullCheckTask::ScriptFunc);
|
|||||||
void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
String output = "Hello from ";
|
String output = "Hello from ";
|
||||||
output += Utility::GetFQDN();
|
output += Utility::GetFQDN();
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ REGISTER_SCRIPTFUNCTION(RandomCheck, &RandomCheckTask::ScriptFunc);
|
|||||||
void RandomCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
void RandomCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
|
if (resolvedMacros && !useResolvedMacros)
|
||||||
|
return;
|
||||||
|
|
||||||
String output = "Hello from ";
|
String output = "Hello from ";
|
||||||
output += Utility::GetFQDN();
|
output += Utility::GetFQDN();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user