mirror of https://github.com/Icinga/icinga2.git
parent
865344ec57
commit
f2a055c85a
|
@ -324,13 +324,6 @@ lterm_items_inner: lterm %dprec 2
|
|||
}
|
||||
;
|
||||
|
||||
library: T_LIBRARY T_STRING
|
||||
{
|
||||
context->HandleLibrary($2);
|
||||
free($2);
|
||||
}
|
||||
;
|
||||
|
||||
identifier: T_IDENTIFIER
|
||||
| T_STRING
|
||||
;
|
||||
|
@ -436,9 +429,9 @@ combined_set_op: T_SET
|
|||
| T_SET_BINARY_OR
|
||||
;
|
||||
|
||||
lterm: library
|
||||
lterm: T_LIBRARY rterm
|
||||
{
|
||||
$$ = MakeLiteral(); // ASTify this
|
||||
$$ = new LibraryExpression($2, @$);
|
||||
}
|
||||
| rterm combined_set_op rterm
|
||||
{
|
||||
|
|
|
@ -217,16 +217,6 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& tag, const String&
|
|||
return new DictExpression(expressions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the library directive.
|
||||
*
|
||||
* @param library The name of the library.
|
||||
*/
|
||||
void ConfigCompiler::HandleLibrary(const String& library)
|
||||
{
|
||||
Loader::LoadExtensionLibrary(library);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles a stream.
|
||||
*
|
||||
|
|
|
@ -109,7 +109,6 @@ public:
|
|||
Expression *HandleInclude(const String& include, bool search, const DebugInfo& debuginfo = DebugInfo());
|
||||
Expression *HandleIncludeRecursive(const String& path, const String& pattern, const DebugInfo& debuginfo = DebugInfo());
|
||||
Expression *HandleIncludeZones(const String& tag, const String& path, const String& pattern, const DebugInfo& debuginfo = DebugInfo());
|
||||
void HandleLibrary(const String& library);
|
||||
|
||||
size_t ReadInput(char *buffer, size_t max_bytes);
|
||||
void *GetScanner(void) const;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "base/logger.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/scriptglobal.hpp"
|
||||
#include "base/loader.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/exception/errinfo_nested_exception.hpp>
|
||||
|
@ -780,3 +781,16 @@ ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint)
|
|||
return VMOps::For(frame, m_FKVar, m_FVVar, valueres.GetValue(), m_Expression, m_DebugInfo);
|
||||
}
|
||||
|
||||
ExpressionResult LibraryExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
|
||||
{
|
||||
if (frame.Sandboxed)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Loading libraries is not allowed in sandbox mode.", m_DebugInfo));
|
||||
|
||||
ExpressionResult libres = m_Operand->Evaluate(frame, dhint);
|
||||
CHECK_RESULT(libres);
|
||||
|
||||
Loader::LoadExtensionLibrary(libres.GetValue());
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
||||
|
|
|
@ -288,7 +288,6 @@ protected:
|
|||
Expression *m_Operand2;
|
||||
};
|
||||
|
||||
|
||||
class I2_CONFIG_API VariableExpression : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
|
@ -885,6 +884,17 @@ private:
|
|||
Expression *m_Expression;
|
||||
};
|
||||
|
||||
class I2_CONFIG_API LibraryExpression : public UnaryExpression
|
||||
{
|
||||
public:
|
||||
LibraryExpression(Expression *expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: UnaryExpression(expression, debugInfo)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* EXPRESSION_H */
|
||||
|
|
Loading…
Reference in New Issue