summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorDoug Nazar <nazard@nazar.ca>2020-07-20 13:38:19 -0400
committerSteve Dickson <steved@redhat.com>2020-07-22 10:39:16 -0400
commit640714ab63a465028bf31781349bfe045d0a1b97 (patch)
tree2b9ed358e74fb2280cf1e76cef25d26b8755ee1f /support
parent47c109c1a5b0b27df86cf77ca120b69e9693729d (diff)
downloadnfs-utils-640714ab63a465028bf31781349bfe045d0a1b97.tar.gz
nfsidmap: Add support to cleanup resources on exit
Signed-off-by: Doug Nazar <nazard@nazar.ca> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support')
-rw-r--r--support/nfsidmap/libnfsidmap.c13
-rw-r--r--support/nfsidmap/nfsidmap.h1
-rw-r--r--support/nfsidmap/nfsidmap_common.c11
-rw-r--r--support/nfsidmap/nfsidmap_private.h1
-rw-r--r--support/nfsidmap/nss.c11
5 files changed, 36 insertions, 1 deletions
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index bce448c..6b5647d 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -496,6 +496,19 @@ out:
return ret ? -ENOENT: 0;
}
+void nfs4_term_name_mapping(void)
+{
+ if (nfs4_plugins)
+ unload_plugins(nfs4_plugins);
+ if (gss_plugins)
+ unload_plugins(gss_plugins);
+
+ nfs4_plugins = gss_plugins = NULL;
+
+ free_local_realms();
+ conf_cleanup();
+}
+
int
nfs4_get_default_domain(char *UNUSED(server), char *domain, size_t len)
{
diff --git a/support/nfsidmap/nfsidmap.h b/support/nfsidmap/nfsidmap.h
index 1063065..5a79568 100644
--- a/support/nfsidmap/nfsidmap.h
+++ b/support/nfsidmap/nfsidmap.h
@@ -50,6 +50,7 @@ typedef struct _extra_mapping_params {
typedef void (*nfs4_idmap_log_function_t)(const char *, ...);
int nfs4_init_name_mapping(char *conffile);
+void nfs4_term_name_mapping(void);
int nfs4_get_default_domain(char *server, char *domain, size_t len);
int nfs4_uid_to_name(uid_t uid, char *domain, char *name, size_t len);
int nfs4_gid_to_name(gid_t gid, char *domain, char *name, size_t len);
diff --git a/support/nfsidmap/nfsidmap_common.c b/support/nfsidmap/nfsidmap_common.c
index f89b82e..4d2cb14 100644
--- a/support/nfsidmap/nfsidmap_common.c
+++ b/support/nfsidmap/nfsidmap_common.c
@@ -34,12 +34,21 @@ static char * toupper_str(char *s)
return s;
}
+static struct conf_list *local_realms = NULL;
+
+void free_local_realms(void)
+{
+ if (local_realms) {
+ conf_free_list(local_realms);
+ local_realms = NULL;
+ }
+}
+
/* Get list of "local equivalent" realms. Meaning the list of realms
* where john@REALM.A is considered the same user as john@REALM.B
* If not specified, default to upper-case of local domain name */
struct conf_list *get_local_realms(void)
{
- static struct conf_list *local_realms = NULL;
if (local_realms) return local_realms;
local_realms = conf_get_list("General", "Local-Realms");
diff --git a/support/nfsidmap/nfsidmap_private.h b/support/nfsidmap/nfsidmap_private.h
index f1af55f..a5cb6dd 100644
--- a/support/nfsidmap/nfsidmap_private.h
+++ b/support/nfsidmap/nfsidmap_private.h
@@ -37,6 +37,7 @@
#include "conffile.h"
struct conf_list *get_local_realms(void);
+void free_local_realms(void);
int get_nostrip(void);
int get_reformat_group(void);
diff --git a/support/nfsidmap/nss.c b/support/nfsidmap/nss.c
index 9d46499..669760b 100644
--- a/support/nfsidmap/nss.c
+++ b/support/nfsidmap/nss.c
@@ -467,6 +467,17 @@ static int nss_plugin_init(void)
return 0;
}
+/*
+ * Called by dlclose(). See dlopen(3) man page
+ */
+__attribute__((destructor))
+static int nss_plugin_term(void)
+{
+ free_local_realms();
+ conf_cleanup();
+ return 0;
+}
+
struct trans_func nss_trans = {
.name = "nsswitch",