From c5098683450a6fd24fc10761dd31be27d4bbe8c8 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 25 Feb 2021 21:59:33 +0100 Subject: [PATCH] Look for symbols in plugins using instead of for more portable use --- apps/cli/cli_plugin.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index 818b34c0..d283dcb0 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -47,6 +47,7 @@ #include #include #include +#define __USE_GNU /* For RTLD_DEFAULT */ #include #include #include @@ -212,8 +213,6 @@ clixon_str2fn(char *name, char **error) { void *fn = NULL; - - /* Reset error */ *error = NULL; @@ -236,7 +235,9 @@ clixon_str2fn(char *name, * master plugin if it exists */ dlerror(); /* Clear any existing error */ - fn = dlsym(NULL, name); + /* RTLD_DEFAULT instead of NULL for linux + FreeBSD: + * Use default search algorithm. Thanks jdl@netgate.com */ + fn = dlsym(RTLD_DEFAULT, name); if ((*error = (char*)dlerror()) == NULL) return fn; /* If no error we found the address of the callback */