summaryrefslogtreecommitdiffstats
path: root/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c')
-rw-r--r--src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c247
1 files changed, 0 insertions, 247 deletions
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
index 55a8eb57e7..02e3b1862b 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c
@@ -974,225 +974,6 @@ cleanup:
}
-/*
- * This function updates a single attribute with a single value of a
- * specified dn. This function is mainly used to update
- * krbRealmReferences, krbKdcServers, krbAdminServers... when KDC,
- * ADMIN, PASSWD servers are associated with some realms or vice
- * versa.
- */
-
-krb5_error_code
-updateAttribute(LDAP *ld, char *dn, char *attribute, char *value)
-{
- int st=0;
- LDAPMod modAttr, *mods[2]={NULL};
- char *values[2]={NULL};
-
- values[0] = value;
-
- /* data to update the {attr,attrval} combination */
- memset(&modAttr, 0, sizeof(modAttr));
- modAttr.mod_type = attribute;
- modAttr.mod_op = LDAP_MOD_ADD;
- modAttr.mod_values = values;
- mods[0] = &modAttr;
-
- /* ldap modify operation */
- st = ldap_modify_ext_s(ld, dn, mods, NULL, NULL);
-
- /* if the {attr,attrval} combination is already present return a success
- * LDAP_ALREADY_EXISTS is for single-valued attribute
- * LDAP_TYPE_OR_VALUE_EXISTS is for multi-valued attribute
- */
- if (st == LDAP_ALREADY_EXISTS || st == LDAP_TYPE_OR_VALUE_EXISTS)
- st = 0;
-
- if (st != 0) {
- st = set_ldap_error (0, st, OP_MOD);
- }
-
- return st;
-}
-
-/*
- * This function deletes a single attribute with a single value of a
- * specified dn. This function is mainly used to delete
- * krbRealmReferences, krbKdcServers, krbAdminServers... when KDC,
- * ADMIN, PASSWD servers are disassociated with some realms or vice
- * versa.
- */
-
-krb5_error_code
-deleteAttribute(LDAP *ld, char *dn, char *attribute, char *value)
-{
- krb5_error_code st=0;
- LDAPMod modAttr, *mods[2]={NULL};
- char *values[2]={NULL};
-
- values[0] = value;
-
- /* data to delete the {attr,attrval} combination */
- memset(&modAttr, 0, sizeof(modAttr));
- modAttr.mod_type = attribute;
- modAttr.mod_op = LDAP_MOD_DELETE;
- modAttr.mod_values = values;
- mods[0] = &modAttr;
-
- /* ldap modify operation */
- st = ldap_modify_ext_s(ld, dn, mods, NULL, NULL);
-
- /* if either the attribute or the attribute value is missing return a success */
- if (st == LDAP_NO_SUCH_ATTRIBUTE || st == LDAP_UNDEFINED_TYPE)
- st = 0;
-
- if (st != 0) {
- st = set_ldap_error (0, st, OP_MOD);
- }
-
- return st;
-}
-
-
-/*
- * This function takes in 2 string arrays, compares them to remove the
- * matching entries. The first array is the original list and the
- * second array is the modified list. Removing the matching entries
- * will result in a reduced array, where the left over first array
- * elements are the deleted entries and the left over second array
- * elements are the added entries. These additions and deletions has
- * resulted in the modified second array.
- */
-
-krb5_error_code
-disjoint_members(char **src, char **dest)
-{
- int i=0, j=0, slen=0, dlen=0;
-
- /* validate the input parameters */
- if (src == NULL || dest == NULL)
- return 0;
-
- /* compute the first array length */
- for (i=0;src[i]; ++i)
- ;
-
- /* return if the length is 0 */
- if (i==0)
- return 0;
-
- /* index of the last element and also the length of the array */
- slen = i-1;
-
- /* compute the second array length */
- for (i=0;dest[i]; ++i)
- ;
-
- /* return if the length is 0 */
- if (i==0)
- return 0;
-
- /* index of the last element and also the length of the array */
- dlen = i-1;
-
- /* check for the similar elements and delete them from both the arrays */
- for (i=0; src[i]; ++i) {
-
- for (j=0; dest[j]; ++j) {
-
- /* if the element are same */
- if (strcasecmp(src[i], dest[j]) == 0) {
- /*
- * If the matched element is in the middle, then copy
- * the last element to the matched index.
- */
- if (i != slen) {
- free (src[i]);
- src[i] = src[slen];
- src[slen] = NULL;
- } else {
- /*
- * If the matched element is the last, free it and
- * set it to NULL.
- */
- free (src[i]);
- src[i] = NULL;
- }
- /* reduce the array length by 1 */
- slen -= 1;
-
- /* repeat the same processing for the second array too */
- if (j != dlen) {
- free(dest[j]);
- dest[j] = dest[dlen];
- dest[dlen] = NULL;
- } else {
- free(dest[j]);
- dest[j] = NULL;
- }
- dlen -=1;
-
- /*
- * The source array is reduced by 1, so reduce the
- * index variable used for source array by 1. No need
- * to adjust the second array index variable as it is
- * reset while entering the inner loop.
- */
- i -= 1;
- break;
- }
- }
- }
- return 0;
-}
-
-/*
- * This function replicates the contents of the src array for later
- * use. Mostly the contents of the src array is obtained from a
- * ldap_search operation and the contents are required for later use.
- */
-
-krb5_error_code
-copy_arrays(char **src, char ***dest, int count)
-{
- krb5_error_code st=0;
- int i=0;
-
- /* validate the input parameters */
- if (src == NULL || dest == NULL)
- return 0;
-
- /* allocate memory for the dest array */
- *dest = (char **) calloc((unsigned) count+1, sizeof(char *));
- if (*dest == NULL) {
- st = ENOMEM;
- goto cleanup;
- }
-
- /* copy the members from src to dest array. */
- for (i=0; i < count && src[i] != NULL; ++i) {
- (*dest)[i] = strdup(src[i]);
- if ((*dest)[i] == NULL) {
- st = ENOMEM;
- goto cleanup;
- }
- }
-
-cleanup:
- /* in case of error free up everything and return */
- if (st != 0) {
- if (*dest != NULL) {
- for (i=0; (*dest)[i]; ++i) {
- free ((*dest)[i]);
- (*dest)[i] = NULL;
- }
- free (*dest);
- *dest = NULL;
- }
- }
- return st;
-}
-
static krb5_error_code
getepochtime(char *strtime, krb5_timestamp *epochtime)
{
@@ -1439,34 +1220,6 @@ format_d (int val)
}
krb5_error_code
-krb5_add_int_arr_mem_ldap_mod(LDAPMod ***mods, char *attribute, int op,
- int *value)
-{
- int i=0, j=0;
- krb5_error_code st=0;
-
- if ((st=krb5_add_member(mods, &i)) != 0)
- return st;
-
- (*mods)[i]->mod_type = strdup(attribute);
- if ((*mods)[i]->mod_type == NULL)
- return ENOMEM;
- (*mods)[i]->mod_op = op;
-
- for (j=0; value[j] != -1; ++j)
- ;
-
- (*mods)[i]->mod_values = malloc(sizeof(char *) * (j+1));
-
- for (j=0; value[j] != -1; ++j) {
- if (((*mods)[i]->mod_values[j] = format_d(value[j])) == NULL)
- return ENOMEM;
- }
- (*mods)[i]->mod_values[j] = NULL;
- return 0;
-}
-
-krb5_error_code
krb5_add_int_mem_ldap_mod(LDAPMod ***mods, char *attribute, int op, int value)
{
int i=0;