diff mbox

[02/11] libnsdb: nsdb_bind() returns incorrect error code

Message ID 20130124183446.13601.64549.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Jan. 24, 2013, 6:34 p.m. UTC
FEDFS_ERR_NSDB_AUTH means our NSDB client could not authenticate the
NSDB.  That authentication is done with an x.509 certificate.  A
user-provided password plays no part.

A missing password is a user input error, thus FEDFS_ERR_INVAL is
the correct error return.

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

 src/libnsdb/ldap.c           |    2 +-
 src/nfsref/add.c             |    3 +++
 src/nfsref/remove.c          |    3 +++
 src/nsdbc/nsdb-annotate.c    |    3 +++
 src/nsdbc/nsdb-create-fsl.c  |    3 +++
 src/nsdbc/nsdb-create-fsn.c  |    3 +++
 src/nsdbc/nsdb-delete-fsl.c  |    3 +++
 src/nsdbc/nsdb-delete-fsn.c  |    3 +++
 src/nsdbc/nsdb-delete-nsdb.c |    3 +++
 src/nsdbc/nsdb-describe.c    |    3 +++
 src/nsdbc/nsdb-remove-nci.c  |    3 +++
 src/nsdbc/nsdb-simple-nce.c  |    3 +++
 src/nsdbc/nsdb-update-fsl.c  |    3 +++
 src/nsdbc/nsdb-update-nci.c  |    3 +++
 14 files changed, 40 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/src/libnsdb/ldap.c b/src/libnsdb/ldap.c
index 7f001a0..cbd56b6 100644
--- a/src/libnsdb/ldap.c
+++ b/src/libnsdb/ldap.c
@@ -562,7 +562,7 @@  nsdb_bind(LDAP *ld, const char *binddn, const char *passwd,
 		secret = nsdb_get_pw();
 		if (secret == NULL) {
 			xlog(D_GENERAL, "No password provided");
-			return FEDFS_ERR_NSDB_AUTH;
+			return FEDFS_ERR_INVAL;
 		}
 	}
 
diff --git a/src/nfsref/add.c b/src/nfsref/add.c
index cd126d4..c99e2a1 100644
--- a/src/nfsref/add.c
+++ b/src/nfsref/add.c
@@ -604,6 +604,9 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		xlog(L_ERROR, "Missing or invalid password");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		xlog(L_ERROR, "Failed to connect to NSDB %s:%u",
 			nsdbname, nsdbport);
diff --git a/src/nfsref/remove.c b/src/nfsref/remove.c
index 8f2f5d0..c40d6dc 100644
--- a/src/nfsref/remove.c
+++ b/src/nfsref/remove.c
@@ -179,6 +179,9 @@  nfsref_remove_delete_fsn(const char *junct_path)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		xlog(L_ERROR, "Missing or invalid password");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		xlog(L_ERROR, "Failed to connect to NSDB %s:%u",
 			nsdb_hostname(host), nsdb_port(host));
diff --git a/src/nsdbc/nsdb-annotate.c b/src/nsdbc/nsdb-annotate.c
index ddc3c14..bd8d6c4 100644
--- a/src/nsdbc/nsdb-annotate.c
+++ b/src/nsdbc/nsdb-annotate.c
@@ -254,6 +254,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index d856175..4089193 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -257,6 +257,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index 6e4d9bc..655f0c6 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -234,6 +234,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index cad6d17..1c45da4 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -216,6 +216,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index 8f88d01..af06a89 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -218,6 +218,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-delete-nsdb.c b/src/nsdbc/nsdb-delete-nsdb.c
index 27f5ae4..b959057 100644
--- a/src/nsdbc/nsdb-delete-nsdb.c
+++ b/src/nsdbc/nsdb-delete-nsdb.c
@@ -191,6 +191,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-describe.c b/src/nsdbc/nsdb-describe.c
index a76f82a..4480786 100644
--- a/src/nsdbc/nsdb-describe.c
+++ b/src/nsdbc/nsdb-describe.c
@@ -211,6 +211,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-remove-nci.c b/src/nsdbc/nsdb-remove-nci.c
index 9ce9775..71f832e 100644
--- a/src/nsdbc/nsdb-remove-nci.c
+++ b/src/nsdbc/nsdb-remove-nci.c
@@ -186,6 +186,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-simple-nce.c b/src/nsdbc/nsdb-simple-nce.c
index 8423295..dfc0cb1 100644
--- a/src/nsdbc/nsdb-simple-nce.c
+++ b/src/nsdbc/nsdb-simple-nce.c
@@ -186,6 +186,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index 5427be3..d5b13cd 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -227,6 +227,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);
diff --git a/src/nsdbc/nsdb-update-nci.c b/src/nsdbc/nsdb-update-nci.c
index e210d82..5277356 100644
--- a/src/nsdbc/nsdb-update-nci.c
+++ b/src/nsdbc/nsdb-update-nci.c
@@ -194,6 +194,9 @@  main(int argc, char **argv)
 	switch (retval) {
 	case FEDFS_OK:
 		break;
+	case FEDFS_ERR_INVAL:
+		fprintf(stderr, "Missing or invalid password\n");
+		goto out_free;
 	case FEDFS_ERR_NSDB_CONN:
 		fprintf(stderr, "Failed to connect to NSDB %s:%u\n",
 			nsdbname, nsdbport);