Since we now store the full NCE DN in the naming context,
nsdb_split_nce_dn_s() is no longer used.

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

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

diff --git a/src/include/nsdb.h b/src/include/nsdb.h
index adb9bfb..859c726 100644
--- a/src/include/nsdb.h
+++ b/src/include/nsdb.h
@@ -323,9 +323,6 @@ 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_split_nce_dn_s(nsdb_t host, const char *nce,
-                               char **context, char **prefix,
-                               unsigned int *ldap_err);
 FedFsStatus     nsdb_find_naming_context_s(nsdb_t host, const char *entry,
                                char **context, unsigned int *ldap_err);
 
diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index ad53605..8ad4515 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -1428,233 +1428,6 @@ out_free:
 }
 
 /**
- * Get a structured DN for the "nce" on "host"
- *
- * @param host an initialized and bound nsdb_t object
- * @param nce a NUL-terminated C string containing the DN of the NSDB container
- * @param nce_dn OUT: a structured LDAPDN for "nce"
- * @param ldap_err OUT: possibly an LDAP error code
- * @return a FedFsStatus code
- *
- * This also tells us if the NCE exists on "host."  Caller must free
- * "nce_dn" with ldap_dnfree(3).
- *
- * ldapsearch equivalent:
- *
- * @verbatim
-
-   ldapsearch -b "nce" -s base "(objectClass=*)"
-   @endverbatim
- *
- */
-static FedFsStatus
-nsdb_get_nce_dn_s(nsdb_t host, const char *nce, LDAPDN *nce_dn,
-               unsigned int *ldap_err)
-{
-       static char *attrs[] = { LDAP_NO_ATTRS, NULL };
-       LDAPMessage *response = NULL;
-       LDAP *ld = host->fn_ldap;
-       FedFsStatus retval;
-       char *dn = NULL;
-       int rc;
-
-       rc = ldap_search_ext_s(ld, nce, LDAP_SCOPE_BASE,
-                               "(objectClass=*)", attrs, 0, NULL, NULL,
-                               NULL, LDAP_NO_LIMIT, &response);
-       switch (rc) {
-       case LDAP_SUCCESS:
-               break;
-       case LDAP_NO_SUCH_OBJECT:
-               xlog(D_GENERAL, "%s: No entry for NCE %s exists",
-                       __func__, nce);
-               return FEDFS_ERR_NSDB_NONCE;
-       default:
-               xlog(D_GENERAL, "%s: LDAP search failed: %s",
-                       __func__, ldap_err2string(rc));
-               *ldap_err = rc;
-               return FEDFS_ERR_NSDB_LDAP_VAL;
-       }
-       if (response == NULL) {
-               xlog(D_GENERAL, "%s: Empty LDAP response", __func__);
-               return FEDFS_ERR_NSDB_FAULT;
-       }
-
-       rc = ldap_count_messages(ld, response);
-       switch (rc) {
-       case -1:
-               xlog(D_GENERAL, "%s: Empty LDAP response", __func__);
-               retval = FEDFS_ERR_NSDB_RESPONSE;
-               goto out;
-       case 1:
-               xlog(D_GENERAL, "%s: No entry for NCE %s exists",
-                       __func__, nce);
-               retval = FEDFS_ERR_NSDB_NONCE;
-               goto out;
-       default:
-               xlog(D_CALL, "%s: received %d messages", __func__, rc);
-       }
-
-       dn = ldap_get_dn(ld, response);
-       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));
-               *ldap_err = rc;
-               retval = FEDFS_ERR_NSDB_LDAP_VAL;
-               goto out;
-       }
-
-       rc = ldap_str2dn(dn, nce_dn, LDAP_DN_FORMAT_LDAPV3);
-       if (rc != LDAP_SUCCESS) {
-               xlog(D_GENERAL, "%s: Failed to construct NCE DN", __func__);
-               *ldap_err = rc;
-               retval = FEDFS_ERR_NSDB_LDAP_VAL;
-               goto out;
-       }
-
-       retval = FEDFS_OK;
-       xlog(D_CALL, "%s: Found '%s'", __func__, dn);
-
-out:
-       ber_memfree(dn);
-       ldap_msgfree(response);
-       return retval;
-}
-
-/**
- * Peel off left-most RDN in "src" and stick it on right end of "dst"
- *
- * @param src IN/OUT: a structured LDAP distinguished name
- * @param dst IN/OUT: a structured LDAP distinguished name
- * @param ldap_err OUT: possibly an LDAP error code
- * @return a FedFsStatus code
- *
- * Caller must free "src" and "dst" with ldap_dnfree(3).
- */
-static FedFsStatus
-nsdb_move_one_rdn(LDAPDN *src, LDAPDN *dst, unsigned int *ldap_err)
-{
-       FedFsStatus retval;
-       LDAPDN dn;
-
-       dn = *src;
-       retval = nsdb_right_append_rdn(dst, dn[0], ldap_err);
-       if (retval != FEDFS_OK)
-               return retval;
-
-       return nsdb_left_remove_rdn(src, ldap_err);
-}
-
-/**
- * Split an NCE DN into a namingContext and a NCE prefix
- *
- * @param host an initialized and bound nsdb_t object
- * @param nce a NUL-terminated C string containing the DN of the NSDB container
- * @param context OUT: a NUL-terminated C string containing a namingContext DN
- * @param prefix OUT: a NUL-terminated C string containing an NCE prefix DN
- * @param ldap_err OUT: possibly an LDAP error code
- * @return a FedFsStatus code
- *
- * An entry at the NCE DN must already exist on this NSDB.  Caller must
- * free "prefix" and "context" with free(3).
- *
- * Strategy:
- *   1. Start with an empty DN as the prefix
- *   2. Retrieve the server's namingContexts list
- *   3. Check if the NCE exists on the NSDB
- *   4. Loop over the namingContexts, matching against the putative NCE DN
- *   4a. If a match is found, use the matched namingContext
- *       and the prefix formed so far
- *   4b. If no match was found, remove the left-most RDN from
- *       the NCE DN, and append it to right end of the prefix
- *       DN; then go back to 4.
- */
-FedFsStatus
-nsdb_split_nce_dn_s(nsdb_t host, const char *nce, char **context,
-               char **prefix, unsigned int *ldap_err)
-{
-       LDAPDN prefix_dn = NULL;
-       LDAPDN tmp_dn = NULL;
-       char **contexts = NULL;
-       char *tmp = NULL;
-       FedFsStatus retval;
-       int i, rc;
-
-       if (host->fn_ldap == NULL) {
-               xlog(L_ERROR, "%s: NSDB not open", __func__);
-               return FEDFS_ERR_INVAL;
-       }
-
-       if (context == NULL || prefix == NULL || ldap_err == NULL) {
-               xlog(L_ERROR, "%s: Invalid parameter", __func__);
-               return FEDFS_ERR_INVAL;
-       }
-
-       retval = nsdb_get_naming_contexts_s(host, &contexts, ldap_err);
-       if (retval != FEDFS_OK)
-               goto out;
-
-       retval = nsdb_get_nce_dn_s(host, nce, &tmp_dn, ldap_err);
-       if (retval != FEDFS_OK)
-               goto out;
-
-again:
-       for (i = 0; contexts[i] != NULL; i++) {
-               _Bool result;
-
-               result = nsdb_compare_dn_string(tmp_dn, contexts[i], ldap_err);
-               if (*ldap_err != LDAP_SUCCESS) {
-                       retval = FEDFS_ERR_NSDB_LDAP_VAL;
-                       goto out;
-               }
-               if (result)
-                       goto match;
-       }
-
-       retval = nsdb_move_one_rdn(&tmp_dn, &prefix_dn, ldap_err);
-       if (retval != FEDFS_OK)
-               goto out;
-       if (tmp_dn == NULL) {
-               xlog(D_GENERAL, "%s: No matching namingContext found",
-                       __func__);
-               /* Pretend user gave us a bogus "nce" string */
-               retval = FEDFS_ERR_INVAL;
-               goto out;
-       }
-       goto again;
-
-match:
-       rc = ldap_dn2str(prefix_dn, &tmp, LDAP_DN_FORMAT_LDAPV3);
-       if (rc != LDAP_SUCCESS) {
-               *ldap_err = rc;
-               retval = FEDFS_ERR_NSDB_LDAP_VAL;
-               goto out;
-       }
-
-       *context = strdup(contexts[i]);
-       *prefix = strdup(tmp);
-       ber_memfree(tmp);
-
-       if (*context == NULL || *prefix == NULL) {
-               free(*prefix);
-               free(*context);
-               xlog(D_GENERAL, "%s: No memory", __func__);
-               retval = FEDFS_ERR_SVRFAULT;
-               goto out;
-       }
-
-       retval = FEDFS_OK;
-
-out:
-       ldap_dnfree(tmp_dn);
-       ldap_dnfree(prefix_dn);
-       nsdb_free_string_array(contexts);
-       xlog(D_CALL, "%s: returning %s",
-               __func__, nsdb_display_fedfsstatus(retval));
-       return retval;
-}
-
-/**
  * See if "entry" ends with one of the items of "contexts"
  *
  * @param entry a NUL-terminated C string containing DN of some entry


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

Reply via email to