degesch: Lua: fix configuration loading

Not the cleanest solution but it has to do for now.
This commit is contained in:
Přemysl Eric Janouch 2016-01-09 02:35:05 +01:00
parent 79f46752d4
commit aca153f575
1 changed files with 11 additions and 6 deletions

View File

@ -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
{