Patchwork [04/11] nsdbc: Report bind password problems correctly

login
register
mail settings
Submitter Chuck Lever
Date Jan. 24, 2013, 6:35 p.m.
Message ID <20130124183504.13601.22791.stgit@seurat.1015granger.net>
Download mbox | patch
Permalink /patch/215476/
State Accepted
Headers show

Comments

Chuck Lever - Jan. 24, 2013, 6:35 p.m.
nsdb_open_nsdb() reports that a bind password is not working by
returning FEDFS_ERR_NSDB_LDAP_VAL with ldap_err =
LDAP_INVALID_CREDENTIALS.  Have NSDB clients display a specific
and helpful error message in this case.

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

 src/nfsref/add.c             |   12 ++++++++++--
 src/nfsref/remove.c          |   13 ++++++++++---
 src/nsdbc/nsdb-annotate.c    |   11 +++++++++--
 src/nsdbc/nsdb-create-fsl.c  |   11 +++++++++--
 src/nsdbc/nsdb-create-fsn.c  |   11 +++++++++--
 src/nsdbc/nsdb-delete-fsl.c  |   11 +++++++++--
 src/nsdbc/nsdb-delete-fsn.c  |   11 +++++++++--
 src/nsdbc/nsdb-delete-nsdb.c |   11 +++++++++--
 src/nsdbc/nsdb-describe.c    |   11 +++++++++--
 src/nsdbc/nsdb-list.c        |    2 +-
 src/nsdbc/nsdb-nces.c        |    2 +-
 src/nsdbc/nsdb-remove-nci.c  |   11 +++++++++--
 src/nsdbc/nsdb-resolve-fsn.c |    2 +-
 src/nsdbc/nsdb-simple-nce.c  |   11 +++++++++--
 src/nsdbc/nsdb-update-fsl.c  |   11 +++++++++--
 src/nsdbc/nsdb-update-nci.c  |   11 +++++++++--
 16 files changed, 122 insertions(+), 30 deletions(-)

Patch

diff --git a/src/nfsref/add.c b/src/nfsref/add.c
index c99e2a1..5bac936 100644
--- a/src/nfsref/add.c
+++ b/src/nfsref/add.c
@@ -616,8 +616,16 @@  nfsref_add_nfs_fedfs(const char *junct_path, char **argv, int optind)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		xlog(L_ERROR, "Failed to authenticate to NSDB %s:%u: %s",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			xlog(L_ERROR, "Incorrect password for DN %s",
+				binddn);
+			break;
+		default:
+			xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
+				nsdbname, nsdbport,
+				ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
diff --git a/src/nfsref/remove.c b/src/nfsref/remove.c
index c40d6dc..aebd284 100644
--- a/src/nfsref/remove.c
+++ b/src/nfsref/remove.c
@@ -191,9 +191,16 @@  nfsref_remove_delete_fsn(const char *junct_path)
 			nsdb_hostname(host), nsdb_port(host));
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		xlog(L_ERROR, "Failed to authenticate to NSDB %s:%u: %s",
-			nsdb_hostname(host), nsdb_port(host),
-			ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			xlog(L_ERROR, "Incorrect password for DN %s",
+				binddn);
+			break;
+		default:
+			xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
+				nsdb_hostname(host), nsdb_port(host),
+				ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s",
diff --git a/src/nsdbc/nsdb-annotate.c b/src/nsdbc/nsdb-annotate.c
index bd8d6c4..145f857 100644
--- a/src/nsdbc/nsdb-annotate.c
+++ b/src/nsdbc/nsdb-annotate.c
@@ -266,8 +266,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 4089193..9fb65fc 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -269,8 +269,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index 655f0c6..551f47e 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -246,8 +246,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index 1c45da4..36d7ae6 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -228,8 +228,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index af06a89..d2ba0f7 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -230,8 +230,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-delete-nsdb.c b/src/nsdbc/nsdb-delete-nsdb.c
index b959057..8c80ab1 100644
--- a/src/nsdbc/nsdb-delete-nsdb.c
+++ b/src/nsdbc/nsdb-delete-nsdb.c
@@ -203,8 +203,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-describe.c b/src/nsdbc/nsdb-describe.c
index 4480786..20a841d 100644
--- a/src/nsdbc/nsdb-describe.c
+++ b/src/nsdbc/nsdb-describe.c
@@ -223,8 +223,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-list.c b/src/nsdbc/nsdb-list.c
index 50581a4..954d0d5 100644
--- a/src/nsdbc/nsdb-list.c
+++ b/src/nsdbc/nsdb-list.c
@@ -293,7 +293,7 @@  again:
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
+		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
 			nsdbname, nsdbport, ldap_err2string(ldap_err));
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-nces.c b/src/nsdbc/nsdb-nces.c
index a1befca..b298b79 100644
--- a/src/nsdbc/nsdb-nces.c
+++ b/src/nsdbc/nsdb-nces.c
@@ -185,7 +185,7 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
+		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
 			nsdbname, nsdbport, ldap_err2string(ldap_err));
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-remove-nci.c b/src/nsdbc/nsdb-remove-nci.c
index 71f832e..16c0dc5 100644
--- a/src/nsdbc/nsdb-remove-nci.c
+++ b/src/nsdbc/nsdb-remove-nci.c
@@ -198,8 +198,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-resolve-fsn.c b/src/nsdbc/nsdb-resolve-fsn.c
index 80677a6..ab84c50 100644
--- a/src/nsdbc/nsdb-resolve-fsn.c
+++ b/src/nsdbc/nsdb-resolve-fsn.c
@@ -353,7 +353,7 @@  again:
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
+		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
 			nsdbname, nsdbport, ldap_err2string(ldap_err));
 		goto out_free;
 	default:
diff --git a/src/nsdbc/nsdb-simple-nce.c b/src/nsdbc/nsdb-simple-nce.c
index dfc0cb1..47a514f 100644
--- a/src/nsdbc/nsdb-simple-nce.c
+++ b/src/nsdbc/nsdb-simple-nce.c
@@ -198,8 +198,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index d5b13cd..dab318e 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -239,8 +239,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
diff --git a/src/nsdbc/nsdb-update-nci.c b/src/nsdbc/nsdb-update-nci.c
index 5277356..18f9f9b 100644
--- a/src/nsdbc/nsdb-update-nci.c
+++ b/src/nsdbc/nsdb-update-nci.c
@@ -206,8 +206,15 @@  main(int argc, char **argv)
 			nsdbname, nsdbport);
 		goto out_free;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n",
-			nsdbname, nsdbport, ldap_err2string(ldap_err));
+		switch (ldap_err) {
+		case LDAP_INVALID_CREDENTIALS:
+			fprintf(stderr, "Incorrect password for DN %s\n",
+				binddn);
+			break;
+		default:
+			fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",
+				nsdbname, nsdbport, ldap_err2string(ldap_err));
+		}
 		goto out_free;
 	default:
 		fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n",