Patchwork [03/11] libnsdb: Simplify nsdb_lookup_nsdb()

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

Comments

Chuck Lever - Jan. 16, 2013, 9:52 p.m.
Clean up: Remove the "fedfs_secdata *" parameter from
nsdb_lookup_nsdb().  No callers remain who need to retrieve security
data when looking up an nsdb_t object.

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

 src/fedfsd/svc.c             |    6 +++---
 src/include/nsdb.h           |    3 +--
 src/libjunction/fedfs.c      |    2 +-
 src/libnsdb/nsdb.c           |   44 +++++++++++-------------------------------
 src/nfsref/add.c             |    2 +-
 src/nsdbc/nsdb-annotate.c    |    2 +-
 src/nsdbc/nsdb-create-fsl.c  |    2 +-
 src/nsdbc/nsdb-create-fsn.c  |    2 +-
 src/nsdbc/nsdb-delete-fsl.c  |    2 +-
 src/nsdbc/nsdb-delete-fsn.c  |    2 +-
 src/nsdbc/nsdb-delete-nsdb.c |    2 +-
 src/nsdbc/nsdb-describe.c    |    2 +-
 src/nsdbc/nsdb-list.c        |    2 +-
 src/nsdbc/nsdb-nces.c        |    2 +-
 src/nsdbc/nsdb-remove-nci.c  |    2 +-
 src/nsdbc/nsdb-resolve-fsn.c |    2 +-
 src/nsdbc/nsdb-simple-nce.c  |    2 +-
 src/nsdbc/nsdb-update-fsl.c  |    2 +-
 src/nsdbc/nsdb-update-nci.c  |    2 +-
 src/nsdbparams/delete.c      |    2 +-
 src/nsdbparams/show.c        |    2 +-
 src/nsdbparams/update.c      |    2 +-
 22 files changed, 34 insertions(+), 57 deletions(-)

Patch

diff --git a/src/fedfsd/svc.c b/src/fedfsd/svc.c
index a384f32..ec8258b 100644
--- a/src/fedfsd/svc.c
+++ b/src/fedfsd/svc.c
@@ -510,7 +510,7 @@  fedfsd_svc_create_junction_1(SVCXPRT *xprt)
 	if (result != FEDFS_OK)
 		goto out;
 
-	result = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	result = nsdb_lookup_nsdb(hostname, port, &host);
 	if (result != FEDFS_OK)
 		goto out;
 
@@ -1041,7 +1041,7 @@  fedfsd_svc_get_nsdb_params_1(SVCXPRT *xprt)
 	if (result.status != FEDFS_OK)
 		goto out;
 
-	result.status = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	result.status = nsdb_lookup_nsdb(hostname, port, &host);
 	if (result.status != FEDFS_OK)
 		goto out;
 
@@ -1110,7 +1110,7 @@  fedfsd_svc_get_limited_nsdb_params_1(SVCXPRT *xprt)
 	if (result.status != FEDFS_OK)
 		goto out;
 
-	result.status = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	result.status = nsdb_lookup_nsdb(hostname, port, &host);
 	if (result.status != FEDFS_OK)
 		goto out;
 
diff --git a/src/include/nsdb.h b/src/include/nsdb.h
index bcf9432..cd81874 100644
--- a/src/include/nsdb.h
+++ b/src/include/nsdb.h
@@ -177,8 +177,7 @@  FedFsStatus	 nsdb_new_nsdb(const char *hostname, const unsigned long port,
  * Instantiate an nsdb_t object based on stored connection parameters
  */
 FedFsStatus	 nsdb_lookup_nsdb(const char *hostname,
-				const unsigned short port, nsdb_t *host,
-				struct fedfs_secdata *sec);
+				const unsigned short port, nsdb_t *host);
 
 /**
  * Instantiate an nsdb_t object based on stored connection parameters
diff --git a/src/libjunction/fedfs.c b/src/libjunction/fedfs.c
index a39925b..eed51b3 100644
--- a/src/libjunction/fedfs.c
+++ b/src/libjunction/fedfs.c
@@ -409,7 +409,7 @@  fedfs_parse_node(const char *pathname, xmlNodePtr node,
 
 	retval = FEDFS_ERR_NSDB_PARAMS;
 	if (nsdb_lookup_nsdb((const char *)nsdb_name_tmp, (unsigned short)port,
-					&host_tmp, NULL) != FEDFS_OK) {
+					&host_tmp) != FEDFS_OK) {
 		xlog(D_GENERAL, "%s: No NSDB params for %s\n",
 			__func__, nsdb_name_tmp);
 		free(tmp);
diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index c854995..112df22 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -1106,15 +1106,12 @@  out:
  * Read NSDB info for "host" from NSDB database
  *
  * @param host an instantiated nsdb_t object
- * @param sec buffer for returned connection data
  * @return a FedFsStatus code
  *
- * On success, FEDFS_OK is returned, a fresh nsdb_t is returned, and
- * the sectype and secdata fields in the passed-in fedfs_secdata object
- * are filled in.
+ * On success, FEDFS_OK is returned and "host" is initialized.
  */
 static FedFsStatus
-nsdb_read_nsdbparams(nsdb_t host, struct fedfs_secdata *sec)
+nsdb_read_nsdbparams(nsdb_t host)
 {
 	FedFsStatus retval;
 	sqlite3 *db;
@@ -1125,25 +1122,7 @@  nsdb_read_nsdbparams(nsdb_t host, struct fedfs_secdata *sec)
 		goto out;
 
 	retval = nsdb_read_nsdbname(db, host);
-	if (retval != FEDFS_OK)
-		goto out_close;
-
-	if (sec != NULL) {
-		if (host->fn_sectype != FEDFS_SEC_NONE) {
-			retval = nsdb_read_certfile(nsdb_certfile(host),
-					&sec->data, &sec->len);
-			if (retval != FEDFS_OK)
-				goto out_close;
-		} else {
-			sec->data = NULL;
-			sec->len = 0;
-		}
-		sec->type = host->fn_sectype;
-	}
 
-	retval = FEDFS_OK;
-
-out_close:
 	nsdb_close_db(db);
 out:
 	return retval;
@@ -1155,16 +1134,15 @@  out:
  * @param hostname NUL-terminated UTF-8 string containing NSDB hostname
  * @param port integer port number of NSDB
  * @param host OUT: an initialized nsdb_t object
- * @param sec buffer for returned connection data
  * @return a FedFsStatus code
  *
- * On success, FEDFS_OK is returned, a fresh nsdb_t is returned, and
- * the sectype and secdata fields in the passed-in fedfs_secdata object
- * are filled in.
+ * On success, FEDFS_OK is returned and a fresh nsdb_t is returned.
+ *
+ * "host" must be freed with nsdb_free_nsdb().
  */
 FedFsStatus
 nsdb_lookup_nsdb(const char *hostname, const unsigned short port,
-		nsdb_t *host, struct fedfs_secdata *sec)
+		nsdb_t *host)
 {
 	FedFsStatus retval;
 	nsdb_t new;
@@ -1173,7 +1151,7 @@  nsdb_lookup_nsdb(const char *hostname, const unsigned short port,
 	if (retval != FEDFS_OK)
 		return retval;
 
-	retval = nsdb_read_nsdbparams(new, sec);
+	retval = nsdb_read_nsdbparams(new);
 	if (retval != FEDFS_OK)
 		nsdb_free_nsdb(new);
 	else
@@ -1220,7 +1198,7 @@  nsdb_lookup_nsdb_by_uri(const char *uri, nsdb_t *host)
 	if (retval != FEDFS_OK)
 		goto out;
 
-	retval = nsdb_read_nsdbparams(new, NULL);
+	retval = nsdb_read_nsdbparams(new);
 	if (retval != FEDFS_OK)
 		nsdb_free_nsdb(new);
 	else
@@ -1333,7 +1311,7 @@  nsdb_update_default_binddn(const char *hostname, const unsigned short port,
 	nsdb_t host;
 	sqlite3 *db;
 
-	retval = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	retval = nsdb_lookup_nsdb(hostname, port, &host);
 	if (retval != FEDFS_OK)
 		return retval;
 
@@ -1366,7 +1344,7 @@  nsdb_update_default_nce(const char *hostname, const unsigned short port,
 	nsdb_t host;
 	sqlite3 *db;
 
-	retval = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	retval = nsdb_lookup_nsdb(hostname, port, &host);
 	if (retval != FEDFS_OK)
 		return retval;
 
@@ -1399,7 +1377,7 @@  nsdb_update_follow_referrals(const char *hostname, const unsigned short port,
 	nsdb_t host;
 	sqlite3 *db;
 
-	retval = nsdb_lookup_nsdb(hostname, port, &host, NULL);
+	retval = nsdb_lookup_nsdb(hostname, port, &host);
 	if (retval != FEDFS_OK)
 		return retval;
 
diff --git a/src/nfsref/add.c b/src/nfsref/add.c
index ce7f813..cd126d4 100644
--- a/src/nfsref/add.c
+++ b/src/nfsref/add.c
@@ -573,7 +573,7 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 		return FEDFS_ERR_INVAL;
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-annotate.c b/src/nsdbc/nsdb-annotate.c
index ed9cbe1..ddc3c14 100644
--- a/src/nsdbc/nsdb-annotate.c
+++ b/src/nsdbc/nsdb-annotate.c
@@ -228,7 +228,7 @@  main(int argc, char **argv)
 		}
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 432d7b4..d856175 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -225,7 +225,7 @@  main(int argc, char **argv)
 		goto out;
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index b0b31e8..6e4d9bc 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -202,7 +202,7 @@  main(int argc, char **argv)
 		nsdb_create_fsn_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index 30f3e87..cad6d17 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -184,7 +184,7 @@  main(int argc, char **argv)
 		nsdb_delete_fsl_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index 5355a92..8f88d01 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -186,7 +186,7 @@  main(int argc, char **argv)
 		nsdb_delete_fsn_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-delete-nsdb.c b/src/nsdbc/nsdb-delete-nsdb.c
index 2777b51..27f5ae4 100644
--- a/src/nsdbc/nsdb-delete-nsdb.c
+++ b/src/nsdbc/nsdb-delete-nsdb.c
@@ -165,7 +165,7 @@  main(int argc, char **argv)
 		nsdb_delete_nsdb_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-describe.c b/src/nsdbc/nsdb-describe.c
index 944380a..a76f82a 100644
--- a/src/nsdbc/nsdb-describe.c
+++ b/src/nsdbc/nsdb-describe.c
@@ -185,7 +185,7 @@  main(int argc, char **argv)
 		nsdb_describe_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-list.c b/src/nsdbc/nsdb-list.c
index e02761c..50581a4 100644
--- a/src/nsdbc/nsdb-list.c
+++ b/src/nsdbc/nsdb-list.c
@@ -264,7 +264,7 @@  main(int argc, char **argv)
 		nsdb_list_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-nces.c b/src/nsdbc/nsdb-nces.c
index 0c32159..a1befca 100644
--- a/src/nsdbc/nsdb-nces.c
+++ b/src/nsdbc/nsdb-nces.c
@@ -157,7 +157,7 @@  main(int argc, char **argv)
 		nsdb_nces_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-remove-nci.c b/src/nsdbc/nsdb-remove-nci.c
index 0d852d4..9ce9775 100644
--- a/src/nsdbc/nsdb-remove-nci.c
+++ b/src/nsdbc/nsdb-remove-nci.c
@@ -165,7 +165,7 @@  main(int argc, char **argv)
 		nsdb_remove_nci_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-resolve-fsn.c b/src/nsdbc/nsdb-resolve-fsn.c
index 9b93df7..80677a6 100644
--- a/src/nsdbc/nsdb-resolve-fsn.c
+++ b/src/nsdbc/nsdb-resolve-fsn.c
@@ -324,7 +324,7 @@  main(int argc, char **argv)
 		nsdb_resolve_fsn_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-simple-nce.c b/src/nsdbc/nsdb-simple-nce.c
index dca1cdf..8423295 100644
--- a/src/nsdbc/nsdb-simple-nce.c
+++ b/src/nsdbc/nsdb-simple-nce.c
@@ -165,7 +165,7 @@  main(int argc, char **argv)
 		nsdb_simple_nce_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index 80c4047..5427be3 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -199,7 +199,7 @@  main(int argc, char **argv)
 		value = (char *)path_array;
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbc/nsdb-update-nci.c b/src/nsdbc/nsdb-update-nci.c
index 757b080..e210d82 100644
--- a/src/nsdbc/nsdb-update-nci.c
+++ b/src/nsdbc/nsdb-update-nci.c
@@ -173,7 +173,7 @@  main(int argc, char **argv)
 		nsdb_update_nci_usage(progname);
 	}
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		break;
diff --git a/src/nsdbparams/delete.c b/src/nsdbparams/delete.c
index 6b86e3d..564d028 100644
--- a/src/nsdbparams/delete.c
+++ b/src/nsdbparams/delete.c
@@ -205,7 +205,7 @@  nsdbparams_delete(const char *progname, int argc, char **argv)
 	if (!nsdb_init_database())
 		return EXIT_FAILURE;
 
-	status = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	status = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (status) {
 	case FEDFS_OK:
 		nsdb_free_nsdb(host);
diff --git a/src/nsdbparams/show.c b/src/nsdbparams/show.c
index ee70cdc..9a4477e 100644
--- a/src/nsdbparams/show.c
+++ b/src/nsdbparams/show.c
@@ -236,7 +236,7 @@  nsdbparams_show(const char *progname, int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	status = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	status = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (status) {
 	case FEDFS_OK:
 		nsdbparams_show_display(host);
diff --git a/src/nsdbparams/update.c b/src/nsdbparams/update.c
index c436876..7003b24 100644
--- a/src/nsdbparams/update.c
+++ b/src/nsdbparams/update.c
@@ -339,7 +339,7 @@  nsdbparams_update(const char *progname, int argc, char **argv)
 	if (!nsdb_init_database())
 		goto out;
 
-	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL);
+	retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
 	switch (retval) {
 	case FEDFS_OK:
 		nsdb_free_nsdb(host);