summaryrefslogtreecommitdiffstats
path: root/controller/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-14 19:31:42 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commiteabae24ea592420de46e36f0b1af5d39eee5b8a4 (patch)
tree16cbc39e84eb71d655add40e715f7d87b4b02132 /controller/ctl-plugin.c
parent140fd3d8f76a8cbbde8f6b0bf997808855f3da43 (diff)
Attach and recursion check working
Change-Id: I2f9509d4b6aa63a16df8db2187810337fd802ef4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller/ctl-plugin.c')
-rw-r--r--controller/ctl-plugin.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c
index 748c78b..ae203af 100644
--- a/controller/ctl-plugin.c
+++ b/controller/ctl-plugin.c
@@ -44,8 +44,7 @@ int PluginGetCB (CtlActionT *action , json_object *callbackJ) {
goto OnErrorExit;
}
-
- int err = wrap_json_unpack(callbackJ, "{ss,ss,s?s,s?o!}", "plugin", &plugin, "function", &function, "args", &argsJ);
+ int err = wrap_json_unpack(callbackJ, "{ss,ss,s?o!}", "plugin", &plugin, "function", &function, "args", &argsJ);
if (err) {
AFB_ERROR("PluginGet missing plugin|function|[args] in %s", json_object_get_string(callbackJ));
goto OnErrorExit;
@@ -87,7 +86,8 @@ STATIC int DispatchOneL2c(lua_State* luaState, char *funcname, Lua2cFunctionT ca
STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* handle) {
json_object *lua2csJ = NULL, *actionsJ = NULL;
- const char*ldSearchPath = NULL, *basename = NULL;
+ const char *basename = NULL;
+ char *ldSearchPath = NULL;
void *dlHandle;
@@ -95,15 +95,23 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han
if (!pluginJ) return 0;
int err = wrap_json_unpack(pluginJ, "{ss,s?s,s?s,s?s,ss,s?o,s?o!}",
- "label", &ctlPlugin->label, "version", &ctlPlugin->version, "info", &ctlPlugin->info, "ldpath", &ldSearchPath, "basename", &basename, "lua2c", &lua2csJ, "actions", &actionsJ);
+ "label", &ctlPlugin->label,
+ "version", &ctlPlugin->version,
+ "info", &ctlPlugin->info,
+ "ldpath", &ldSearchPath,
+ "basename", &basename,
+ "lua2c", &lua2csJ,
+ "actions", &actionsJ);
if (err) {
AFB_ERROR("CTL-PLUGIN-LOADONE Plugin missing label|basename|version|[info]|[ldpath]|[lua2c]|[actions] in:\n-- %s", json_object_get_string(pluginJ));
goto OnErrorExit;
}
// if search path not in Json config file, then try default binding dir
- ldSearchPath = getenv("CONTROL_PLUGIN_PATH");
- if (!ldSearchPath) ldSearchPath = strncat(GetBindingDirPath(), "/lib", sizeof(GetBindingDirPath()) - strlen(GetBindingDirPath()) - 1);
+ if (!ldSearchPath) ldSearchPath = getenv("CONTROL_PLUGIN_PATH");
+ if (!ldSearchPath) {
+ ldSearchPath = strncat(GetBindingDirPath(), "/lib", sizeof(GetBindingDirPath()) - strlen(GetBindingDirPath()) - 1);
+ }
// search for default policy config file
json_object *pluginPathJ = ScanForConfig(ldSearchPath, CTL_SCAN_RECURSIVE, basename, CTL_PLUGIN_EXT);
@@ -145,7 +153,7 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han
// store dlopen handle to enable onload action at exec time
ctlPlugin->dlHandle = dlHandle;
- // Jose hack to make verbosity visible from sharelib
+ // Jose hack to make verbosity visible from sharedlib
struct afb_binding_data_v2 *afbHidenData = dlsym(dlHandle, "afbBindingV2data");
if (afbHidenData) *afbHidenData = afbBindingV2data;
@@ -208,7 +216,6 @@ OnErrorExit:
return 1;
}
-
int PluginConfig(CtlSectionT *section, json_object *pluginsJ) {
int err=0;