linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Nazar <nazard@nazar.ca>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 10/11] svcgssd: Cleanup global resources on exit
Date: Sat, 18 Jul 2020 05:24:20 -0400	[thread overview]
Message-ID: <20200718092421.31691-11-nazard@nazar.ca> (raw)
In-Reply-To: <20200718092421.31691-1-nazard@nazar.ca>

Signed-off-by: Doug Nazar <nazard@nazar.ca>
---
 utils/gssd/gss_util.c     |  6 ++++++
 utils/gssd/gss_util.h     |  1 +
 utils/gssd/svcgssd.c      |  8 ++++++++
 utils/gssd/svcgssd_krb5.c | 21 ++++++++++++++-------
 utils/gssd/svcgssd_krb5.h |  1 +
 5 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/utils/gssd/gss_util.c b/utils/gssd/gss_util.c
index 2e6d40f0..a4b27779 100644
--- a/utils/gssd/gss_util.c
+++ b/utils/gssd/gss_util.c
@@ -339,3 +339,9 @@ out:
 	return retval;
 }
 
+void
+gssd_cleanup(void)
+{
+	u_int32_t min_stat;
+	gss_release_cred(&min_stat, &gssd_creds);
+}
diff --git a/utils/gssd/gss_util.h b/utils/gssd/gss_util.h
index aa9f7780..4da64e38 100644
--- a/utils/gssd/gss_util.h
+++ b/utils/gssd/gss_util.h
@@ -41,6 +41,7 @@ int gssd_acquire_cred(char *server_name, const gss_OID oid);
 void pgsserr(char *msg, u_int32_t maj_stat, u_int32_t min_stat,
 	const gss_OID mech);
 int gssd_check_mechs(void);
+void gssd_cleanup(void);
 
 #ifndef HAVE_LIBGSSGLUE
 #include <gssapi/gssapi_krb5.h>
diff --git a/utils/gssd/svcgssd.c b/utils/gssd/svcgssd.c
index f538fd2a..3155a2f9 100644
--- a/utils/gssd/svcgssd.c
+++ b/utils/gssd/svcgssd.c
@@ -65,6 +65,7 @@
 #include "err_util.h"
 #include "conffile.h"
 #include "misc.h"
+#include "svcgssd_krb5.h"
 
 struct state_paths etab;
 static bool signal_received = false;
@@ -148,6 +149,9 @@ main(int argc, char *argv[])
 	rpc_verbosity = conf_get_num("svcgssd", "RPC-Verbosity", rpc_verbosity);
 	idmap_verbosity = conf_get_num("svcgssd", "IDMAP-Verbosity", idmap_verbosity);
 
+	/* We don't need the config anymore */
+	conf_cleanup();
+
 	while ((opt = getopt(argc, argv, "fivrnp:")) != -1) {
 		switch (opt) {
 			case 'f':
@@ -276,5 +280,9 @@ main(int argc, char *argv[])
 
 	event_base_free(evbase);
 
+	nfs4_term_name_mapping();
+	svcgssd_free_enctypes();
+	gssd_cleanup();
+
 	return EXIT_SUCCESS;
 }
diff --git a/utils/gssd/svcgssd_krb5.c b/utils/gssd/svcgssd_krb5.c
index 1d44d344..305d4751 100644
--- a/utils/gssd/svcgssd_krb5.c
+++ b/utils/gssd/svcgssd_krb5.c
@@ -74,13 +74,7 @@ parse_enctypes(char *enctypes)
 		return 0;
 
 	/* Free any existing cached_enctypes */
-	free(cached_enctypes);
-
-	if (parsed_enctypes != NULL) {
-		free(parsed_enctypes);
-		parsed_enctypes = NULL;
-		parsed_num_enctypes = 0;
-	}
+	svcgssd_free_enctypes();
 
 	/* count the number of commas */
 	for (curr = enctypes; curr && *curr != '\0'; curr = ++comma) {
@@ -162,6 +156,19 @@ out_clean_parsed:
 /*===  External routines ===*/
 /*==========================*/
 
+void
+svcgssd_free_enctypes(void)
+{
+	free(cached_enctypes);
+	cached_enctypes = NULL;
+
+	if (parsed_enctypes != NULL) {
+		free(parsed_enctypes);
+		parsed_enctypes = NULL;
+		parsed_num_enctypes = 0;
+	}
+}
+
 /*
  * Get encryption types supported by the kernel, and then
  * call gss_krb5_set_allowable_enctypes() to limit the
diff --git a/utils/gssd/svcgssd_krb5.h b/utils/gssd/svcgssd_krb5.h
index 07d5eb9b..78a90e9a 100644
--- a/utils/gssd/svcgssd_krb5.h
+++ b/utils/gssd/svcgssd_krb5.h
@@ -32,5 +32,6 @@
 #define SVCGSSD_KRB5_H
 
 int svcgssd_limit_krb5_enctypes(void);
+void svcgssd_free_enctypes(void);
 
 #endif /* SVCGSSD_KRB5_H */
-- 
2.26.2


  parent reply	other threads:[~2020-07-18  9:24 UTC|newest]

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
2020-07-20 15:58     ` Doug Nazar
2020-07-20 17:31       ` Steve Dickson
2020-07-18  9:24 ` Doug Nazar [this message]
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=20200718092421.31691-11-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).