Added configure option CLICON_PLUGIN_DLOPEN_GLOBAL for config of dlopen()

This commit is contained in:
Olof hagsand 2023-07-06 15:50:36 +02:00
parent ad61570a3d
commit 90b7a550b2
5 changed files with 44 additions and 18 deletions

View file

@ -299,6 +299,7 @@ clixon_plugin_find(clicon_handle h,
}
/*! Load a dynamic plugin object and call its init-function
*
* @param[in] h Clicon handle
* @param[in] file Which plugin to load
* @param[in] function Which function symbol to load and call
@ -310,10 +311,10 @@ clixon_plugin_find(clicon_handle h,
* @see clixon_plugins_load Load all plugins
*/
static int
plugin_load_one(clicon_handle h,
char *file, /* note modified */
const char *function,
int dlflags,
plugin_load_one(clicon_handle h,
char *file, /* note modified */
const char *function,
int dlflags,
clixon_plugin_t **cpp)
{
int retval = -1;
@ -406,15 +407,16 @@ clixon_plugins_load(clicon_handle h,
const char *dir,
const char *regexp)
{
int retval = -1;
int ndp;
struct dirent *dp = NULL;
int i;
char filename[MAXPATHLEN];
clixon_plugin_t *cp = NULL;
int ret;
int retval = -1;
int ndp;
struct dirent *dp = NULL;
int i;
char filename[MAXPATHLEN];
clixon_plugin_t *cp = NULL;
int ret;
plugin_module_struct *ms = plugin_module_struct_get(h);
int dlflags;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (ms == NULL){
clicon_err(OE_PLUGIN, EINVAL, "plugin module not initialized");
@ -427,7 +429,12 @@ clixon_plugins_load(clicon_handle h,
for (i = 0; i < ndp; i++) {
snprintf(filename, MAXPATHLEN-1, "%s/%s", dir, dp[i].d_name);
clicon_debug(CLIXON_DBG_DEFAULT, "Loading plugin '%s'", filename);
if ((ret = plugin_load_one(h, filename, function, RTLD_NOW, &cp)) < 0)
dlflags = RTLD_NOW;
if (clicon_option_bool(h, "CLICON_PLUGIN_DLOPEN_GLOBAL"))
dlflags |= RTLD_GLOBAL;
else
dlflags |= RTLD_LOCAL;
if ((ret = plugin_load_one(h, filename, function, dlflags, &cp)) < 0)
goto done;
if (ret == 0)
continue;

View file

@ -999,7 +999,7 @@ assign_namespace_element(cxobj *x0, /* source */
*
* If origin body has namespace definitions, copy them. The reason is that
* some bodies rely on namespace prefixes, such as NACM path, but there is
* no way we can now this here.
* no way we can know this here.
* However, this may lead to namespace collisions if these prefixes are not
* canonical, and may collide with the assign_namespace_element() above (but that
* is for element symbols)