diff options
| author | Nalin Dahyabhai <nalin@dahyabhai.net> | 2008-06-21 11:05:59 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin@dahyabhai.net> | 2008-06-21 11:05:59 -0400 |
| commit | 12d60d433105f34fcc7e2b1d28e4c3f7da0bc4ef (patch) | |
| tree | 17ef93debea283b9ec6fc204023815e7d6491254 /src | |
| parent | cd158d753a24f84a096d1c2211cd1da400a66036 (diff) | |
| download | slapi-nis-12d60d433105f34fcc7e2b1d28e4c3f7da0bc4ef.tar.gz slapi-nis-12d60d433105f34fcc7e2b1d28e4c3f7da0bc4ef.tar.xz slapi-nis-12d60d433105f34fcc7e2b1d28e4c3f7da0bc4ef.zip | |
- read the key format list correctly
- log the key formats correctly
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend.c | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/backend.c b/src/backend.c index a6946a1..f650349 100644 --- a/src/backend.c +++ b/src/backend.c @@ -127,9 +127,6 @@ backend_free_strlist(char **strlist) { int i; if (strlist) { - for (i = 0; strlist[i] != NULL; i++) { - free(strlist[i]); - } free(strlist); } } @@ -152,7 +149,7 @@ backend_dup_strlist(char **strlist) } /* Allocate space for the array of pointers (with NULL terminator) and * then the string data. */ - ret = malloc((i + 1) * sizeof(char *) + l); + ret = malloc(((i + 1) * sizeof(char *)) + l); if (ret != NULL) { /* Figure out where the string data will start. */ s = (char *) &ret[i + 1]; @@ -212,6 +209,7 @@ backend_copy_cb_data(const struct backend_map_data *data) NULL; ret->entry_filter = strdup(data->entry_filter); ret->key_formats = backend_dup_strlist(data->key_formats); + ret->n_key_formats = data->n_key_formats; ret->value_format = strdup(data->value_format); if ((ret->domain == NULL) || (ret->map == NULL) || @@ -451,15 +449,14 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, key_formats = malloc((slapi_valueset_count(values) + 1) * (sizeof (char *))); if (key_formats != NULL) { - for (i = 0; i < slapi_valueset_count(values); i++) { - j = slapi_valueset_first_value(values, &value); - if (j != -1) { - cvalue = slapi_value_get_string(value); - key_formats[i] = strdup(cvalue); - } - slapi_vattr_values_free(&values, &actual_attr, - buffer_flags); + for (j = slapi_valueset_first_value(values, &value); + j != -1; + j = slapi_valueset_next_value(values, j, &value)) { + cvalue = slapi_value_get_string(value); + key_formats[i] = strdup(cvalue); } + slapi_vattr_values_free(&values, &actual_attr, + buffer_flags); key_formats[i] = NULL; } } @@ -522,14 +519,21 @@ backend_map_config_read_config(struct plugin_state *state, Slapi_Entry *e, ret->value_format = use_value_format; ret->ref_attrs = NULL; ret->inref_attrs = NULL; - slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, - "initializing map %s in %s (3): " - "filter \"%s\", " - "key \"%s\", " - "value \"%s\"\n", - map, domain, - use_entry_filter, use_key_formats, use_value_format); + ret->n_key_formats = 0; + for (i = 0; + (use_key_formats != NULL) && (use_key_formats[i] != NULL); + i++) { + slapi_log_error(SLAPI_LOG_PLUGIN, + state->plugin_desc->spd_id, + "initializing map %s in %s (3): " + "filter \"%s\", " + "key \"%s\", " + "value \"%s\"\n", + map, domain, + use_entry_filter, + use_key_formats[i], use_value_format); + ret->n_key_formats++; + } } /* Given a directory server entry which represents a map's configuration, set @@ -547,13 +551,21 @@ backend_map_config_entry_add_one(struct plugin_state *state, Slapi_Entry *e, secure = FALSE; backend_map_config_read_config(state, e, domain, map, &secure, &cb_data); + map_cb_data = backend_copy_cb_data(&cb_data); + backend_free_map_data_contents(&cb_data); + if (map_cb_data == NULL) { + slapi_log_error(SLAPI_LOG_PLUGIN, + state->plugin_desc->spd_id, + "incomplete map definition %s in %s (2)\n", + map, domain); + slapi_pblock_destroy(pb); + return 0; + } slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "initializing map %s in %s, secure=%s (2)\n", map, domain, secure ? "yes" : "no"); - map_cb_data = backend_copy_cb_data(&cb_data); - backend_free_map_data_contents(&cb_data); - map_data_set_map(state, domain, map, secure, + map_data_set_map(state, domain, map, map_cb_data->n_key_formats, secure, map_cb_data, &backend_free_map_data); map_data_clear_map(state, domain, map); /* Search under each base in turn, adding the matching directory @@ -782,6 +794,7 @@ backend_startup(struct plugin_state *state) slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "searching \"%s\" for maps\n", state->plugin_base); + sleep(10); slapi_search_internal_set_pb(pb, state->plugin_base, LDAP_SCOPE_ONE, |
