Since we no longer store a DN prefix in the naming context,
nsdb_get_nceprefix_s() is no longer used.

Signed-off-by: Chuck Lever <[email protected]>
---

 src/include/nsdb.h       |    2 
 src/libnsdb/fileserver.c |  272 ----------------------------------------------
 2 files changed, 0 insertions(+), 274 deletions(-)

diff --git a/src/include/nsdb.h b/src/include/nsdb.h
index 14ad8ed..196ef0f 100644
--- a/src/include/nsdb.h
+++ b/src/include/nsdb.h
@@ -321,8 +321,6 @@ FedFsStatus  nsdb_annotation_delete_s(nsdb_t host, const 
char *dn,
  */
 FedFsStatus     nsdb_get_ncedn_s(nsdb_t host, const char *naming_context,
                                char **dn, unsigned int *ldap_err);
-FedFsStatus     nsdb_get_nceprefix_s(nsdb_t host, const char *naming_context,
-                               char **dn, unsigned int *ldap_err);
 FedFsStatus     nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts,
                                unsigned int *ldap_err);
 FedFsStatus     nsdb_find_naming_context_s(nsdb_t host, const char *entry,
diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 52bb991..01bbe11 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -169,278 +169,6 @@ nsdb_new_fedfs_fsl(FedFsFslType type)
 }
 
 /**
- * Parse DN for an LDAP server's NSDB container info
- *
- * @param ld an initialized LDAP descriptor
- * @param message an LDAP_RES_SEARCH_ENTRY message
- * @param nceprefix a NUL-terminated C string containing an NCE prefix 
received from server
- * @param tmp OUT: pointer to a NUL-terminated C string containing resulting DN
- * @return true if successful
- *
- * Caller must free "tmp" with free(3)
- */
-static _Bool
-nsdb_parse_nce_dn(LDAP *ld, LDAPMessage *message,
-               const char *nceprefix, char **tmp)
-{
-       char *dn, *result;
-       size_t size;
-       int rc, len;
-
-       dn = ldap_get_dn(ld, message);
-       if (dn == NULL) {
-               ldap_get_option(ld, LDAP_OPT_RESULT_CODE, &rc);
-               xlog(D_GENERAL, "%s: Failed to parse DN: %s",
-                       __func__, ldap_err2string(rc));
-               return false;
-       }
-
-       /*
-        * If the fedfsNcePrefix value is empty,
-        * the NCE DN is the namingContext.
-        */
-       if (*nceprefix == '\0') {
-               result = strdup(dn);
-               if (result == NULL) {
-                       xlog(D_GENERAL, "%s: No memory", __func__);
-                       goto out_err;
-               }
-               goto out;
-       }
-
-       /*
-        * Otherwise, the NCE DN is the concatenation
-        * of the two strings
-        */
-       size = strlen(nceprefix) + strlen(",") + strlen(dn) + 1;
-       result = malloc(size);
-       if (result == NULL) {
-               xlog(D_GENERAL, "%s: No memory", __func__);
-               goto out_err;
-       }
-
-       len = snprintf(result, size, "%s,%s", nceprefix, dn);
-       if (len < 0 || (size_t)len > size) {
-               xlog(D_GENERAL, "%s: Buffer overflow", __func__);
-               free(result);
-               goto out_err;
-       }
-
-out:
-       ldap_memfree(dn);
-       *tmp = result;
-       return true;
-
-out_err:
-       ldap_memfree(dn);
-       return false;
-}
-
-/**
- * Parse NCE prefix attribute
- *
- * @param ld an initialized LDAP descriptor
- * @param entry an LDAP_RES_SEARCH_ENTRY message
- * @param attr a NUL-terminated C string containing the name of an attribute
- * @param dn OUT: pointer to a NUL-terminated C string containing resulting DN
- * @return a FedFsStatus code
- *
- * Caller must free "dn" with free(3)
- */
-static FedFsStatus
-nsdb_parse_nceprefix_attribute(LDAP *ld, LDAPMessage *entry, char *attr,
-               char **dn)
-{
-       struct berval **values;
-       FedFsStatus retval;
-       char *tmp;
-
-       xlog(D_CALL, "%s: parsing attribute %s", __func__, attr);
-       if (strcasecmp(attr, "fedfsNcePrefix") != 0)
-               return FEDFS_OK;
-
-       values = ldap_get_values_len(ld, entry, attr);
-       if (values == NULL) {
-               xlog(D_GENERAL, "%s: No values found for attribute %s",
-                       __func__, attr);
-               return FEDFS_ERR_NSDB_RESPONSE;
-       }
-       if (values[1] != NULL) {
-               xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
-                       __func__, attr);
-               retval = FEDFS_ERR_NSDB_RESPONSE;
-               goto out_free;
-       }
-
-       if (!nsdb_parse_nce_dn(ld, entry, values[0]->bv_val, &tmp)) {
-               retval = FEDFS_ERR_SVRFAULT;
-               goto out_free;
-       }
-
-       retval = FEDFS_OK;
-       *dn = tmp;
-
-out_free:
-       ldap_value_free_len(values);
-       return retval;
-}
-
-/**
- * Construct DN for an LDAP server's NSDB container
- *
- * @param ld an initialized LDAP descriptor
- * @param entry an LDAP_RES_SEARCH_ENTRY message
- * @param dn OUT: pointer to a NUL-terminated C string containing resulting DN
- * @return a FedFsStatus code
- *
- * Caller must free "dn" with free(3)
- */
-static FedFsStatus
-nsdb_parse_nceprefix_entry(LDAP *ld, LDAPMessage *entry, char **dn)
-{
-       BerElement *field = NULL;
-       FedFsStatus retval;
-       char *attr;
-
-       for (attr = ldap_first_attribute(ld, entry, &field), retval = FEDFS_OK;
-            attr != NULL && retval == FEDFS_OK;
-            attr = ldap_next_attribute(ld, entry, field)) {
-               retval = nsdb_parse_nceprefix_attribute(ld, entry,
-                                                       attr, dn);
-               ldap_memfree(attr);
-       }
-
-       if (field != NULL)
-               ber_free(field, 0);
-       return retval;
-}
-
-/**
- * Get the naming context's NSDB DN, if it has one
- *
- * @param host an initialized and bound nsdb_t object
- * @param naming_context NUL-terminated C string containing one naming context
- * @param dn OUT: pointer to a NUL-terminated C string containing full DN of 
NSDB container
- * @param ldap_err OUT: possibly an LDAP error code
- * @return a FedFsStatus code
- *
- * Caller must free "dn" with free(3)
- *
- * ldapsearch equivalent:
- *
- * @verbatim
-
-   ldapsearch -b "naming_context" -s base (objectClass=*) fedfsNcePrefix
-   @endverbatim
- *
- * The full DN for the NSDB container is constructed and returned in "dn."
- * That is, if the requested naming context is "dc=example,dc=com" and
- * the fedfsNcePrefix attribute in the server's "dc=example,dc=com"
- * entry contains "ou=fedfs", then the string that is returned in "dn"
- * is "ou=fedfs,dc=example,dc=com".
- */
-FedFsStatus
-nsdb_get_nceprefix_s(nsdb_t host, const char *naming_context, char **dn,
-               unsigned int *ldap_err)
-{
-       LDAPMessage *response, *message;
-       char *attrs[2], *tmp = NULL;
-       LDAP *ld = host->fn_ldap;
-       FedFsStatus retval;
-       int rc;
-
-       if (host->fn_ldap == NULL) {
-               xlog(L_ERROR, "%s: NSDB not open", __func__);
-               return FEDFS_ERR_INVAL;
-       }
-
-       if (dn == NULL || ldap_err == NULL) {
-               xlog(L_ERROR, "%s: Invalid parameter", __func__);
-               return FEDFS_ERR_INVAL;
-       }
-
-       attrs[0] = "fedfsNcePrefix";
-       attrs[1] = NULL;
-       rc = ldap_search_ext_s(ld, naming_context, LDAP_SCOPE_BASE,
-                               "(objectClass=*)", attrs, 0, NULL,
-                               NULL, &nsdb_ldap_timeout,
-                               LDAP_NO_LIMIT, &response);
-       switch (rc) {
-       case LDAP_SUCCESS:
-               break;
-       case LDAP_NO_SUCH_OBJECT:
-               xlog(D_GENERAL, "%s: %s is not an NSDB container entry",
-                       __func__, naming_context);
-               return FEDFS_ERR_NSDB_NONCE;
-       default:
-               xlog(D_GENERAL, "%s: Failed to retrieve naming_context "
-                       "entry %s: %s", __func__, naming_context,
-                       ldap_err2string(rc));
-               *ldap_err = rc;
-               return FEDFS_ERR_NSDB_LDAP_VAL;
-       }
-       if (response == NULL) {
-               xlog(D_GENERAL, "%s: Empty LDAP response\n", __func__);
-               return FEDFS_ERR_NSDB_FAULT;
-       }
-
-       rc = ldap_count_messages(ld, response);
-       switch (rc) {
-       case -1:
-               xlog(D_GENERAL, "%s: Empty LDAP response\n", __func__);
-               retval = FEDFS_ERR_NSDB_FAULT;
-               goto out;
-       case 1:
-               xlog(L_ERROR, "Naming context entry %s is inaccessible",
-                       naming_context);
-               retval = FEDFS_ERR_NSDB_NONCE;
-               goto out;
-       default:
-               xlog(D_CALL, "%s: received %d messages", __func__, rc);
-               break;
-       }
-
-       tmp = NULL;
-       retval = FEDFS_OK;
-       for (message = ldap_first_message(ld, response);
-            message != NULL && retval == FEDFS_OK;
-            message = ldap_next_message(ld, message)) {
-               switch (ldap_msgtype(message)) {
-               case LDAP_RES_SEARCH_ENTRY:
-                       retval = nsdb_parse_nceprefix_entry(ld, message, &tmp);
-                       break;
-               case LDAP_RES_SEARCH_REFERENCE:
-                       retval = nsdb_parse_reference(ld, message, ldap_err);
-                       break;
-               case LDAP_RES_SEARCH_RESULT:
-                       retval = nsdb_parse_result(ld, message, ldap_err);
-                       break;
-               default:
-                       xlog(L_ERROR, "%s: Unrecognized LDAP message type",
-                               __func__);
-                       retval = FEDFS_ERR_NSDB_FAULT;
-               }
-       }
-
-       if (retval == FEDFS_OK) {
-               if (tmp == NULL) {
-                       xlog(D_GENERAL, "%s: %s is not an NCE",
-                               __func__, naming_context);
-                       retval = FEDFS_ERR_NSDB_NONCE;
-               } else {
-                       xlog(D_CALL, "%s: %s contains NCE prefix %s",
-                               __func__, naming_context, tmp);
-                       *dn = tmp;
-               }
-       } else
-               free(tmp);
-
-out:
-       ldap_msgfree(response);
-       return retval;
-}
-
-/**
  * Parse fedfsNceDN attribute
  *
  * @param ld an initialized LDAP descriptor


_______________________________________________
fedfs-utils-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel

Reply via email to