diff mbox

[07/11] nsdbc: Do not follow LDAP referrals during administrator operations

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

Commit Message

Chuck Lever Dec. 14, 2012, 10:38 p.m. UTC
NSDB tools that perform administrative operations are not ever
allowed to follow LDAP referrals.

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

 src/nsdbc/nsdb-annotate.c    |    4 ++++
 src/nsdbc/nsdb-create-fsl.c  |    5 +++++
 src/nsdbc/nsdb-create-fsn.c  |    5 +++++
 src/nsdbc/nsdb-delete-fsl.c  |    5 +++++
 src/nsdbc/nsdb-delete-fsn.c  |    5 +++++
 src/nsdbc/nsdb-delete-nsdb.c |    5 +++++
 src/nsdbc/nsdb-describe.c    |    4 ++++
 src/nsdbc/nsdb-nces.c        |    5 +++++
 src/nsdbc/nsdb-remove-nci.c  |    5 +++++
 src/nsdbc/nsdb-simple-nce.c  |    5 +++++
 src/nsdbc/nsdb-update-fsl.c  |    5 +++++
 src/nsdbc/nsdb-update-nci.c  |    5 +++++
 12 files changed, 58 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/src/nsdbc/nsdb-annotate.c b/src/nsdbc/nsdb-annotate.c
index 2d3acec..c4ad5f4 100644
--- a/src/nsdbc/nsdb-annotate.c
+++ b/src/nsdbc/nsdb-annotate.c
@@ -300,6 +300,10 @@  main(int argc, char **argv)
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		switch (ldap_err) {
+		case LDAP_REFERRAL:
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
 		case LDAP_NO_SUCH_ATTRIBUTE:
 			fprintf(stderr, "Annotation \"%s\" = \"%s\" not found\n",
 				keyword, value);
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 278d14e..845d452 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -289,6 +289,11 @@  main(int argc, char **argv)
 			fprintf(stderr, "NCE %s does not exist\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to create FSL %s: %s\n",
 			fsl_uuid, ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index 5591516..fd53120 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -266,6 +266,11 @@  main(int argc, char **argv)
 			fprintf(stderr, "NCE %s does not exist\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to create FSN: %s\n",
 			ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index 9dc48aa..726845f 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -252,6 +252,11 @@  main(int argc, char **argv)
 			nsdbname, nsdbport, fsl_uuid);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to delete FSL %s: %s\n",
 			fsl_uuid, ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index 3efaeb8..f3927f0 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -261,6 +261,11 @@  main(int argc, char **argv)
 		fprintf(stderr, "FSN %s still has FSL entries\n", fsn_uuid);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		/* XXX: "Operation not allowed on non-leaf" means
 		 *	this FSN still has children FSLs. */
 		fprintf(stderr, "Failed to delete FSN %s: %s\n",
diff --git a/src/nsdbc/nsdb-delete-nsdb.c b/src/nsdbc/nsdb-delete-nsdb.c
index 88b811b..f76d786 100644
--- a/src/nsdbc/nsdb-delete-nsdb.c
+++ b/src/nsdbc/nsdb-delete-nsdb.c
@@ -218,6 +218,11 @@  main(int argc, char **argv)
 		fprintf(stderr, "NCE %s does not exist\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to remove NCE %s: %s\n",
 			nce, ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-describe.c b/src/nsdbc/nsdb-describe.c
index f90cb2a..947cab1 100644
--- a/src/nsdbc/nsdb-describe.c
+++ b/src/nsdbc/nsdb-describe.c
@@ -243,6 +243,10 @@  main(int argc, char **argv)
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
 		switch (ldap_err) {
+		case LDAP_REFERRAL:
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
 		case LDAP_NO_SUCH_OBJECT:
 			fprintf(stderr, "Entry \"%s\" not found\n", entry);
 			break;
diff --git a/src/nsdbc/nsdb-nces.c b/src/nsdbc/nsdb-nces.c
index 523a44b..247ccf6 100644
--- a/src/nsdbc/nsdb-nces.c
+++ b/src/nsdbc/nsdb-nces.c
@@ -199,6 +199,11 @@  main(int argc, char **argv)
 	case FEDFS_OK:
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to list NCEs: %s\n",
 			ldap_err2string(ldap_err));
 		goto out_close;
diff --git a/src/nsdbc/nsdb-remove-nci.c b/src/nsdbc/nsdb-remove-nci.c
index ddbfb9f..4de2b10 100644
--- a/src/nsdbc/nsdb-remove-nci.c
+++ b/src/nsdbc/nsdb-remove-nci.c
@@ -215,6 +215,11 @@  main(int argc, char **argv)
 		fprintf(stderr, "NCE %s does not exist\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to remove NCI for NCE %s: %s\n",
 			nce, ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-simple-nce.c b/src/nsdbc/nsdb-simple-nce.c
index aa8c8fe..d6530cf 100644
--- a/src/nsdbc/nsdb-simple-nce.c
+++ b/src/nsdbc/nsdb-simple-nce.c
@@ -229,6 +229,11 @@  main(int argc, char **argv)
 			"for this NSDB\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to update NCI: %s\n",
 			ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index 413e8b9..cfd7e13 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -260,6 +260,11 @@  main(int argc, char **argv)
 			fprintf(stderr, "NCE %s does not exist\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to update FSL %s: %s\n",
 			fsl_uuid, ldap_err2string(ldap_err));
 		break;
diff --git a/src/nsdbc/nsdb-update-nci.c b/src/nsdbc/nsdb-update-nci.c
index 3fdcaf6..cb057af 100644
--- a/src/nsdbc/nsdb-update-nci.c
+++ b/src/nsdbc/nsdb-update-nci.c
@@ -234,6 +234,11 @@  main(int argc, char **argv)
 			"for this NSDB\n", nce);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
+		if (ldap_err == LDAP_REFERRAL) {
+			fprintf(stderr, "Encountered LDAP referral on %s:%u\n",
+				nsdbname, nsdbport);
+			break;
+		}
 		fprintf(stderr, "Failed to update NCI: %s\n",
 			ldap_err2string(ldap_err));
 		break;