From: Doug Nazar <nazard@nazar.ca>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 4/4] nfsidmap: Allow overriding location of method libraries
Date: Wed, 22 Jul 2020 01:53:54 -0400 [thread overview]
Message-ID: <20200722055354.28132-5-nazard@nazar.ca> (raw)
In-Reply-To: <20200722055354.28132-1-nazard@nazar.ca>
Signed-off-by: Doug Nazar <nazard@nazar.ca>
---
support/nfsidmap/libnfsidmap.c | 40 ++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 6b5647d2..22b319b8 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -237,24 +237,40 @@ static int load_translation_plugin(char *method, struct mapping_plugin *plgn)
{
void *dl = NULL;
struct trans_func *trans = NULL;
- libnfsidmap_plugin_init_t init_func;
+ libnfsidmap_plugin_init_t init_func = NULL;
char plgname[128];
int ret = 0;
- snprintf(plgname, sizeof(plgname), "%s/%s.so", PATH_PLUGINS, method);
+ /* Look for library using search path first to allow overriding */
+ snprintf(plgname, sizeof(plgname), "%s.so", method);
dl = dlopen(plgname, RTLD_NOW | RTLD_LOCAL);
- if (dl == NULL) {
- IDMAP_LOG(1, ("libnfsidmap: Unable to load plugin: %s",
- dlerror()));
- return -1;
+ if (dl != NULL) {
+ /* Is it really one of our libraries */
+ init_func = (libnfsidmap_plugin_init_t) dlsym(dl, PLUGIN_INIT_FUNC);
+ if (init_func == NULL) {
+ dlclose(dl);
+ dl = NULL;
+ }
}
- init_func = (libnfsidmap_plugin_init_t) dlsym(dl, PLUGIN_INIT_FUNC);
- if (init_func == NULL) {
- IDMAP_LOG(1, ("libnfsidmap: Unable to get init function: %s",
- dlerror()));
- dlclose(dl);
- return -1;
+
+ if (dl == NULL) {
+ /* Fallback to hard-coded path */
+ snprintf(plgname, sizeof(plgname), "%s/%s.so", PATH_PLUGINS, method);
+
+ dl = dlopen(plgname, RTLD_NOW | RTLD_LOCAL);
+ if (dl == NULL) {
+ IDMAP_LOG(1, ("libnfsidmap: Unable to load plugin: %s",
+ dlerror()));
+ return -1;
+ }
+ init_func = (libnfsidmap_plugin_init_t) dlsym(dl, PLUGIN_INIT_FUNC);
+ if (init_func == NULL) {
+ IDMAP_LOG(1, ("libnfsidmap: Unable to get init function: %s",
+ dlerror()));
+ dlclose(dl);
+ return -1;
+ }
}
trans = init_func();
if (trans == NULL) {
--
2.26.2
next prev parent reply other threads:[~2020-07-22 5:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 5:53 [PATCH 0/4] nfs-utils patches Doug Nazar
2020-07-22 5:53 ` [PATCH 1/4] exportfs: Fix a few valgrind warnings Doug Nazar
2020-07-22 5:53 ` [PATCH 2/4] idmapd: Add graceful exit and resource cleanup Doug Nazar
2020-07-23 17:56 ` Steve Dickson
2020-07-23 18:25 ` Doug Nazar
2020-07-23 19:16 ` Steve Dickson
2020-07-22 5:53 ` [PATCH 3/4] idmapd: Fix client mode support Doug Nazar
2020-07-22 5:53 ` Doug Nazar [this message]
2020-07-27 14:42 ` [PATCH 0/4] nfs-utils patches Steve Dickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200722055354.28132-5-nazard@nazar.ca \
--to=nazard@nazar.ca \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.