summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-02 18:09:22 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-02 18:09:22 -0400
commit53bea9986215588b1b8efd5288dbae911aee5a73 (patch)
treef4d377146fac92be26e0081cd133564210b26d2e /src
parent52910d53411ac7b73b00ee246892fb820bc07b63 (diff)
downloadslapi-nis-53bea9986215588b1b8efd5288dbae911aee5a73.tar.gz
slapi-nis-53bea9986215588b1b8efd5288dbae911aee5a73.tar.xz
slapi-nis-53bea9986215588b1b8efd5288dbae911aee5a73.zip
- make the newly-multiple-choice deref and referred functions return errors
when they fail to find answers in multiple-choice situations, so that we don't end up with empty strings
Diffstat (limited to 'src')
-rw-r--r--src/format.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/format.c b/src/format.c
index bc64a6c..2b20305 100644
--- a/src/format.c
+++ b/src/format.c
@@ -530,7 +530,11 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
0, &ref_buffer_flags) != 0) {
/* No references. */
format_free_parsed_args(argv);
- return 0;
+ if (outbuf_choices == NULL) {
+ return 0;
+ } else {
+ return -ENOENT;
+ }
}
/* Retrieve these attributes from the referred-to entries. */
attrs[0] = ref_attr;
@@ -567,6 +571,10 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
slapi_sdn_free(&refdn);
continue;
}
+ slapi_log_error(SLAPI_LOG_PLUGIN,
+ state->plugin_desc->spd_id,
+ "deref: reading \"%s\" from \"%s\"\n",
+ target_attr, slapi_sdn_get_ndn(refdn));
slapi_sdn_free(&refdn);
/* Pull out the attribute from the referred-to entry. */
if (slapi_vattr_values_get(ref, target_attr, &values,
@@ -641,9 +649,15 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
&actual_ref_attr,
ref_buffer_flags);
format_free_parsed_args(argv);
- if (choices != NULL) {
- format_add_choice(outbuf_choices, outbuf, choices);
- backend_shr_free_strlist(choices);
+ if (outbuf_choices != NULL) {
+ if (choices != NULL) {
+ /* Return the values we found. */
+ format_add_choice(outbuf_choices, outbuf, choices);
+ backend_shr_free_strlist(choices);
+ } else {
+ /* Return a no-result error. */
+ ret = -ENOENT;
+ }
}
return ret;
}
@@ -874,9 +888,16 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
}
free(tndn);
- if ((outbuf_choices != NULL) && (cbdata.choices != NULL)) {
- format_add_choice(outbuf_choices, outbuf, cbdata.choices);
- backend_shr_free_strlist(cbdata.choices);
+ if (outbuf_choices != NULL) {
+ if (cbdata.choices != NULL) {
+ /* Return the values we found. */
+ format_add_choice(outbuf_choices, outbuf,
+ cbdata.choices);
+ backend_shr_free_strlist(cbdata.choices);
+ } else {
+ /* Return a no-result error. */
+ cbdata.ret = -ENOENT;
+ }
}
backend_free_set_config(set_bases, set_filter);
@@ -2149,6 +2170,10 @@ format_get_data_set(struct plugin_state *state, Slapi_Entry *e,
}
combinations *= this_choice->n_values;
}
+ if (combinations == 0) {
+ format_free_choices(choices);
+ return NULL;
+ }
template_len = strlen(template);
ret = malloc((combinations + 1) * sizeof(char *));
if (ret != NULL) {