mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-04 10:26:40 +00:00
fix(userspace/falco): guard lua state for falco outputs
Co-authored-by: Lorenzo Fontana <lo@linux.com> Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
3d8b7231f3
commit
f0cd3344a2
@ -57,7 +57,6 @@ falco_outputs::~falco_outputs()
|
|||||||
if(m_initialized)
|
if(m_initialized)
|
||||||
{
|
{
|
||||||
lua_getglobal(m_ls, m_lua_output_cleanup.c_str());
|
lua_getglobal(m_ls, m_lua_output_cleanup.c_str());
|
||||||
|
|
||||||
if(!lua_isfunction(m_ls, -1))
|
if(!lua_isfunction(m_ls, -1))
|
||||||
{
|
{
|
||||||
falco_logger::log(LOG_ERR, std::string("No function ") + m_lua_output_cleanup + " found. ");
|
falco_logger::log(LOG_ERR, std::string("No function ") + m_lua_output_cleanup + " found. ");
|
||||||
@ -148,8 +147,8 @@ void falco_outputs::handle_event(gen_event *ev, string &rule, string &source,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> guard(m_ls_semaphore);
|
||||||
lua_getglobal(m_ls, m_lua_output_event.c_str());
|
lua_getglobal(m_ls, m_lua_output_event.c_str());
|
||||||
|
|
||||||
if(lua_isfunction(m_ls, -1))
|
if(lua_isfunction(m_ls, -1))
|
||||||
{
|
{
|
||||||
lua_pushlightuserdata(m_ls, ev);
|
lua_pushlightuserdata(m_ls, ev);
|
||||||
@ -170,7 +169,6 @@ void falco_outputs::handle_event(gen_event *ev, string &rule, string &source,
|
|||||||
{
|
{
|
||||||
throw falco_exception("No function " + m_lua_output_event + " found in lua compiler module");
|
throw falco_exception("No function " + m_lua_output_event + " found in lua compiler module");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void falco_outputs::handle_msg(uint64_t now,
|
void falco_outputs::handle_msg(uint64_t now,
|
||||||
@ -226,8 +224,8 @@ void falco_outputs::handle_msg(uint64_t now,
|
|||||||
full_msg += ")";
|
full_msg += ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> guard(m_ls_semaphore);
|
||||||
lua_getglobal(m_ls, m_lua_output_msg.c_str());
|
lua_getglobal(m_ls, m_lua_output_msg.c_str());
|
||||||
|
|
||||||
if(lua_isfunction(m_ls, -1))
|
if(lua_isfunction(m_ls, -1))
|
||||||
{
|
{
|
||||||
lua_pushstring(m_ls, full_msg.c_str());
|
lua_pushstring(m_ls, full_msg.c_str());
|
||||||
@ -251,7 +249,6 @@ void falco_outputs::handle_msg(uint64_t now,
|
|||||||
void falco_outputs::reopen_outputs()
|
void falco_outputs::reopen_outputs()
|
||||||
{
|
{
|
||||||
lua_getglobal(m_ls, m_lua_output_reopen.c_str());
|
lua_getglobal(m_ls, m_lua_output_reopen.c_str());
|
||||||
|
|
||||||
if(!lua_isfunction(m_ls, -1))
|
if(!lua_isfunction(m_ls, -1))
|
||||||
{
|
{
|
||||||
throw falco_exception("No function " + m_lua_output_reopen + " found. ");
|
throw falco_exception("No function " + m_lua_output_reopen + " found. ");
|
||||||
|
Loading…
Reference in New Issue
Block a user