Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: Steve Dickson <SteveD@RedHat.com>
To: Doug Nazar <nazard@nazar.ca>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 09/11] nfsidmap: Add support to cleanup resources on exit
Date: Mon, 20 Jul 2020 11:49:18 -0400
Message-ID: <84277cb9-03da-3065-1848-f8c1e2bee167@RedHat.com> (raw)
In-Reply-To: <20200718092421.31691-10-nazard@nazar.ca>

Hey,

On 7/18/20 5:24 AM, Doug Nazar wrote:
> Signed-off-by: Doug Nazar <nazard@nazar.ca>
> ---
>  support/nfsidmap/libnfsidmap.c      | 13 +++++++++++++
>  support/nfsidmap/nfsidmap.h         |  1 +
>  support/nfsidmap/nfsidmap_common.c  | 11 ++++++++++-
>  support/nfsidmap/nfsidmap_private.h |  1 +
>  support/nfsidmap/nss.c              |  8 ++++++++
>  5 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
> index bce448cf..6b5647d2 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 10630654..5a795684 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 f89b82ee..4d2cb14f 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 f1af55fa..a5cb6dda 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 9d46499c..f8dbb94a 100644
> --- a/support/nfsidmap/nss.c
> +++ b/support/nfsidmap/nss.c
> @@ -467,6 +467,14 @@ static int nss_plugin_init(void)
>  	return 0;
>  }
>  
> +__attribute__((destructor))
> +static int nss_plugin_term(void)
> +{
> +	free_local_realms();
> +	conf_cleanup();
> +	return 0;
> +}
> +
Just wondering... How is nss_plugin_term() called/used?

steved.

>  
>  struct trans_func nss_trans = {
>  	.name		= "nsswitch",
> 


  reply index

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-18  9:24 [PATCH 00/11] nfs-utils: Misc cleanups & fixes Doug Nazar
2020-07-18  9:24 ` [PATCH 01/11] Add error handling to libevent allocations Doug Nazar
2020-07-18  9:24 ` [PATCH 02/11] gssd: Fix cccache buffer size Doug Nazar
2020-07-20 14:43   ` Steve Dickson
2020-07-20 15:41     ` Doug Nazar
2020-07-18  9:24 ` [PATCH 03/11] gssd: Fix handling of failed allocations Doug Nazar
2020-07-18  9:24 ` [PATCH 04/11] gssd: srchost should never be * Doug Nazar
2020-07-18  9:24 ` [PATCH 05/11] xlog: Reorganize xlog_backend() to work around -Wmaybe-uninitialized Doug Nazar
2020-07-18  9:24 ` [PATCH 06/11] nfsdcld: Add graceful exit handling and resource cleanup Doug Nazar
2020-07-18  9:24 ` [PATCH 07/11] nfsdcld: Don't copy more data than exists in column Doug Nazar
2020-07-18  9:24 ` [PATCH 08/11] svcgssd: Convert to using libevent Doug Nazar
2020-07-18  9:24 ` [PATCH 09/11] nfsidmap: Add support to cleanup resources on exit Doug Nazar
2020-07-20 15:49   ` Steve Dickson [this message]
2020-07-20 15:58     ` Doug Nazar
2020-07-20 17:31       ` Steve Dickson
2020-07-18  9:24 ` [PATCH 10/11] svcgssd: Cleanup global " Doug Nazar
2020-07-18  9:24 ` [PATCH 11/11] svcgssd: Wait for nullrpc channel if not available Doug Nazar
2020-07-18 15:55   ` J. Bruce Fields
2020-07-18 18:07     ` Doug Nazar
2020-07-27 14:42 ` [PATCH 00/11] nfs-utils: Misc cleanups & fixes 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=84277cb9-03da-3065-1848-f8c1e2bee167@RedHat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=nazard@nazar.ca \
    /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

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git