From aca153f5750cabfb7ccf0fc0cb5a05a83ed2d026 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 9 Jan 2016 02:35:05 +0100
Subject: degesch: Lua: fix configuration loading
Not the cleanest solution but it has to do for now.
---
degesch.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/degesch.c b/degesch.c
index dbecd9a..03b5318 100644
--- a/degesch.c
+++ b/degesch.c
@@ -7999,10 +7999,12 @@ lua_plugin_add_config_schema (struct lua_plugin *plugin,
self->ref_validate = LUA_REFNIL;
struct config_schema *schema = &self->schema;
- schema->name = xstrdup (name);
- schema->comment = NULL;
- schema->default_ = NULL;
- schema->type = CONFIG_ITEM_NULL;
+ schema->name = xstrdup (name);
+ schema->comment = NULL;
+ schema->default_ = NULL;
+ schema->type = CONFIG_ITEM_NULL;
+ schema->on_change = lua_schema_item_on_change;
+ schema->validate = lua_schema_item_validate;
// Try to update the defaults with values provided by the plugin
int values = lua_absindex (L, -2);
@@ -8602,7 +8604,7 @@ lua_plugin_load (struct app_context *ctx, const char *filename,
luaL_openlibs (L);
struct lua_plugin *plugin = xcalloc (1, sizeof *plugin);
- plugin->super.name = NULL;
+ plugin->super.name = xstrdup (filename);
plugin->super.vtable = &lua_plugin_vtable;
plugin->ctx = ctx;
plugin->L = L;
@@ -8714,9 +8716,12 @@ plugin_load (struct app_context *ctx, const char *name)
struct plugin *plugin = plugin_load_by_name (ctx, name, &e);
if (plugin)
{
+ // FIXME: this way the real name isn't available to the plugin on load
+ free (plugin->name);
+ plugin->name = xstrdup (name);
+
log_global_status (ctx, "Plugin \"#s\" loaded", name);
LIST_PREPEND (ctx->plugins, plugin);
- plugin->name = xstrdup (name);
}
else
{
--
cgit v1.2.3-70-g09d2