Patchwork [06/11] libnsdb: Clean up an NSDB's certfile when NSDB conn params are deleted

login
register
mail settings
Submitter Chuck Lever
Date Jan. 16, 2013, 9:52 p.m.
Message ID <20130116215235.21683.29525.stgit@seurat.1015granger.net>
Download mbox | patch
Permalink /patch/213074/
State Accepted
Headers show

Comments

Chuck Lever - Jan. 16, 2013, 9:52 p.m.
An NSDB's certfile should be removed when an NSDB is deleted.
This change affects both fedfsd and the nsdbparams command.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/fedfsc/Makefile.am     |    1 +
 src/libnsdb/nsdb.c         |    6 +++++-
 src/nfsref/Makefile.am     |    2 +-
 src/nsdbc/Makefile.am      |    2 +-
 src/nsdbparams/Makefile.am |    2 +-
 5 files changed, 9 insertions(+), 4 deletions(-)

Patch

diff --git a/src/fedfsc/Makefile.am b/src/fedfsc/Makefile.am
index 87189e2..a12cf19 100644
--- a/src/fedfsc/Makefile.am
+++ b/src/fedfsc/Makefile.am
@@ -32,6 +32,7 @@  sbin_PROGRAMS		= fedfs-null \
 			  fedfs-lookup-replication
 LDADD			= $(LIBTIRPC) $(LIBLDAP) $(LIBLBER) $(LIBXML2) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) \
+			  $(LIBCRYPTO) $(LIBSSL) \
 			  $(top_builddir)/src/libadmin/libadmin.la \
 			  $(top_builddir)/src/libjunction/libjunction.la \
 			  $(top_builddir)/src/libnsdb/libnsdb.la \
diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index 0c84a37..5b75294 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -1627,12 +1627,15 @@  out:
 static FedFsStatus
 nsdb_delete_nsdbparams(nsdb_t host)
 {
+	const char *old_certfile;
 	FedFsStatus retval;
 	sqlite3 *db;
 
 	xlog(D_CALL, "%s: deleting parameters for NSDB '%s'",
 			__func__, host->fn_hostname);
 
+	old_certfile = nsdb_certfile(host);
+
 	retval = FEDFS_ERR_IO;
 	db = nsdb_open_db(fedfs_db_filename, SQLITE_OPEN_READWRITE);
 	if (db == NULL)
@@ -1642,6 +1645,7 @@  nsdb_delete_nsdbparams(nsdb_t host)
 	if (retval != FEDFS_OK)
 		goto out_close;
 
+	nsdb_connsec_remove_certfile(old_certfile);
 	retval = FEDFS_OK;
 
 out_close:
@@ -1746,7 +1750,7 @@  nsdb_delete_nsdb(const char *hostname, const unsigned short port)
 	nsdb_t host;
 	FedFsStatus retval;
 
-	retval = nsdb_new_nsdb(hostname, port, &host);
+	retval = nsdb_lookup_nsdb(hostname, port, &host);
 	if (retval != FEDFS_OK)
 		return retval;
 
diff --git a/src/nfsref/Makefile.am b/src/nfsref/Makefile.am
index c8ef8c9..411ad15 100644
--- a/src/nfsref/Makefile.am
+++ b/src/nfsref/Makefile.am
@@ -28,7 +28,7 @@  sbin_PROGRAMS		= nfsref
 nfsref_SOURCES		= add.c lookup.c nfsref.c remove.c
 LDADD			= $(LIBLDAP) $(LIBLBER) $(LIBXML2) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) \
-			  $(LIBURIPARSER) \
+			  $(LIBURIPARSER) $(LIBCRYPTO) $(LIBSSL) \
 			  $(top_builddir)/src/libnsdb/libnsdb.la \
 			  $(top_builddir)/src/libxlog/libxlog.la \
 			  $(top_builddir)/src/libjunction/libjunction.la
diff --git a/src/nsdbc/Makefile.am b/src/nsdbc/Makefile.am
index b1da7ad..b5fd5a9 100644
--- a/src/nsdbc/Makefile.am
+++ b/src/nsdbc/Makefile.am
@@ -30,7 +30,7 @@  sbin_PROGRAMS		= nsdb-annotate nsdb-describe nsdb-list \
 			  nsdb-create-fsl nsdb-delete-fsl nsdb-update-fsl
 LDADD			= $(LIBLDAP) $(LIBLBER) $(LIBXML2) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) \
-			  $(LIBURIPARSER) \
+			  $(LIBURIPARSER) $(LIBCRYPTO) $(LIBSSL) \
 			  $(top_builddir)/src/libnsdb/libnsdb.la \
 			  $(top_builddir)/src/libxlog/libxlog.la \
 			  $(top_builddir)/src/libjunction/libjunction.la
diff --git a/src/nsdbparams/Makefile.am b/src/nsdbparams/Makefile.am
index 9deb9ea..14c8be3 100644
--- a/src/nsdbparams/Makefile.am
+++ b/src/nsdbparams/Makefile.am
@@ -28,7 +28,7 @@  sbin_PROGRAMS		= nsdbparams
 nsdbparams_SOURCES	= delete.c list.c main.c show.c update.c
 LDADD			= $(LIBLDAP) $(LIBLBER) $(LIBXML2) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) $(LIBCAP) \
-			  $(LIBURIPARSER) \
+			  $(LIBURIPARSER) $(LIBCRYPTO) $(LIBSSL) \
 			  $(top_builddir)/src/libnsdb/libnsdb.la \
 			  $(top_builddir)/src/libjunction/libjunction.la \
 			  $(top_builddir)/src/libxlog/libxlog.la