From 90b7a550b258e9e9f01d11dbf2e5656329337787 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 6 Jul 2023 15:50:36 +0200 Subject: [PATCH] Added configure option `CLICON_PLUGIN_DLOPEN_GLOBAL` for config of dlopen() --- CHANGELOG.md | 8 +++++- doc/CLI.md | 4 +-- lib/src/clixon_plugin.c | 33 ++++++++++++++--------- lib/src/clixon_xml_map.c | 2 +- yang/clixon/clixon-config@2023-05-01.yang | 15 ++++++++++- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1450f6fc..c366a71d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Users may have to change how they access the system * New `clixon-config@2023-05-01.yang` revision * Added options: `CLICON_CONFIG_EXTEND` + * Moved datastore-format datastype to clixon-lib * New `clixon-lib@2023-05-01.yang` revision * Restructured and extended stats rpc to schema mountpoints @@ -97,8 +98,13 @@ project, along with minor improvements and bugfixes. ### API changes on existing protocol/config features Users may have to change how they access the system +* Changed `configure --with-cligen=dir` + * is considered as `DESTDIR` and consider cligen installed under `DESTDIR/PREFIX` + * Changed from: consider cligen installed under `` * New `clixon-config@2023-03-01.yang` revision - * Added options: `CLICON_RESTCONF_NOALPN_DEFAULT` + * Added options: + * `CLICON_RESTCONF_NOALPN_DEFAULT` + * `CLICON_PLUGIN_DLOPEN_GLOBAL` * Extended datastore-format with CLI and text * New `clixon-lib@2023-03-01.yang` revision * Added creator meta-object diff --git a/doc/CLI.md b/doc/CLI.md index 06032d6b..7f3ea092 100644 --- a/doc/CLI.md +++ b/doc/CLI.md @@ -179,7 +179,7 @@ A straightforward way to reference a pipe tree is by using an explicit pipe-tree @|mypipe, regular_cb(); } ``` -Note that the `regular_cb()` is stated as an argument to the mypipe reference. This means it will be preended to each callback in 'mypipe'. +Note that the `regular_cb()` is stated as an argument to the mypipe reference. This means it will be prepended to each callback in 'mypipe'. For example, in the following CLI call: ``` @@ -209,7 +209,7 @@ In Clixon: pipetree="|mypipe"; # in CLIgen ``` -This autoamtically expands each terminal command into a pipe-tree reference in a dynamic way. For example, assume the command `set, regular_cb();` is specified and a user types `set `. +This automatically expands each terminal command into a pipe-tree reference in a dynamic way. For example, assume the command `set, regular_cb();` is specified and a user types `set `. This expands the syntax by adding the `@|mypipe, regular_cb()` which is in turn expanded to: ``` diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index da6cc480..12eac664 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -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; diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index f63acac3..945bdab3 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -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) diff --git a/yang/clixon/clixon-config@2023-05-01.yang b/yang/clixon/clixon-config@2023-05-01.yang index a2b1842b..20f1a91c 100644 --- a/yang/clixon/clixon-config@2023-05-01.yang +++ b/yang/clixon/clixon-config@2023-05-01.yang @@ -53,7 +53,8 @@ module clixon-config { description "Added options: CLICON_CONFIG_EXTEND - Moved datastore-format datastype to clixon-lib + CLICON_PLUGIN_DLOPEN_GLOBAL + Moved datastore-format datatype to clixon-lib Released in Clixon 6.3"; } revision 2023-03-01 { @@ -1003,6 +1004,18 @@ module clixon-config { as well as the CLIgen callbacks. See https://clixon-docs.readthedocs.io/en/latest/backend.html#plugin-callback-guidelines"; } + leaf CLICON_PLUGIN_DLOPEN_GLOBAL { + type boolean; + default false; + description + "Local/global flag for dlopen as described in the man page. + This applies to the opening of all clixon plugins (backend/cli/netconf/restconf) + when loading the shared .so file with dlopen. + If false: Symbols defined in this shared object are not made available to resolve + references in subsequently loaded shared objects (default). + If true: The symbols defined by this shared object will be made available for symbol res‐ + olution of subsequently loaded shared objects."; + } leaf CLICON_YANG_AUGMENT_ACCEPT_BROKEN { type boolean; default false;