From 55c1a2ab93d146d8778fe77d14e65720649a669b Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 1/7] src/format.c: use only internal functions inside formatter engine format_get_data_set() is an external interface to the formatter engine. In order to refactor its API, avoid its usage from the internal code. Rename it to format_get_data_set_int() and make format_get_data_set() a wrapper around it. All internal functions would need to call to format_get_data_set_int(). --- diff --git a/src/format.c b/src/format.c index ae4824c..8683049 100644 --- a/src/format.c +++ b/src/format.c @@ -69,6 +69,20 @@ static int format_expand(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list); +static char ** +format_get_data_set_int(struct plugin_state *state, + Slapi_PBlock *pb, Slapi_Entry *e, + const char *group, const char *set, + const char *fmt, const char *disallowed, + const struct slapi_dn **restrict_subtrees, + const struct slapi_dn **ignore_subtrees, + char ***rel_attrs, + char ***ref_attrs, + struct format_inref_attr ***inref_attrs, + struct format_ref_attr_list ***ref_attr_list, + struct format_ref_attr_list ***inref_attr_list, + unsigned int **data_lengths); + static char * xstrndup(const char *start, size_t length) { @@ -1004,12 +1018,12 @@ format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, default_value = argv[1]; } ret = -ENOENT; - values = format_get_data_set(state, pb, e, group, set, - value_format, disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + value_format, disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values == NULL) { if (default_value == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -2128,12 +2142,12 @@ format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set(state, pb, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[i], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -2219,12 +2233,12 @@ format_match_generic(struct plugin_state *state, matches = NULL; count = 0; lengths = NULL; - values = format_get_data_set(state, pb, e, group, set, - argv[0], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[0], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values != NULL) { for (i = 0; values[i] != NULL; i++) { continue; @@ -2802,19 +2816,19 @@ format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Evaluate the value expression to get a list of candidate values. */ - values = format_get_data_set(state, pb, e, group, set, - argv[1], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[1], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "ifeq: error evaluating \"%s\"\n", argv[1]); format_free_parsed_args(argv); - /* Shouldn't be necessary, since format_get_data_set() should - * only ever return a NULL lengths list when it returns NULL, - * but it'll make tools happy. */ + /* Shouldn't be necessary, since format_get_data_set_int() + * should only ever return a NULL lengths list when it returns + * NULL, but it'll make tools happy. */ free(lengths); return -EINVAL; } @@ -2979,12 +2993,12 @@ format_sort(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Evaluate this argument. */ choices = NULL; - values = format_get_data_set(state, pb, e, group, set, - argv[0], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[0], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values != NULL) { /* Walk the list of values. */ for (i = 0; values[i] != NULL; i++) { @@ -3083,12 +3097,12 @@ format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, choices = NULL; for (i = 0; i < argc; i++) { /* Evaluate this argument. */ - values = format_get_data_set(state, pb, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[i], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values != NULL) { /* Walk the list of values. */ for (j = 0; values[j] != NULL; j++) { @@ -3210,30 +3224,30 @@ format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i]); j = (i / 3) * 2; - values[j] = format_get_data_set(state, pb, e, group, set, - argv[i], disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list, - &lengths[j]); + values[j] = format_get_data_set_int(state, pb, e, group, set, + argv[i], disallowed, + restrict_subtrees, + ignore_subtrees, + rel_attrs, + ref_attrs, inref_attrs, + ref_attr_list, + inref_attr_list, + &lengths[j]); if (values[j] != NULL) { n_lists++; } j++; slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i + 1]); - values[j] = format_get_data_set(state, pb, e, group, set, - argv[i + 1], disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list, - &lengths[j]); + values[j] = format_get_data_set_int(state, pb, e, group, set, + argv[i + 1], disallowed, + restrict_subtrees, + ignore_subtrees, + rel_attrs, + ref_attrs, inref_attrs, + ref_attr_list, + inref_attr_list, + &lengths[j]); if (values[j] != NULL) { n_lists++; } else { @@ -3431,12 +3445,12 @@ format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, return -EINVAL; } ret = -ENOENT; - values = format_get_data_set(state, pb, e, group, set, - value_format, disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + value_format, disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values == NULL) { if (default_value == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -3606,12 +3620,12 @@ format_dribble_merge(struct plugin_state *state, Slapi_PBlock *pb, /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "dribble_merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set(state, pb, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - &lengths); + values = format_get_data_set_int(state, pb, e, group, set, + argv[i], disallowed, + restrict_subtrees, ignore_subtrees, + rel_attrs, ref_attrs, inref_attrs, + ref_attr_list, inref_attr_list, + &lengths); if (values == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, @@ -4645,19 +4659,20 @@ format_free_data_set(char **data, unsigned int *data_lengths) } free(data_lengths); } -char ** -format_get_data_set(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, - const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, - unsigned int **data_lengths) + +static char ** +format_get_data_set_int(struct plugin_state *state, + Slapi_PBlock *pb, Slapi_Entry *e, + const char *group, const char *set, + const char *fmt, const char *disallowed, + const struct slapi_dn **restrict_subtrees, + const struct slapi_dn **ignore_subtrees, + char ***rel_attrs, + char ***ref_attrs, + struct format_inref_attr ***inref_attrs, + struct format_ref_attr_list ***ref_attr_list, + struct format_ref_attr_list ***inref_attr_list, + unsigned int **data_lengths) { struct format_choice *choices, *this_choice; struct berval *val; @@ -4775,6 +4790,33 @@ format_get_data_set(struct plugin_state *state, return ret; } +char ** +format_get_data_set(struct plugin_state *state, + Slapi_PBlock *pb, Slapi_Entry *e, + const char *group, const char *set, + const char *fmt, const char *disallowed, + const struct slapi_dn **restrict_subtrees, + const struct slapi_dn **ignore_subtrees, + char ***rel_attrs, + char ***ref_attrs, + struct format_inref_attr ***inref_attrs, + struct format_ref_attr_list ***ref_attr_list, + struct format_ref_attr_list ***inref_attr_list, + unsigned int **data_lengths) +{ + return format_get_data_set_int(state, pb, e, + group, set, + fmt, disallowed, + restrict_subtrees, + ignore_subtrees, + rel_attrs, + ref_attrs, + inref_attrs, + ref_attr_list, + inref_attr_list, + data_lengths); +} + char * format_escape_for_filter(const char *unescaped) { From 0408e6f0ab4cedaf3d7d4d4a2cd59d934a8a981d Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 2/7] src/format.c: use only internal functions inside formatter engine (part 2) format_get_data() is an external interface to the formatter engine. In order to refactor its API, avoid its usage from the internal code. The only place where it is called is format_match_generic(), so replace its use with a corresponding call to format_format(). --- diff --git a/src/format.c b/src/format.c index 8683049..3619871 100644 --- a/src/format.c +++ b/src/format.c @@ -69,6 +69,20 @@ static int format_expand(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list); +static char * +format_format(struct plugin_state *state, Slapi_PBlock *pb, + Slapi_Entry *e, + const char *group, const char *set, + const char *fmt, const char *disallowed, + struct format_choice **choices, + const struct slapi_dn **restrict_subtrees, + const struct slapi_dn **ignore_subtrees, + char ***rel_attrs, char ***ref_attrs, + struct format_inref_attr ***inref_attrs, + struct format_ref_attr_list ***ref_attr_list, + struct format_ref_attr_list ***inref_attr_list, + unsigned int *data_length); + static char ** format_get_data_set_int(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, @@ -2287,18 +2301,19 @@ format_match_generic(struct plugin_state *state, * many matches to store. */ default_value = NULL; if ((default_arg >= 0) && (argv[default_arg] != NULL)) { - default_value = format_get_data(state, pb, e, - group, set, - argv[default_arg], - disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, - inref_attrs, - ref_attr_list, - inref_attr_list, - &default_length); + default_value = format_format(state, pb, e, + group, set, + argv[default_arg], + disallowed, + NULL, + restrict_subtrees, + ignore_subtrees, + rel_attrs, + ref_attrs, + inref_attrs, + ref_attr_list, + inref_attr_list, + &default_length); } if (default_arg < 0) { /* Return all of the matches as a list. */ From aa5e737c9cd033985d06ee0fe0b05dc922c5d7f2 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 3/7] src/format.c: remove pb from the internal functions signatures wrap_pblock_new() takes a parent pblock but never uses it as 389-ds SLAPI has no concept of parent/child pblocks. Remove pblock from the parameters where possible. There are two cases left: - backend_get_set_config() takes pblock and then passes it to wrap_pblock_new() to create a 'child' pblock, we can pass NULL here to avoid changing external API - wrap_search_internal_get_entry() takes pblock and then passes it to wrap_pblock_new() to create a 'child' pblock, we can pass NULL here to avoid changing external API --- diff --git a/src/format.c b/src/format.c index 3619871..e14edce 100644 --- a/src/format.c +++ b/src/format.c @@ -56,8 +56,7 @@ struct format_choice { struct format_choice *next; }; -static int format_expand(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +static int format_expand(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -70,8 +69,7 @@ static int format_expand(struct plugin_state *state, struct format_ref_attr_list ***inref_attr_list); static char * -format_format(struct plugin_state *state, Slapi_PBlock *pb, - Slapi_Entry *e, +format_format(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, struct format_choice **choices, @@ -84,8 +82,7 @@ format_format(struct plugin_state *state, Slapi_PBlock *pb, unsigned int *data_length); static char ** -format_get_data_set_int(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -316,14 +313,16 @@ format_add_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, } static int -format_check_entry_exists(Slapi_PBlock *pb, const char *dn, char *filter, +format_check_entry_exists(const char *dn, char *filter, void *identity) { Slapi_DN *sdn; Slapi_Entry *entry; sdn = slapi_sdn_new_dn_byval(dn); - wrap_search_internal_get_entry(pb, sdn, filter, NULL, &entry, identity); + /* pblock used in wrap_search_internal_get_entry() is a new one, it never + * gets generated from the one we pass */ + wrap_search_internal_get_entry(NULL, sdn, filter, NULL, &entry, identity); slapi_sdn_free(&sdn); if (entry != NULL) { slapi_entry_free(entry); @@ -384,11 +383,10 @@ format_check_dn_location(const char *dn, } static void -format_maybe_add_sdn_list(Slapi_PBlock *pb, - struct slapi_dn ***list, struct slapi_dn ***list2, +format_maybe_add_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, const char *dn, char *filter, void *identity) { - if (format_check_entry_exists(pb, dn, filter, identity) == 0) { + if (format_check_entry_exists(dn, filter, identity) == 0) { format_add_sdn_list(list, list2, dn); } } @@ -996,7 +994,7 @@ format_parse_args(struct plugin_state *state, const char *args, /* Choose the first value of the set of results for the first argument, and if * we get no results, return the second argument. */ static int -format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_first(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1032,7 +1030,7 @@ format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, default_value = argv[1]; } ret = -ENOENT; - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, value_format, disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -1047,7 +1045,7 @@ format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, value_format); ret = -ENOENT; } else { - i = format_expand(state, pb, e, + i = format_expand(state, e, group, set, default_value, NULL, restrict_subtrees, @@ -1088,7 +1086,7 @@ format_first(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * argument, pull out the values for the attribute named by the second * argument, and return a list of those values. */ static int -format_deref_x(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref_x(struct plugin_state *state, Slapi_Entry *e, const char *fname, const char *group, const char *set, char *ref_attr, char *target_attr, char *filter, const char *disallowed, @@ -1157,7 +1155,7 @@ format_deref_x(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, slapi_sdn_free(&refdn); continue; } - wrap_search_internal_get_entry(pb, refdn, filter, attrs, &ref, + wrap_search_internal_get_entry(NULL, refdn, filter, attrs, &ref, state->plugin_identity); if (ref == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -1210,7 +1208,7 @@ format_deref_x(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static int -format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1245,7 +1243,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } ref_attr = argv[0]; target_attr = argv[1]; - ret = format_deref_x(state, pb, e, "deref", group, set, + ret = format_deref_x(state, e, "deref", group, set, ref_attr, target_attr, NULL, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -1256,7 +1254,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static int -format_deref_f(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref_f(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1292,7 +1290,7 @@ format_deref_f(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, ref_attr = argv[0]; filter = argv[1]; target_attr = argv[2]; - ret = format_deref_x(state, pb, e, "deref_f", group, set, + ret = format_deref_x(state, e, "deref_f", group, set, ref_attr, target_attr, filter, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -1307,7 +1305,7 @@ format_deref_f(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * at last, pull out the values for the attribute named by the last argument, * and return a list of those values. */ static int -format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref_rx(struct plugin_state *state, Slapi_Entry *e, const char *fname, const char *group, const char *set, const char **attributes, const char **filters, const char *disallowed, @@ -1391,7 +1389,7 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, continue; } /* Pull up the named entry. */ - wrap_search_internal_get_entry(pb, these[j], + wrap_search_internal_get_entry(NULL, these[j], NULL, attrs, &entry, state->plugin_identity); @@ -1442,13 +1440,13 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Let's visit the named entry this * time, in case we're nesting. */ - format_maybe_add_sdn_list(pb, &these, &these2, + format_maybe_add_sdn_list(&these, &these2, cvalue, list->links[i + 1].filter_str, state->plugin_identity); /* We need to visit the named entry * next time. */ - format_maybe_add_sdn_list(pb, &next, &next2, + format_maybe_add_sdn_list(&next, &next2, cvalue, list->links[i + 1].filter_str, state->plugin_identity); @@ -1495,7 +1493,7 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static int -format_deref_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref_r(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1528,7 +1526,7 @@ format_deref_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, format_free_parsed_args(argv); return -EINVAL; } - ret = format_deref_rx(state, pb, e, "deref_r", + ret = format_deref_rx(state, e, "deref_r", group, set, (const char **) argv, NULL, disallowed, @@ -1542,7 +1540,7 @@ format_deref_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static int -format_deref_rf(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_deref_rf(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1601,7 +1599,7 @@ format_deref_rf(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, filters[i + 1] = argv[i * 2 + 1]; } } - ret = format_deref_rx(state, pb, e, "deref_rf", + ret = format_deref_rx(state, e, "deref_rf", group, set, (const char **) attrs, (const char **) filters, disallowed, @@ -1671,7 +1669,7 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data) return 0; } static int -format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_referred(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1721,7 +1719,8 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * examine. */ set_filter = NULL; set_bases = NULL; - backend_get_set_config(pb, state, group, other_set, + /* wrap_pblock_new() ignores its pblock argument */ + backend_get_set_config(NULL, state, group, other_set, &set_bases, &set_filter); if (set_bases == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, @@ -1775,7 +1774,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, attrs[1] = NULL; for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) { /* Set up the search. */ - local_pb = wrap_pblock_new(pb); + local_pb = slapi_pblock_new(); slapi_search_internal_set_pb(local_pb, set_bases[i], LDAP_SCOPE_SUBTREE, filter, attrs, FALSE, @@ -1878,7 +1877,7 @@ format_referred_r_entry_cb(Slapi_Entry *e, void *cbdata_ptr) * get to the last argument, at which point we return the value of the * attribute named by the final argument. */ static int -format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_referred_r(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -1965,7 +1964,8 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Get the searching parameters for the set which contains the entry, * and all of the referred-to sets, and save them for use at the last * link in the chain. */ - backend_get_set_config(pb, state, group, set, + /* wrap_pblock_new() ignores its argument */ + backend_get_set_config(NULL, state, group, set, &set_bases, &set_filter); for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) { format_add_sdn_list(&(list->links[0].base_sdn_list), @@ -1974,7 +1974,8 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } backend_free_set_config(set_bases, set_filter); for (i = 0; i < list->n_links - 1; i++) { - backend_get_set_config(pb, state, group, argv[i * 2], + /* wrap_pblock_new() ignores its argument */ + backend_get_set_config(NULL, state, group, argv[i * 2], &set_bases, &set_filter); for (j = 0; (set_bases != NULL) && (set_bases[j] != NULL); @@ -2033,7 +2034,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "referred_r: searching under %s" " for \"%s\" (link=1.%d)\n", ndn, filter, i); - local_pb = wrap_pblock_new(pb); + local_pb = slapi_pblock_new(); slapi_search_internal_set_pb(local_pb, ndn, LDAP_SCOPE_SUBTREE, @@ -2074,7 +2075,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "referred_r: searching under %s" " for \"%s\" (link=2.%d)\n", ndn, filter, i); - local_pb = wrap_pblock_new(pb); + local_pb = slapi_pblock_new(); slapi_search_internal_set_pb(local_pb, ndn, LDAP_SCOPE_SUBTREE, @@ -2121,7 +2122,7 @@ format_referred_r(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Evaluate each argument's list of results, after the first, in turn, and * merge them, using the first argument as a separator. */ static int -format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_merge(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2156,7 +2157,7 @@ format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[i], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -2207,8 +2208,7 @@ format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * of the default_arg'th argument if given, or return everything if no * default_arg'th argument was given. */ static int -format_match_generic(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_match_generic(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, int min_args, int default_arg, const char *disallowed, @@ -2247,7 +2247,7 @@ format_match_generic(struct plugin_state *state, matches = NULL; count = 0; lengths = NULL; - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[0], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -2301,7 +2301,7 @@ format_match_generic(struct plugin_state *state, * many matches to store. */ default_value = NULL; if ((default_arg >= 0) && (argv[default_arg] != NULL)) { - default_value = format_format(state, pb, e, + default_value = format_format(state, e, group, set, argv[default_arg], disallowed, @@ -2413,8 +2413,7 @@ format_match_cb(const char *pattern, const char *value, char **argv) return (fnmatch(pattern, value, 0) == 0) ? strdup(value) : NULL; } static int -format_match(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_match(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2426,7 +2425,7 @@ format_match(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, 2, + return format_match_generic(state, e, group, set, args, 2, 2, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2435,8 +2434,7 @@ format_match(struct plugin_state *state, "format_match", format_match_cb); } static int -format_mmatch(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_mmatch(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2448,7 +2446,7 @@ format_mmatch(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, -1, + return format_match_generic(state, e, group, set, args, 2, -1, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2479,8 +2477,7 @@ format_regmatch_cb(const char *pattern, const char *value, char **argv) return format_regmatch_base_cb(pattern, 0, value, argv); } static int -format_regmatch(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_regmatch(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2492,7 +2489,7 @@ format_regmatch(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, 2, + return format_match_generic(state, e, group, set, args, 2, 2, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2501,8 +2498,7 @@ format_regmatch(struct plugin_state *state, "format_regmatch", format_regmatch_cb); } static int -format_mregmatch(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_mregmatch(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2514,7 +2510,7 @@ format_mregmatch(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, -1, + return format_match_generic(state, e, group, set, args, 2, -1, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2528,8 +2524,7 @@ format_regmatchi_cb(const char *pattern, const char *value, char **argv) return format_regmatch_base_cb(pattern, REG_ICASE, value, argv); } static int -format_regmatchi(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_regmatchi(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2541,7 +2536,7 @@ format_regmatchi(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, 2, + return format_match_generic(state, e, group, set, args, 2, 2, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2550,8 +2545,7 @@ format_regmatchi(struct plugin_state *state, "format_regmatchi", format_regmatchi_cb); } static int -format_mregmatchi(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_mregmatchi(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2563,7 +2557,7 @@ format_mregmatchi(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 2, -1, + return format_match_generic(state, e, group, set, args, 2, -1, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2687,8 +2681,7 @@ format_regsub_cb(const char *pattern, const char *value, char **argv) return format_regsub_base_cb(pattern, 0, value, argv); } static int -format_regsub(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_regsub(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2700,7 +2693,7 @@ format_regsub(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 3, 3, + return format_match_generic(state, e, group, set, args, 3, 3, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2709,8 +2702,7 @@ format_regsub(struct plugin_state *state, "format_regsub", format_regsub_cb); } static int -format_mregsub(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_mregsub(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2722,7 +2714,7 @@ format_mregsub(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 3, -1, + return format_match_generic(state, e, group, set, args, 3, -1, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2736,8 +2728,7 @@ format_regsubi_cb(const char *pattern, const char *value, char **argv) return format_regsub_base_cb(pattern, REG_ICASE, value, argv); } static int -format_regsubi(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_regsubi(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2749,7 +2740,7 @@ format_regsubi(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 3, 3, + return format_match_generic(state, e, group, set, args, 3, 3, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2758,8 +2749,7 @@ format_regsubi(struct plugin_state *state, "format_regsubi", format_regsubi_cb); } static int -format_mregsubi(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_mregsubi(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2771,7 +2761,7 @@ format_mregsubi(struct plugin_state *state, struct format_ref_attr_list ***ref_attr_list, struct format_ref_attr_list ***inref_attr_list) { - return format_match_generic(state, pb, e, group, set, args, 3, -1, + return format_match_generic(state, e, group, set, args, 3, -1, disallowed, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -2786,7 +2776,7 @@ format_mregsubi(struct plugin_state *state, * exactly we needed to do the comparison check (specifically, * case-sensitivity). */ static int -format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_ifeq(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2831,7 +2821,7 @@ format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Evaluate the value expression to get a list of candidate values. */ - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[1], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -2874,7 +2864,7 @@ format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Evaluate the argument which corresponds to the output expression and * return its values. */ - ret = format_expand(state, pb, e, group, set, + ret = format_expand(state, e, group, set, argv[matched ? 2 : 3], disallowed, restrict_subtrees, ignore_subtrees, @@ -2889,7 +2879,7 @@ format_ifeq(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* If the expression given as the first argument returns any values, return * them. Otherwise, return the second expression. */ static int -format_default(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_default(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -2920,7 +2910,7 @@ format_default(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Evaluate expressions until we run out of them or succeed. */ for (i = 0; i < argc; i++) { - ret = format_expand(state, pb, e, group, set, + ret = format_expand(state, e, group, set, argv[i], disallowed, restrict_subtrees, ignore_subtrees, @@ -2963,7 +2953,7 @@ format_compare_bv(const void *p1, const void *p2) } static int -format_sort(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_sort(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3008,7 +2998,7 @@ format_sort(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Evaluate this argument. */ choices = NULL; - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[0], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -3071,7 +3061,7 @@ format_sort(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Evaluate all of the arguments, and concatentate all of the lists of results * to produce one long list. */ static int -format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_collect(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3112,7 +3102,7 @@ format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, choices = NULL; for (i = 0; i < argc; i++) { /* Evaluate this argument. */ - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[i], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -3175,7 +3165,7 @@ format_collect(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * list, separating them with an optional separator, padding the lists with a * specified value until all of the elements of all lists have been used. */ static int -format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_link(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3239,7 +3229,7 @@ format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i]); j = (i / 3) * 2; - values[j] = format_get_data_set_int(state, pb, e, group, set, + values[j] = format_get_data_set_int(state, e, group, set, argv[i], disallowed, restrict_subtrees, ignore_subtrees, @@ -3254,7 +3244,7 @@ format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, j++; slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i + 1]); - values[j] = format_get_data_set_int(state, pb, e, group, set, + values[j] = format_get_data_set_int(state, e, group, set, argv[i + 1], disallowed, restrict_subtrees, ignore_subtrees, @@ -3415,7 +3405,7 @@ format_link(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Eliminate duplicate values from the list. */ static int -format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_unique(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3460,7 +3450,7 @@ format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, return -EINVAL; } ret = -ENOENT; - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, value_format, disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -3475,7 +3465,7 @@ format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, value_format); ret = -ENOENT; } else { - i = format_expand(state, pb, e, + i = format_expand(state, e, group, set, default_value, NULL, restrict_subtrees, @@ -3533,8 +3523,7 @@ format_unique(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Produce an internal sequence number. */ static int -format_internal_sequence_number(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_internal_sequence_number(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3580,8 +3569,7 @@ format_internal_sequence_number(struct plugin_state *state, /* Condense the list as much as possible, but possibly still produce multiple * values. */ static int -format_dribble_merge(struct plugin_state *state, Slapi_PBlock *pb, - Slapi_Entry *e, +format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3635,7 +3623,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_PBlock *pb, /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, "dribble_merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set_int(state, pb, e, group, set, + values = format_get_data_set_int(state, e, group, set, argv[i], disallowed, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, @@ -3743,8 +3731,7 @@ format_lookup_fn(const char *fnname) unsigned int i; struct { const char *name; - int (*fct_ptr)(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, + int (*fct_ptr)(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -3853,7 +3840,7 @@ format_check_disallowed(const struct berval *bv, const char *disallowed) * than one, return NULL. If there's more than one, store the values in the * array argument. */ static struct berval -format_single(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_single(struct plugin_state *state, Slapi_Entry *e, const char *attr, const char *disallowed, char ***attrlist, struct berval ***values) { @@ -4090,8 +4077,7 @@ format_trim_value(struct plugin_state *state, struct berval input, * attribute value, perhaps with a default or alternate value, perhaps with a * prefix or suffix stripped, perhaps with internal replacements made. */ static int -format_expand_simple(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_expand_simple(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4197,7 +4183,7 @@ format_expand_simple(struct plugin_state *state, } /* Retrieve the value. */ values = NULL; - tmp = format_single(state, pb, e, attribute, disallowed, + tmp = format_single(state, e, attribute, disallowed, rel_attrs, outbuf_choices ? &values : NULL); if (tmp.bv_val == NULL) { /* The attribute is undefined, or we're treating it as if it @@ -4206,7 +4192,7 @@ format_expand_simple(struct plugin_state *state, if (default_value != NULL) { /* Supply the default value, expanding it if * needed. */ - i = format_expand(state, pb, e, + i = format_expand(state, e, group, set, default_value, NULL, restrict_subtrees, @@ -4227,7 +4213,7 @@ format_expand_simple(struct plugin_state *state, } else { if (alternate_value != NULL) { /* Supply the alternate value. */ - i = format_expand(state, pb, e, + i = format_expand(state, e, group, set, alternate_value, NULL, restrict_subtrees, @@ -4259,7 +4245,7 @@ format_expand_simple(struct plugin_state *state, /* There's a suitable single value available. */ if (alternate_value != NULL) { /* Supply the alternate value. */ - i = format_expand(state, pb, e, + i = format_expand(state, e, group, set, alternate_value, NULL, restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, outbuf_choices, @@ -4297,7 +4283,7 @@ format_expand_simple(struct plugin_state *state, * will also be an expression, treat the entire result as an attribute * specifier and evaluate it, otherwise return it. */ static int -format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, +format_expand(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4313,8 +4299,7 @@ format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, const char *fmtstart, *fmtend, *match, *pair; char *subexp, *fnname, *params, *spd_id; const char *paramstart, *paramend; - int (*formatfn)(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, + int (*formatfn)(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *args, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4374,7 +4359,7 @@ format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Expand the simple expression. */ used = format_expand_simple(state, - pb, e, + e, group, set, subexp, @@ -4484,7 +4469,7 @@ format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, return -ENOSYS; } /* Call the "function". */ - used = (*formatfn)(state, pb, e, + used = (*formatfn)(state, e, group, set, params, disallowed, restrict_subtrees, @@ -4545,8 +4530,7 @@ format_expand(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } static char * -format_format(struct plugin_state *state, - Slapi_PBlock *parent_pb, Slapi_Entry *e, +format_format(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, struct format_choice **choices, @@ -4558,7 +4542,6 @@ format_format(struct plugin_state *state, struct format_ref_attr_list ***inref_attr_list, unsigned int *data_length) { - Slapi_PBlock *pb; char *buf, *ret, *spd_id; int i, buflen; @@ -4576,15 +4559,13 @@ format_format(struct plugin_state *state, return NULL; } - pb = wrap_pblock_new(parent_pb); - i = format_expand(state, pb, e, group, set, + i = format_expand(state, e, group, set, fmt, disallowed, restrict_subtrees, ignore_subtrees, buf, buflen, choices, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list); - slapi_pblock_destroy(pb); if ((i >= 0) && (i < buflen)) { buf[i] = '\0'; ret = xmemdup(buf, i); @@ -4639,8 +4620,8 @@ format_free_data(char *data) } } char * -format_get_data(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_get_data(struct plugin_state *state, Slapi_PBlock *pb /*unused*/, + Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4653,7 +4634,7 @@ format_get_data(struct plugin_state *state, unsigned int *data_length) { unsigned int ignored; - return format_format(state, pb, e, group, set, fmt, + return format_format(state, e, group, set, fmt, disallowed, NULL, restrict_subtrees, ignore_subtrees, rel_attrs, @@ -4676,8 +4657,7 @@ format_free_data_set(char **data, unsigned int *data_lengths) } static char ** -format_get_data_set_int(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4695,7 +4675,7 @@ format_get_data_set_int(struct plugin_state *state, int combinations, groupsize, i, j, k, offset, length, prev_offset; unsigned int template_len; choices = NULL; - template = format_format(state, pb, e, group, set, fmt, disallowed, + template = format_format(state, e, group, set, fmt, disallowed, &choices, restrict_subtrees, ignore_subtrees, rel_attrs, ref_attrs, inref_attrs, ref_attr_list, inref_attr_list, @@ -4806,8 +4786,8 @@ format_get_data_set_int(struct plugin_state *state, } char ** -format_get_data_set(struct plugin_state *state, - Slapi_PBlock *pb, Slapi_Entry *e, +format_get_data_set(struct plugin_state *state, Slapi_PBlock *pb /*unused*/, + Slapi_Entry *e, const char *group, const char *set, const char *fmt, const char *disallowed, const struct slapi_dn **restrict_subtrees, @@ -4819,7 +4799,7 @@ format_get_data_set(struct plugin_state *state, struct format_ref_attr_list ***inref_attr_list, unsigned int **data_lengths) { - return format_get_data_set_int(state, pb, e, + return format_get_data_set_int(state, e, group, set, fmt, disallowed, restrict_subtrees, From bbbfb632214d9ecba894830ccfeb8d2795fee0c5 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 4/7] WIP: use format_state to abstract internals of the formatting engine --- diff --git a/src/format.c b/src/format.c index e14edce..a23f64e 100644 --- a/src/format.c +++ b/src/format.c @@ -56,42 +56,23 @@ struct format_choice { struct format_choice *next; }; -static int format_expand(struct plugin_state *state, Slapi_Entry *e, +static int format_expand(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *fmt, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list); + struct format_choice **outbuf_choices); static char * -format_format(struct plugin_state *state, Slapi_Entry *e, +format_format(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, + const char *fmt, struct format_choice **choices, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, unsigned int *data_length); static char ** -format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, +format_get_data_set_int(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, + const char *fmt, unsigned int **data_lengths); static char * @@ -313,8 +294,42 @@ format_add_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, } static int -format_check_entry_exists(const char *dn, char *filter, - void *identity) +format_search_get_entry_cb(Slapi_Entry *e, void *cb) +{ + Slapi_Entry **ret = cb; + if (*ret) { + slapi_entry_free(*ret); + } + *ret = slapi_entry_dup(e); + return 0; +} + +static int +format_search_get_entry(struct format_state *st, + Slapi_DN *dn, char *filter, char **attrs, + Slapi_Entry **ret_entry) +{ + Slapi_PBlock *pb; + int ret; + + *ret_entry = NULL; + pb = slapi_pblock_new(); + if (pb == NULL) { + return -1; + } + slapi_search_internal_set_pb(pb, slapi_sdn_get_dn(dn), LDAP_SCOPE_BASE, + filter ? filter : "(objectClass=*)", attrs, + FALSE, NULL, NULL, st->plugin_identity, 0); + ret = st->search_callback_pb(st, pb, ret_entry, + NULL, + format_search_get_entry_cb, + NULL); + slapi_pblock_destroy(pb); + return ret; +} + +static int +format_check_entry_exists(struct format_state *st, const char *dn, char *filter) { Slapi_DN *sdn; Slapi_Entry *entry; @@ -322,7 +337,7 @@ format_check_entry_exists(const char *dn, char *filter, sdn = slapi_sdn_new_dn_byval(dn); /* pblock used in wrap_search_internal_get_entry() is a new one, it never * gets generated from the one we pass */ - wrap_search_internal_get_entry(NULL, sdn, filter, NULL, &entry, identity); + format_search_get_entry(st, sdn, filter, NULL, &entry); slapi_sdn_free(&sdn); if (entry != NULL) { slapi_entry_free(entry); @@ -333,29 +348,27 @@ format_check_entry_exists(const char *dn, char *filter, } static int -format_check_sdn_location(const Slapi_DN *sdn, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees) +format_check_sdn_location(struct format_state *st, const Slapi_DN *sdn) { int i; - if (restrict_subtrees != NULL) { - for (i = 0; restrict_subtrees[i] != NULL; i++) { + if (st->config.restrict_subtrees != NULL) { + for (i = 0; st->config.restrict_subtrees[i] != NULL; i++) { if (slapi_sdn_scope_test(sdn, - restrict_subtrees[i], + st->config.restrict_subtrees[i], LDAP_SCOPE_SUBTREE) != 0) { break; } } - if (restrict_subtrees[i] == NULL) { + if (st->config.restrict_subtrees[i] == NULL) { /* Non-empty list, but no match. */ return ENOENT; } } - if (ignore_subtrees != NULL) { - for (i = 0; ignore_subtrees[i] != NULL; i++) { + if (st->config.ignore_subtrees != NULL) { + for (i = 0; st->config.ignore_subtrees[i] != NULL; i++) { if (slapi_sdn_scope_test(sdn, - ignore_subtrees[i], + st->config.ignore_subtrees[i], LDAP_SCOPE_SUBTREE) != 0) { return ENOENT; } @@ -365,28 +378,25 @@ format_check_sdn_location(const Slapi_DN *sdn, } static int -format_check_dn_location(const char *dn, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees) +format_check_dn_location(struct format_state *st, const char *dn) { int ret = ENOENT; Slapi_DN *sdn; sdn = slapi_sdn_new_dn_byref(dn); if (sdn != NULL) { - ret = format_check_sdn_location(sdn, - restrict_subtrees, - ignore_subtrees); + ret = format_check_sdn_location(st, sdn); slapi_sdn_free(&sdn); } return ret; } static void -format_maybe_add_sdn_list(struct slapi_dn ***list, struct slapi_dn ***list2, - const char *dn, char *filter, void *identity) +format_maybe_add_sdn_list(struct format_state *st, + struct slapi_dn ***list, struct slapi_dn ***list2, + const char *dn, char *filter) { - if (format_check_entry_exists(dn, filter, identity) == 0) { + if (format_check_entry_exists(st, dn, filter) == 0) { format_add_sdn_list(list, list2, dn); } } @@ -935,7 +945,7 @@ format_free_parsed_args(char **argv) free(argv); } static int -format_parse_args(struct plugin_state *state, const char *args, +format_parse_args(struct format_state *st, const char *args, int *pargc, char ***pargv) { int i, dq, argc; @@ -991,33 +1001,28 @@ format_parse_args(struct plugin_state *state, const char *args, return 0; } + /* Choose the first value of the set of results for the first argument, and if * we get no results, return the second argument. */ static int -format_first(struct plugin_state *state, Slapi_Entry *e, +format_first(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, i, argc, first, common_length; char **argv, **values; const char *value_format, *default_value; unsigned int *lengths; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "first: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "first: error parsing arguments\n"); format_free_parsed_args(argv); return -EINVAL; @@ -1030,30 +1035,23 @@ format_first(struct plugin_state *state, Slapi_Entry *e, default_value = argv[1]; } ret = -ENOENT; - values = format_get_data_set_int(state, e, group, set, - value_format, disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + value_format, &lengths); if (values == NULL) { if (default_value == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "first: no values for ->%s<-, " "and no default value provided\n", value_format); ret = -ENOENT; } else { - i = format_expand(state, e, + i = format_expand(st, e, group, set, - default_value, NULL, - restrict_subtrees, - ignore_subtrees, + default_value, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); ret = i; } } else { @@ -1086,18 +1084,12 @@ format_first(struct plugin_state *state, Slapi_Entry *e, * argument, pull out the values for the attribute named by the second * argument, and return a list of those values. */ static int -format_deref_x(struct plugin_state *state, Slapi_Entry *e, +format_deref_x(struct format_state *st, Slapi_Entry *e, const char *fname, const char *group, const char *set, char *ref_attr, char *target_attr, - char *filter, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + char *filter, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int i, j; Slapi_Entry *ref; @@ -1110,12 +1102,12 @@ format_deref_x(struct plugin_state *state, Slapi_Entry *e, const struct berval *val; struct berval **choices; /* Note that this map cares about this attribute. */ - if (rel_attrs != NULL) { - format_add_attrlist(rel_attrs, ref_attr); + if (st->config.rel_attrs != NULL) { + format_add_attrlist(st->config.rel_attrs, ref_attr); } /* Note that the attribute in this entry refers to other entries. */ - if (ref_attrs != NULL) { - format_add_attrlist(ref_attrs, ref_attr); + if (st->config.ref_attrs != NULL) { + format_add_attrlist(st->config.ref_attrs, ref_attr); } /* Get the values of the reference attribute from this entry. */ if (slapi_vattr_values_get(e, ref_attr, &ref_values, @@ -1140,39 +1132,36 @@ format_deref_x(struct plugin_state *state, Slapi_Entry *e, refdn = slapi_sdn_new_dn_byval(cref); if (refdn == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: internal error parsing name " "\"%s\"\n", fname, cref); continue; } - if (format_check_sdn_location(refdn, - restrict_subtrees, - ignore_subtrees) != 0) { + if (format_check_sdn_location(st, refdn) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: entry \"%s\" is in a location " "where we don't look\n", fname, cref); slapi_sdn_free(&refdn); continue; } - wrap_search_internal_get_entry(NULL, refdn, filter, attrs, &ref, - state->plugin_identity); + format_search_get_entry(st, refdn, filter, attrs, &ref); if (ref == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: failure reading entry \"%s\"\n", fname, slapi_sdn_get_ndn(refdn)); slapi_sdn_free(&refdn); continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: reading \"%s\" from \"%s\"\n", fname, target_attr, slapi_sdn_get_ndn(refdn)); slapi_sdn_free(&refdn); /* Note that this map cares about this attribute. */ - if (rel_attrs != NULL) { - format_add_attrlist(rel_attrs, target_attr); + if (st->config.rel_attrs != NULL) { + format_add_attrlist(st->config.rel_attrs, target_attr); } /* Pull out the attribute from the referred-to entry. */ if (slapi_vattr_values_get(ref, target_attr, &values, @@ -1208,34 +1197,28 @@ format_deref_x(struct plugin_state *state, Slapi_Entry *e, } static int -format_deref(struct plugin_state *state, Slapi_Entry *e, +format_deref(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int argc, ret; char **argv, *ref_attr, *target_attr; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref: error parsing arguments\n"); return -EINVAL; } if (argc != 2) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref: requires two arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -1243,45 +1226,36 @@ format_deref(struct plugin_state *state, Slapi_Entry *e, } ref_attr = argv[0]; target_attr = argv[1]; - ret = format_deref_x(state, e, "deref", group, set, - ref_attr, target_attr, NULL, disallowed, - restrict_subtrees, ignore_subtrees, - outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + ret = format_deref_x(st, e, "deref", group, set, + ref_attr, target_attr, NULL, + outbuf, outbuf_len, outbuf_choices); format_free_parsed_args(argv); return ret; } static int -format_deref_f(struct plugin_state *state, Slapi_Entry *e, +format_deref_f(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int argc, ret; char **argv, *ref_attr, *filter, *target_attr; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_f: error parsing arguments\n"); return -EINVAL; } if (argc != 3) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_f: requires three arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_f: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -1290,12 +1264,9 @@ format_deref_f(struct plugin_state *state, Slapi_Entry *e, ref_attr = argv[0]; filter = argv[1]; target_attr = argv[2]; - ret = format_deref_x(state, e, "deref_f", group, set, - ref_attr, target_attr, filter, disallowed, - restrict_subtrees, ignore_subtrees, - outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + ret = format_deref_x(st, e, "deref_f", group, set, + ref_attr, target_attr, filter, + outbuf, outbuf_len, outbuf_choices); format_free_parsed_args(argv); return ret; } @@ -1305,18 +1276,11 @@ format_deref_f(struct plugin_state *state, Slapi_Entry *e, * at last, pull out the values for the attribute named by the last argument, * and return a list of those values. */ static int -format_deref_rx(struct plugin_state *state, Slapi_Entry *e, +format_deref_rx(struct format_state *st, Slapi_Entry *e, const char *fname, const char *group, const char *set, const char **attributes, const char **filters, - const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int i, j, k; Slapi_Entry *entry; @@ -1331,16 +1295,17 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, struct format_ref_attr_list *list; /* Note that this map cares about all of these attributes. */ - if (rel_attrs != NULL) { + if (st->config.rel_attrs != NULL) { for (i = 0; attributes[i] != NULL; i++) { - format_add_attrlist(rel_attrs, attributes[i]); + format_add_attrlist(st->config.rel_attrs, attributes[i]); } } /* Note that this list of attributes is used for pulling up data. */ - format_add_ref_attr_list(ref_attr_list, group, set, + format_add_ref_attr_list(st->config.ref_attr_list, group, set, attributes, filters); - list = format_find_ref_attr_list(*ref_attr_list, group, set, + list = format_find_ref_attr_list(*(st->config.ref_attr_list), + group, set, attributes, filters); /* Follow the chain: set up the first link. */ @@ -1368,7 +1333,7 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, dn = slapi_sdn_get_ndn(these[j]); slapi_sdn_get_parent(these[j], parent); slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: noting parent " "\"%s\" for \"%s\"\n", fname, slapi_sdn_get_ndn(parent), @@ -1378,31 +1343,28 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, slapi_sdn_get_ndn(parent)); /* Check if the referred-to entry is in a location that * we care about. */ - if (format_check_sdn_location(these[j], - restrict_subtrees, - ignore_subtrees) != 0) { + if (format_check_sdn_location(st, these[j]) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: entry \"%s\" is in a location " "where we don't look\n", fname, slapi_sdn_get_ndn(these[j])); continue; } /* Pull up the named entry. */ - wrap_search_internal_get_entry(NULL, these[j], - NULL, - attrs, &entry, - state->plugin_identity); + format_search_get_entry(st, these[j], + NULL, + attrs, &entry); if (entry == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: error reading entry " "\"%s\"\n", fname, slapi_sdn_get_dn(these[j])); continue; } else { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: reading entry " "\"%s\" (%d)\n", fname, slapi_sdn_get_dn(these[j]), i); @@ -1413,7 +1375,7 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, &actual_attr, 0, &buffer_flags) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: entry \"%s\" has no " "values for \"%s\"\n", fname, slapi_entry_get_dn(entry), @@ -1433,23 +1395,19 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, } /* If it's in an area that we're * ignoring, then ignore it already. */ - if (format_check_dn_location(cvalue, - restrict_subtrees, - ignore_subtrees) != 0) { + if (format_check_dn_location(st, cvalue) != 0) { continue; } /* Let's visit the named entry this * time, in case we're nesting. */ - format_maybe_add_sdn_list(&these, &these2, + format_maybe_add_sdn_list(st, &these, &these2, cvalue, - list->links[i + 1].filter_str, - state->plugin_identity); + list->links[i + 1].filter_str); /* We need to visit the named entry * next time. */ - format_maybe_add_sdn_list(&next, &next2, + format_maybe_add_sdn_list(st, &next, &next2, cvalue, - list->links[i + 1].filter_str, - state->plugin_identity); + list->links[i + 1].filter_str); } else { /* Get the value. */ bval = slapi_value_get_berval(value); @@ -1459,7 +1417,7 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, } format_add_bv_list(&choices, bval); slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%s: found value " "\"%.*s\" in \"%s\"\n", fname, @@ -1493,82 +1451,66 @@ format_deref_rx(struct plugin_state *state, Slapi_Entry *e, } static int -format_deref_r(struct plugin_state *state, Slapi_Entry *e, +format_deref_r(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc; char **argv; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_r: error parsing arguments\n"); return -EINVAL; } if (argc < 2) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_r: requires at least two arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_r: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); return -EINVAL; } - ret = format_deref_rx(state, e, "deref_r", + ret = format_deref_rx(st, e, "deref_r", group, set, (const char **) argv, NULL, - disallowed, - restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); format_free_parsed_args(argv); return ret; } static int -format_deref_rf(struct plugin_state *state, Slapi_Entry *e, +format_deref_rf(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, n, i; char **argv, **attrs, **filters; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_rf: error parsing arguments\n"); return -EINVAL; } if (argc < 3) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_rf: requires at least three " "arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_rf: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -1578,7 +1520,7 @@ format_deref_rf(struct plugin_state *state, Slapi_Entry *e, n = (argc + 1) / 2; attrs = malloc(sizeof(char *) * (n + 1)); if (attrs == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_rf: out of memory\n"); format_free_parsed_args(argv); return -ENOMEM; @@ -1586,7 +1528,7 @@ format_deref_rf(struct plugin_state *state, Slapi_Entry *e, memset(attrs, 0, sizeof(char *) * (n + 1)); filters = malloc(sizeof(char *) * (n + 1)); if (filters == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "deref_rf: out of memory\n"); free(attrs); format_free_parsed_args(argv); @@ -1599,15 +1541,11 @@ format_deref_rf(struct plugin_state *state, Slapi_Entry *e, filters[i + 1] = argv[i * 2 + 1]; } } - ret = format_deref_rx(state, e, "deref_rf", + ret = format_deref_rx(st, e, "deref_rf", group, set, (const char **) attrs, (const char **) filters, - disallowed, - restrict_subtrees, ignore_subtrees, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); free(filters); free(attrs); format_free_parsed_args(argv); @@ -1619,7 +1557,7 @@ format_deref_rf(struct plugin_state *state, Slapi_Entry *e, * the values for the attribute named by the third argument, and return a list * of those values. */ struct format_referred_cbdata { - struct plugin_state *state; + struct format_state *st; char *attr; struct berval **choices; }; @@ -1636,7 +1574,7 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data) cbdata = callback_data; slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata->state->plugin_desc->spd_id, + cbdata->st->plugin_desc->spd_id, "referred: examining \"%s\" in \%s\"\n", cbdata->attr, slapi_entry_get_ndn(e)); @@ -1645,7 +1583,7 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data) &disposition, &actual_attr, 0, &buffer_flags) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata->state->plugin_desc->spd_id, + cbdata->st->plugin_desc->spd_id, "referred: no values for \"%s\" in \"%s\"\n", cbdata->attr, slapi_entry_get_ndn(e)); return 0; @@ -1659,7 +1597,7 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data) continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata->state->plugin_desc->spd_id, + cbdata->st->plugin_desc->spd_id, "referred: got %d-byte value for \"%s\"\n", (int) val->bv_len, actual_attr); /* Add it to the list of values we've retrieved. */ @@ -1669,17 +1607,11 @@ format_referred_entry_cb(Slapi_Entry *e, void *callback_data) return 0; } static int -format_referred(struct plugin_state *state, Slapi_Entry *e, +format_referred(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int i, ret, argc; Slapi_PBlock *local_pb; @@ -1687,20 +1619,20 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, char *other_set, *set_filter, **set_bases, *use_filter; struct format_referred_cbdata cbdata; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred: error parsing arguments\n"); return -EINVAL; } if (argc != 3) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred: requires 3 arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred: returns a list, but a list would " "not be appropriate here\n"); format_free_parsed_args(argv); @@ -1711,7 +1643,7 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, attr = argv[2]; /* Set up to search for matches. */ - cbdata.state = state; + cbdata.st = st; cbdata.attr = attr; cbdata.choices = NULL; @@ -1719,28 +1651,27 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, * examine. */ set_filter = NULL; set_bases = NULL; - /* wrap_pblock_new() ignores its pblock argument */ - backend_get_set_config(NULL, state, group, other_set, - &set_bases, &set_filter); + st->get_bases_filter(st, group, other_set, + &set_bases, &set_filter); if (set_bases == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "no search bases defined for \"%s\"/\"%s\"?\n", group, other_set); - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); format_free_parsed_args(argv); return -ENOENT; } /* Note that this map cares about both attributes. */ - if (rel_attrs != NULL) { - format_add_attrlist(rel_attrs, other_attr); - format_add_attrlist(rel_attrs, attr); + if (st->config.rel_attrs != NULL) { + format_add_attrlist(st->config.rel_attrs, other_attr); + format_add_attrlist(st->config.rel_attrs, attr); } /* Note that the attribute in this map refers to this entry. */ - if (inref_attrs != NULL) { - format_add_inref_attrs(inref_attrs, group, + if (st->config.inref_attrs != NULL) { + format_add_inref_attrs(st->config.inref_attrs, group, other_set, other_attr); } @@ -1749,9 +1680,9 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, tndn = format_escape_for_filter(slapi_entry_get_ndn(e)); if (tndn == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "referred: out of memory\n"); - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); format_free_parsed_args(argv); return -ENOMEM; } @@ -1759,10 +1690,10 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, filter = malloc(strlen(use_filter) + strlen(other_attr) + strlen(tndn) + 7); if (filter == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred: out of memory\n"); free(tndn); - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); format_free_parsed_args(argv); return -ENOMEM; } @@ -1779,21 +1710,23 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, set_bases[i], LDAP_SCOPE_SUBTREE, filter, attrs, FALSE, NULL, NULL, - state->plugin_identity, 0); + st->plugin_identity, 0); /* Let the callback do the work of saving a value. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "searching under \"%s\" for \"%s\"\n", set_bases[i], filter); - slapi_search_internal_callback_pb(local_pb, &cbdata, - NULL, - format_referred_entry_cb, - NULL); + (void) st->search_callback_pb(st, + local_pb, + &cbdata, + NULL, + format_referred_entry_cb, + NULL); slapi_pblock_destroy(local_pb); } free(filter); - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); format_free_parsed_args(argv); /* Return any values we found. */ @@ -1807,7 +1740,7 @@ format_referred(struct plugin_state *state, Slapi_Entry *e, /* Add the name of this entry to the DN list in the cbdata. */ struct format_referred_r_entry_cbdata { - struct plugin_state *state; + struct format_state *st; char *attribute; struct berval ***choices; Slapi_DN ***sdn_list, ***sdn_list2; @@ -1825,7 +1758,7 @@ format_referred_r_entry_cb(Slapi_Entry *e, void *cbdata_ptr) char *actual_attr; /* Note that we visited this entry. */ - slapi_log_error(SLAPI_LOG_PLUGIN, cbdata->state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, cbdata->st->plugin_desc->spd_id, "search matched entry \"%s\"\n", slapi_entry_get_dn(e)); format_add_sdn_list(cbdata->sdn_list, cbdata->sdn_list2, slapi_entry_get_dn(e)); @@ -1839,7 +1772,7 @@ format_referred_r_entry_cb(Slapi_Entry *e, void *cbdata_ptr) &actual_attr, 0, &buffer_flags) != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata->state->plugin_desc->spd_id, + cbdata->st->plugin_desc->spd_id, "referred_r: entry \"%s\" has no " "values for \"%s\"\n", slapi_sdn_get_dn(sdn), @@ -1857,7 +1790,7 @@ format_referred_r_entry_cb(Slapi_Entry *e, void *cbdata_ptr) } format_add_bv_list(cbdata->choices, bval); slapi_log_error(SLAPI_LOG_PLUGIN, - cbdata->state->plugin_desc->spd_id, + cbdata->st->plugin_desc->spd_id, "referred_r: found value " "\"%.*s\" in \"%s\"\n", (int) bval->bv_len, @@ -1877,17 +1810,11 @@ format_referred_r_entry_cb(Slapi_Entry *e, void *cbdata_ptr) * get to the last argument, at which point we return the value of the * attribute named by the final argument. */ static int -format_referred_r(struct plugin_state *state, Slapi_Entry *e, +format_referred_r(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int i, j, k, ret, argc, attrs_list_length; Slapi_PBlock *local_pb; @@ -1900,27 +1827,27 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, char *set_filter, **set_bases; const char **attr_links, *ndn; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred_r: error parsing arguments\n"); return -EINVAL; } if (argc < 3) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred_r: requires at least 3 arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if ((argc % 2) != 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred_r: requires an odd number of " "arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred_r: returns a list, but a list would " "not be appropriate here\n"); format_free_parsed_args(argv); @@ -1933,7 +1860,7 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, attrs_list_length = (argc + 1) / 2; attr_links = malloc((attrs_list_length + 1) * sizeof(char *)); if (attr_links == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "referred_r: out of memory\n"); format_free_parsed_args(argv); return -ENOMEM; @@ -1948,16 +1875,16 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, attr_links[i] = NULL; /* Note that this map cares about these attributes. */ - if (rel_attrs != NULL) { - format_add_attrlist(rel_attrs, attr); + if (st->config.rel_attrs != NULL) { + format_add_attrlist(st->config.rel_attrs, attr); for (i = 0; attr_links[i] != NULL; i++) { - format_add_attrlist(rel_attrs, attr_links[i]); + format_add_attrlist(st->config.rel_attrs, attr_links[i]); } } /* Note this list of attributes. */ - format_add_ref_attr_list(inref_attr_list, group, set, attr_links, NULL); - list = format_find_ref_attr_list(*inref_attr_list, group, set, + format_add_ref_attr_list(st->config.inref_attr_list, group, set, attr_links, NULL); + list = format_find_ref_attr_list(*(st->config.inref_attr_list), group, set, attr_links, NULL); free(attr_links); @@ -1965,18 +1892,18 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, * and all of the referred-to sets, and save them for use at the last * link in the chain. */ /* wrap_pblock_new() ignores its argument */ - backend_get_set_config(NULL, state, group, set, - &set_bases, &set_filter); + st->get_bases_filter(st, group, set, + &set_bases, &set_filter); for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) { format_add_sdn_list(&(list->links[0].base_sdn_list), &(list->links[0].base_sdn_list2), set_bases[i]); } - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); for (i = 0; i < list->n_links - 1; i++) { /* wrap_pblock_new() ignores its argument */ - backend_get_set_config(NULL, state, group, argv[i * 2], - &set_bases, &set_filter); + st->get_bases_filter(st, group, argv[i * 2], + &set_bases, &set_filter); for (j = 0; (set_bases != NULL) && (set_bases[j] != NULL); j++) { @@ -1984,7 +1911,7 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, &(list->links[i + 1].base_sdn_list2), set_bases[j]); } - backend_free_set_config(set_bases, set_filter); + st->free_bases_filter(st, &set_bases, &set_filter); } /* Walk the chain, searching for entries which refer to entries at @@ -2030,7 +1957,7 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, ndn = slapi_sdn_get_dn(these_bases[k]); /* Search for referrers under this tree. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "referred_r: searching under %s" " for \"%s\" (link=1.%d)\n", ndn, filter, i); @@ -2041,18 +1968,19 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, filter, attrs, FALSE, NULL, NULL, - state->plugin_identity, + st->plugin_identity, 0); - entry_cbdata.state = state; + entry_cbdata.st = st; entry_cbdata.attribute = attr; entry_cbdata.choices = &choices; entry_cbdata.sdn_list = &these_entries; entry_cbdata.sdn_list2 = &these_entries2; - slapi_search_internal_callback_pb(local_pb, - &entry_cbdata, - NULL, - format_referred_r_entry_cb, - NULL); + (void) st->search_callback_pb(st, + local_pb, + &entry_cbdata, + NULL, + format_referred_r_entry_cb, + NULL); slapi_pblock_destroy(local_pb); } free(filter); @@ -2071,7 +1999,7 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, ndn = slapi_sdn_get_dn(next_bases[k]); /* Search for referrers under that tree. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "referred_r: searching under %s" " for \"%s\" (link=2.%d)\n", ndn, filter, i); @@ -2082,18 +2010,19 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, filter, attrs, FALSE, NULL, NULL, - state->plugin_identity, + st->plugin_identity, 0); - entry_cbdata.state = state; + entry_cbdata.st = st; entry_cbdata.attribute = attr; entry_cbdata.choices = &choices; entry_cbdata.sdn_list = &next_entries; entry_cbdata.sdn_list2 = &next_entries2; - slapi_search_internal_callback_pb(local_pb, - &entry_cbdata, - NULL, - format_referred_r_entry_cb, - NULL); + (void) st->search_callback_pb(st, + local_pb, + &entry_cbdata, + NULL, + format_referred_r_entry_cb, + NULL); slapi_pblock_destroy(local_pb); } free(filter); @@ -2122,31 +2051,25 @@ format_referred_r(struct plugin_state *state, Slapi_Entry *e, /* Evaluate each argument's list of results, after the first, in turn, and * merge them, using the first argument as a separator. */ static int -format_merge(struct plugin_state *state, Slapi_Entry *e, +format_merge(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, i, j, argc, slen, count; unsigned int *lengths; char **argv, **values; const char *sep; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "merge: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "merge: requires at least one argument\n"); format_free_parsed_args(argv); return -EINVAL; @@ -2155,17 +2078,14 @@ format_merge(struct plugin_state *state, Slapi_Entry *e, slen = strlen(sep); for (i = 1, ret = 0, count = 0; i < argc; i++) { /* Expand this argument. */ - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set_int(state, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[i], &lengths); if (values == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "merge: no values for ->%s<-\n", argv[i]); continue; @@ -2175,7 +2095,7 @@ format_merge(struct plugin_state *state, Slapi_Entry *e, if (ret + lengths[j] + (count ? slen : 0) > (unsigned int) outbuf_len) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "merge: out of space\n"); format_free_data_set(values, lengths); format_free_parsed_args(argv); @@ -2183,7 +2103,7 @@ format_merge(struct plugin_state *state, Slapi_Entry *e, } /* Log this value. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "merge: got %d-byte value for ->%s<\n", lengths[j], argv[i]); /* If this isn't the first result, fill in the @@ -2208,19 +2128,11 @@ format_merge(struct plugin_state *state, Slapi_Entry *e, * of the default_arg'th argument if given, or return everything if no * default_arg'th argument was given. */ static int -format_match_generic(struct plugin_state *state, Slapi_Entry *e, +format_match_generic(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, const char *args, int min_args, int default_arg, - const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, char *outbuf, int outbuf_len, struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, const char *fnname, char * (*match_fn)(const char *pattern, const char *value, char **argv)) @@ -2229,8 +2141,8 @@ format_match_generic(struct plugin_state *state, Slapi_Entry *e, int i, count, argc, ret, len; unsigned int *lengths, default_length; - plugin_id = state->plugin_desc->spd_id; - ret = format_parse_args(state, args, &argc, &argv); + plugin_id = st->plugin_desc->spd_id; + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { slapi_log_error(SLAPI_LOG_PLUGIN, plugin_id, "%s: error parsing arguments\n", fnname); @@ -2247,11 +2159,8 @@ format_match_generic(struct plugin_state *state, Slapi_Entry *e, matches = NULL; count = 0; lengths = NULL; - values = format_get_data_set_int(state, e, group, set, - argv[0], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[0], &lengths); if (values != NULL) { for (i = 0; values[i] != NULL; i++) { @@ -2301,18 +2210,10 @@ format_match_generic(struct plugin_state *state, Slapi_Entry *e, * many matches to store. */ default_value = NULL; if ((default_arg >= 0) && (argv[default_arg] != NULL)) { - default_value = format_format(state, e, + default_value = format_format(st, e, group, set, argv[default_arg], - disallowed, NULL, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, - inref_attrs, - ref_attr_list, - inref_attr_list, &default_length); } if (default_arg < 0) { @@ -2413,45 +2314,25 @@ format_match_cb(const char *pattern, const char *value, char **argv) return (fnmatch(pattern, value, 0) == 0) ? strdup(value) : NULL; } static int -format_match(struct plugin_state *state, Slapi_Entry *e, +format_match(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, 2, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, 2, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_match", format_match_cb); } static int -format_mmatch(struct plugin_state *state, Slapi_Entry *e, +format_mmatch(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, -1, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, -1, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_mmatch", format_match_cb); } @@ -2477,45 +2358,25 @@ format_regmatch_cb(const char *pattern, const char *value, char **argv) return format_regmatch_base_cb(pattern, 0, value, argv); } static int -format_regmatch(struct plugin_state *state, Slapi_Entry *e, +format_regmatch(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, 2, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, 2, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_regmatch", format_regmatch_cb); } static int -format_mregmatch(struct plugin_state *state, Slapi_Entry *e, +format_mregmatch(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, -1, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, -1, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_mregmatch", format_regmatch_cb); } static char * @@ -2524,45 +2385,25 @@ format_regmatchi_cb(const char *pattern, const char *value, char **argv) return format_regmatch_base_cb(pattern, REG_ICASE, value, argv); } static int -format_regmatchi(struct plugin_state *state, Slapi_Entry *e, +format_regmatchi(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, 2, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, 2, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_regmatchi", format_regmatchi_cb); } static int -format_mregmatchi(struct plugin_state *state, Slapi_Entry *e, +format_mregmatchi(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 2, -1, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 2, -1, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_mregmatchi", format_regmatchi_cb); } @@ -2681,45 +2522,25 @@ format_regsub_cb(const char *pattern, const char *value, char **argv) return format_regsub_base_cb(pattern, 0, value, argv); } static int -format_regsub(struct plugin_state *state, Slapi_Entry *e, +format_regsub(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 3, 3, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 3, 3, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_regsub", format_regsub_cb); } static int -format_mregsub(struct plugin_state *state, Slapi_Entry *e, +format_mregsub(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 3, -1, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 3, -1, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_mregsub", format_regsub_cb); } static char * @@ -2728,45 +2549,25 @@ format_regsubi_cb(const char *pattern, const char *value, char **argv) return format_regsub_base_cb(pattern, REG_ICASE, value, argv); } static int -format_regsubi(struct plugin_state *state, Slapi_Entry *e, +format_regsubi(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 3, 3, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 3, 3, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_regsubi", format_regsubi_cb); } static int -format_mregsubi(struct plugin_state *state, Slapi_Entry *e, +format_mregsubi(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { - return format_match_generic(state, e, group, set, args, 3, -1, - disallowed, - restrict_subtrees, ignore_subtrees, + return format_match_generic(st, e, group, set, args, 3, -1, outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, "format_mregsubi", format_regsubi_cb); } @@ -2776,17 +2577,11 @@ format_mregsubi(struct plugin_state *state, Slapi_Entry *e, * exactly we needed to do the comparison check (specifically, * case-sensitivity). */ static int -format_ifeq(struct plugin_state *state, Slapi_Entry *e, +format_ifeq(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, i; unsigned int *lengths; @@ -2795,20 +2590,20 @@ format_ifeq(struct plugin_state *state, Slapi_Entry *e, struct berval bv; Slapi_Value *value; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "ifeq: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "ifeq: error parsing arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (argc != 4) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "ifeq: expected four arguments (got %d)\n", argc); format_free_parsed_args(argv); @@ -2816,19 +2611,16 @@ format_ifeq(struct plugin_state *state, Slapi_Entry *e, } /* Note that this map cares about the tested attribute. */ - if (rel_attrs != NULL) { - format_add_attrlist(rel_attrs, argv[0]); + if (st->config.rel_attrs != NULL) { + format_add_attrlist(st->config.rel_attrs, argv[0]); } /* Evaluate the value expression to get a list of candidate values. */ - values = format_get_data_set_int(state, e, group, set, - argv[1], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[1], &lengths); if (values == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "ifeq: error evaluating \"%s\"\n", argv[1]); format_free_parsed_args(argv); /* Shouldn't be necessary, since format_get_data_set_int() @@ -2856,7 +2648,7 @@ format_ifeq(struct plugin_state *state, Slapi_Entry *e, } } slapi_value_free(&value); - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "ifeq: \"%s\" %s \"%s\"\n", argv[0], matched ? "matches" : "doesn't match", argv[1]); @@ -2864,14 +2656,10 @@ format_ifeq(struct plugin_state *state, Slapi_Entry *e, /* Evaluate the argument which corresponds to the output expression and * return its values. */ - ret = format_expand(state, e, group, set, - argv[matched ? 2 : 3], disallowed, - restrict_subtrees, - ignore_subtrees, + ret = format_expand(st, e, group, set, + argv[matched ? 2 : 3], outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); format_free_parsed_args(argv); return ret; } @@ -2879,29 +2667,23 @@ format_ifeq(struct plugin_state *state, Slapi_Entry *e, /* If the expression given as the first argument returns any values, return * them. Otherwise, return the second expression. */ static int -format_default(struct plugin_state *state, Slapi_Entry *e, +format_default(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, i; char **argv; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "default: error parsing arguments\n"); return -EINVAL; } if (argc < 2) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "default: expected at least two arguments " "(got %d)\n", argc); @@ -2910,14 +2692,10 @@ format_default(struct plugin_state *state, Slapi_Entry *e, } /* Evaluate expressions until we run out of them or succeed. */ for (i = 0; i < argc; i++) { - ret = format_expand(state, e, group, set, - argv[i], disallowed, - restrict_subtrees, - ignore_subtrees, + ret = format_expand(st, e, group, set, + argv[i], outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); if (ret >= 0) { break; } @@ -2953,43 +2731,37 @@ format_compare_bv(const void *p1, const void *p2) } static int -format_sort(struct plugin_state *state, Slapi_Entry *e, +format_sort(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, i; unsigned int *lengths; char **argv, **values; struct berval bv, **choices; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "sort: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "sort: one argument is required\n"); format_free_parsed_args(argv); return -EINVAL; } if (argc > 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "sort: only one argument is allowed\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "sort: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -2998,11 +2770,8 @@ format_sort(struct plugin_state *state, Slapi_Entry *e, /* Evaluate this argument. */ choices = NULL; - values = format_get_data_set_int(state, e, group, set, - argv[0], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[0], &lengths); if (values != NULL) { /* Walk the list of values. */ @@ -3011,20 +2780,20 @@ format_sort(struct plugin_state *state, Slapi_Entry *e, bv.bv_val = values[i]; bv.bv_len = lengths[i]; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "sort: input %d = \"%.*s\"\n", i + 1, (int) bv.bv_len, bv.bv_val); format_add_bv_list(&choices, &bv); } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "sort: expanded \"%s\" to produce " "%d values for \"%s\"\n", argv[0], i, slapi_entry_get_dn(e)); format_free_data_set(values, lengths); } else { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "sort: expanding \"%s\" produced " "no values for \"%s\"\n", argv[0], slapi_entry_get_dn(e)); @@ -3035,7 +2804,7 @@ format_sort(struct plugin_state *state, Slapi_Entry *e, qsort(choices, i, sizeof(choices[0]), format_compare_bv); for (i = 0; choices[i] != NULL; i++) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "sort: returning \"%.*s\" as a " "value for \"%s\"\n", (int) choices[i]->bv_len, @@ -3044,7 +2813,7 @@ format_sort(struct plugin_state *state, Slapi_Entry *e, continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "sort: returning %d values for \"%s\"\n", i, slapi_entry_get_dn(e)); format_add_choice(outbuf_choices, outbuf, &choices); @@ -3058,40 +2827,34 @@ format_sort(struct plugin_state *state, Slapi_Entry *e, return ret; } -/* Evaluate all of the arguments, and concatentate all of the lists of results +/* Evaluate all of the arguments, and concatenate all of the lists of results * to produce one long list. */ static int -format_collect(struct plugin_state *state, Slapi_Entry *e, +format_collect(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, i, j; unsigned int *lengths; char **argv, **values; struct berval bv, **choices; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "collect: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "collect: error parsing arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "collect: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -3102,11 +2865,8 @@ format_collect(struct plugin_state *state, Slapi_Entry *e, choices = NULL; for (i = 0; i < argc; i++) { /* Evaluate this argument. */ - values = format_get_data_set_int(state, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[i], &lengths); if (values != NULL) { /* Walk the list of values. */ @@ -3115,20 +2875,20 @@ format_collect(struct plugin_state *state, Slapi_Entry *e, bv.bv_val = values[j]; bv.bv_len = lengths[j]; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "collect: \"%.*s\"\n", (int) bv.bv_len, bv.bv_val); format_add_bv_list(&choices, &bv); } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "collect: expanded \"%s\" to produce " "%d values for \"%s\"\n", argv[i], j, slapi_entry_get_dn(e)); format_free_data_set(values, lengths); } else { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "collect: expanding \"%s\" produced " "no values for \"%s\"\n", argv[i], slapi_entry_get_dn(e)); @@ -3138,7 +2898,7 @@ format_collect(struct plugin_state *state, Slapi_Entry *e, if (choices != NULL) { for (i = 0; choices[i] != NULL; i++) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "collect: returning \"%.*s\" as a " "value for \"%s\"\n", (int) choices[i]->bv_len, @@ -3147,7 +2907,7 @@ format_collect(struct plugin_state *state, Slapi_Entry *e, continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "collect: returning %d values for \"%s\"\n", i, slapi_entry_get_dn(e)); format_add_choice(outbuf_choices, outbuf, &choices); @@ -3161,47 +2921,41 @@ format_collect(struct plugin_state *state, Slapi_Entry *e, return ret; } -/* Evaluate all of the arguments, and concatentate sets of entries from each +/* Evaluate all of the arguments, and concatenate sets of entries from each * list, separating them with an optional separator, padding the lists with a * specified value until all of the elements of all lists have been used. */ static int -format_link(struct plugin_state *state, Slapi_Entry *e, +format_link(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, argc, i, j, *n_items, l, result_n, n_lists, n_done; unsigned int **lengths, length, max_length; char **argv, ***values, *buffer, *p; struct berval bv, **choices; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: error parsing arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (((argc + 1) % 3) != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: wrong number of arguments\n"); format_free_parsed_args(argv); return -EINVAL; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -3213,7 +2967,7 @@ format_link(struct plugin_state *state, Slapi_Entry *e, lengths = malloc(sizeof(int *) * (((argc + 1) / 3) * 2)); n_items = malloc(sizeof(int) * (((argc + 1) / 3) * 2)); if ((values == NULL) || (lengths == NULL) || (n_items == NULL)) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: out of memory\n"); format_free_parsed_args(argv); free(values); @@ -3226,38 +2980,26 @@ format_link(struct plugin_state *state, Slapi_Entry *e, choices = NULL; n_lists = 0; for (i = 0; i < argc; i += 3) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i]); j = (i / 3) * 2; - values[j] = format_get_data_set_int(state, e, group, set, - argv[i], disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list, + values[j] = format_get_data_set_int(st, e, group, set, + argv[i], &lengths[j]); if (values[j] != NULL) { n_lists++; } j++; - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "link: evaluating \"%s\"\n", argv[i + 1]); - values[j] = format_get_data_set_int(state, e, group, set, - argv[i + 1], disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list, + values[j] = format_get_data_set_int(st, e, group, set, + argv[i + 1], &lengths[j]); if (values[j] != NULL) { n_lists++; } else { slapi_log_error(SLAPI_LOG_FATAL, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "link: error evaluating \"%s\" " "for \"%s\"\n", argv[i + 1], @@ -3372,12 +3114,12 @@ format_link(struct plugin_state *state, Slapi_Entry *e, bv.bv_len = length; if ((p - buffer) != length) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "link: internal error\n"); break; } else { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "link: \"%.*s\"\n", (int) bv.bv_len, bv.bv_val); format_add_bv_list(&choices, &bv); @@ -3405,17 +3147,11 @@ format_link(struct plugin_state *state, Slapi_Entry *e, /* Eliminate duplicate values from the list. */ static int -format_unique(struct plugin_state *state, Slapi_Entry *e, +format_unique(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, i, j, argc; char **argv, **values; @@ -3423,14 +3159,14 @@ format_unique(struct plugin_state *state, Slapi_Entry *e, unsigned int *lengths; struct berval **choices, bv; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "unique: error parsing arguments\n"); return -EINVAL; } if (argc < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "unique: error parsing arguments\n"); format_free_parsed_args(argv); return -EINVAL; @@ -3443,37 +3179,30 @@ format_unique(struct plugin_state *state, Slapi_Entry *e, default_value = argv[1]; } if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "unique: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); return -EINVAL; } ret = -ENOENT; - values = format_get_data_set_int(state, e, group, set, - value_format, disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + value_format, &lengths); if (values == NULL) { if (default_value == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "unique: no values for ->%s<-, " "and no default value provided\n", value_format); ret = -ENOENT; } else { - i = format_expand(state, e, + i = format_expand(st, e, group, set, - default_value, NULL, - restrict_subtrees, - ignore_subtrees, + default_value, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + outbuf_choices); ret = i; } } else { @@ -3498,7 +3227,7 @@ format_unique(struct plugin_state *state, Slapi_Entry *e, if (choices != NULL) { for (i = 0; choices[i] != NULL; i++) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "unique: returning \"%.*s\" as a " "value for \"%s\"\n", (int) choices[i]->bv_len, @@ -3507,7 +3236,7 @@ format_unique(struct plugin_state *state, Slapi_Entry *e, continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "unique: returning %d values for \"%s\"\n", i, slapi_entry_get_dn(e)); format_add_choice(outbuf_choices, outbuf, &choices); @@ -3523,18 +3252,11 @@ format_unique(struct plugin_state *state, Slapi_Entry *e, /* Produce an internal sequence number. */ static int -format_internal_sequence_number(struct plugin_state *state, Slapi_Entry *e, +format_internal_sequence_number(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { static int sequence; char *buf; @@ -3556,10 +3278,10 @@ format_internal_sequence_number(struct plugin_state *state, Slapi_Entry *e, ret = -ENOENT; } if (ret == 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "internal_sequence_number: ->%s<-\n", buf); } else { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "internal_sequence_number: error building result\n"); } free(buf); @@ -3569,18 +3291,11 @@ format_internal_sequence_number(struct plugin_state *state, Slapi_Entry *e, /* Condense the list as much as possible, but possibly still produce multiple * values. */ static int -format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, +format_dribble_merge(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int ret, i, j, argc, slen, count, buf_used = 0; unsigned int *lengths, max; @@ -3589,14 +3304,14 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, char *buf = NULL; struct berval **choices, bv; - ret = format_parse_args(state, args, &argc, &argv); + ret = format_parse_args(st, args, &argc, &argv); if (ret != 0) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "dribble_merge: error parsing arguments\n"); return -EINVAL; } if (argc < 2) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "dribble_merge: requires at least " "two arguments\n"); format_free_parsed_args(argv); @@ -3604,7 +3319,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, } max = atoi(argv[0]); if (max < 1) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "dribble_merge: small maximum group size\n"); format_free_parsed_args(argv); return -EINVAL; @@ -3613,7 +3328,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, slen = strlen(sep); choices = NULL; if (outbuf_choices == NULL) { - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "dribble_merge: returns a list, but a list " "would not be appropriate\n"); format_free_parsed_args(argv); @@ -3621,17 +3336,14 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, } for (i = 2, ret = 0, count = 0; i < argc; i++) { /* Expand this argument. */ - slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + slapi_log_error(SLAPI_LOG_PLUGIN, st->plugin_desc->spd_id, "dribble_merge: expanding ->%s<-\n", argv[i]); - values = format_get_data_set_int(state, e, group, set, - argv[i], disallowed, - restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + values = format_get_data_set_int(st, e, group, set, + argv[i], &lengths); if (values == NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "dribble_merge: no values for " "->%s<-\n", argv[i]); continue; @@ -3662,7 +3374,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, /* If the value's just too big, return an error. */ if (lengths[j] > max) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "dribble_merge: value \"%.*s\"" " was too big for ->%s<\n", lengths[j], values[j], @@ -3675,7 +3387,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, } else { /* Log this value. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "dribble_merge: got %d-byte " "value for ->%s<\n", lengths[j], argv[i]); @@ -3704,7 +3416,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, if (choices != NULL) { for (i = 0; choices[i] != NULL; i++) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "dribble_merge: returning \"%.*s\" " "as a value for \"%s\"\n", (int) choices[i]->bv_len, @@ -3713,7 +3425,7 @@ format_dribble_merge(struct plugin_state *state, Slapi_Entry *e, continue; } slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "dribble_merge: returning %d values for " "\"%s\"\n", i, slapi_entry_get_dn(e)); format_add_choice(outbuf_choices, outbuf, &choices); @@ -3731,18 +3443,11 @@ format_lookup_fn(const char *fnname) unsigned int i; struct { const char *name; - int (*fct_ptr)(struct plugin_state *state, Slapi_Entry *e, + int (*fct_ptr)(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list); + struct format_choice **outbuf_choices); } fns[] = { {"first", format_first}, {"deref", format_deref}, @@ -3840,9 +3545,9 @@ format_check_disallowed(const struct berval *bv, const char *disallowed) * than one, return NULL. If there's more than one, store the values in the * array argument. */ static struct berval -format_single(struct plugin_state *state, Slapi_Entry *e, - const char *attr, const char *disallowed, - char ***attrlist, struct berval ***values) +format_single(struct format_state *st, Slapi_Entry *e, + const char *attr, char ***attrlist, + struct berval ***values) { Slapi_ValueSet *value_set; Slapi_Value *value; @@ -3864,10 +3569,10 @@ format_single(struct plugin_state *state, Slapi_Entry *e, if (count == 1) { if (slapi_valueset_first_value(value_set, &value) != -1) { val = slapi_value_get_berval(value); - d = format_check_disallowed(val, disallowed); + d = format_check_disallowed(val, st->config.disallowed_chars); if (d != NULL) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "value for \"%s\" " "contains disallowed " "character \"%c\", " @@ -3887,7 +3592,7 @@ format_single(struct plugin_state *state, Slapi_Entry *e, /* Either no results, or too many results with no place * to put them. */ slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "%d values for \"%s\"\n", count, attr); } else { /* Return the list of values. */ @@ -3900,7 +3605,7 @@ format_single(struct plugin_state *state, Slapi_Entry *e, if (val->bv_len == 0) { continue; } - d = format_check_disallowed(val, disallowed); + d = format_check_disallowed(val, st->config.disallowed_chars); if (d == NULL) { format_add_bv_list(values, val); } @@ -3945,7 +3650,7 @@ format_find_closer(const char *pair, const char *pattern) /* Trim off prefixes or suffixes which match the given patterns, free the * original, and return the result. */ static struct berval -format_trim_value(struct plugin_state *state, struct berval input, +format_trim_value(struct format_state *st, struct berval input, const char *shortstart, const char *longstart, const char *shortend, const char *longend, const char *replace, const char *replaceall, @@ -3970,7 +3675,7 @@ format_trim_value(struct plugin_state *state, struct berval input, ret.bv_val = buf; ret.bv_len = input.bv_len - i; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "trim-ss: ->%.*s<- => " "->%.*s<-\n", (int) input.bv_len, @@ -3997,7 +3702,7 @@ format_trim_value(struct plugin_state *state, struct berval input, ret.bv_val = buf; ret.bv_len = input.bv_len - i; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "trim-se: ->%.*s<- => " "->%.*s<-\n", (int) input.bv_len, @@ -4022,7 +3727,7 @@ format_trim_value(struct plugin_state *state, struct berval input, ret.bv_val = buf; ret.bv_len = input.bv_len - i; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "trim-ls: ->%.*s<- => " "->%.*s<-\n", (int) input.bv_len, @@ -4047,7 +3752,7 @@ format_trim_value(struct plugin_state *state, struct berval input, ret.bv_val = buf; ret.bv_len = input.bv_len - i; slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "trim-le: ->%.*s<- => " "->%.*s<-\n", (int) input.bv_len, @@ -4077,18 +3782,11 @@ format_trim_value(struct plugin_state *state, struct berval input, * attribute value, perhaps with a default or alternate value, perhaps with a * prefix or suffix stripped, perhaps with internal replacements made. */ static int -format_expand_simple(struct plugin_state *state, Slapi_Entry *e, +format_expand_simple(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *fmt, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { char *shortstart, *longstart, *shortend, *longend; struct berval tmp, **values; @@ -4183,8 +3881,9 @@ format_expand_simple(struct plugin_state *state, Slapi_Entry *e, } /* Retrieve the value. */ values = NULL; - tmp = format_single(state, e, attribute, disallowed, - rel_attrs, outbuf_choices ? &values : NULL); + tmp = format_single(st, e, attribute, + st->config.rel_attrs, + outbuf_choices ? &values : NULL); if (tmp.bv_val == NULL) { /* The attribute is undefined, or we're treating it as if it * is. */ @@ -4192,17 +3891,11 @@ format_expand_simple(struct plugin_state *state, Slapi_Entry *e, if (default_value != NULL) { /* Supply the default value, expanding it if * needed. */ - i = format_expand(state, e, + i = format_expand(st, e, group, set, - default_value, NULL, - restrict_subtrees, - ignore_subtrees, + default_value, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list); + outbuf_choices); free(expr); return i; } else { @@ -4213,17 +3906,11 @@ format_expand_simple(struct plugin_state *state, Slapi_Entry *e, } else { if (alternate_value != NULL) { /* Supply the alternate value. */ - i = format_expand(state, e, + i = format_expand(st, e, group, set, - alternate_value, NULL, - restrict_subtrees, - ignore_subtrees, + alternate_value, outbuf, outbuf_len, - outbuf_choices, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list); + outbuf_choices); free(expr); format_free_bv_list(values); return i; @@ -4245,18 +3932,15 @@ format_expand_simple(struct plugin_state *state, Slapi_Entry *e, /* There's a suitable single value available. */ if (alternate_value != NULL) { /* Supply the alternate value. */ - i = format_expand(state, e, - group, set, alternate_value, NULL, - restrict_subtrees, ignore_subtrees, - outbuf, outbuf_len, outbuf_choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + i = format_expand(st, e, + group, set, alternate_value, + outbuf, outbuf_len, outbuf_choices); free(tmp.bv_val); free(expr); return i; } else { /* Munge up the looked-up value. */ - tmp = format_trim_value(state, tmp, + tmp = format_trim_value(st, tmp, shortstart, longstart, shortend, longend, replace, replaceall, @@ -4283,36 +3967,24 @@ format_expand_simple(struct plugin_state *state, Slapi_Entry *e, * will also be an expression, treat the entire result as an attribute * specifier and evaluate it, otherwise return it. */ static int -format_expand(struct plugin_state *state, Slapi_Entry *e, +format_expand(struct format_state *st, + Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *fmt, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list) + struct format_choice **outbuf_choices) { int i, j, used; const char *fmtstart, *fmtend, *match, *pair; char *subexp, *fnname, *params, *spd_id; const char *paramstart, *paramend; - int (*formatfn)(struct plugin_state *state, Slapi_Entry *e, + int (*formatfn)(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *args, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, + const char *args, char *outbuf, int outbuf_len, - struct format_choice **outbuf_choices, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list); + struct format_choice **outbuf_choices); - spd_id = state->plugin_desc->spd_id; + spd_id = st->plugin_desc->spd_id; /* Expand any subexpressions and call any "functions". */ i = 0; @@ -4358,22 +4030,14 @@ format_expand(struct plugin_state *state, Slapi_Entry *e, return -ENOMEM; } /* Expand the simple expression. */ - used = format_expand_simple(state, + used = format_expand_simple(st, e, group, set, subexp, - disallowed, - restrict_subtrees, - ignore_subtrees, outbuf + j, outbuf_len - j, - outbuf_choices, - rel_attrs, - ref_attrs, - inref_attrs, - ref_attr_list, - inref_attr_list); + outbuf_choices); if (used < 0) { /* Some failure, FAIL. */ slapi_log_error(SLAPI_LOG_PLUGIN, @@ -4469,17 +4133,11 @@ format_expand(struct plugin_state *state, Slapi_Entry *e, return -ENOSYS; } /* Call the "function". */ - used = (*formatfn)(state, e, + used = (*formatfn)(st, e, group, set, - params, disallowed, - restrict_subtrees, - ignore_subtrees, + params, outbuf + j, outbuf_len - j, - outbuf_choices, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, - inref_attr_list); + outbuf_choices); if (used < 0) { /* Error in function, FAIL. */ slapi_log_error(SLAPI_LOG_PLUGIN, @@ -4530,22 +4188,17 @@ format_expand(struct plugin_state *state, Slapi_Entry *e, } static char * -format_format(struct plugin_state *state, Slapi_Entry *e, +format_format(struct format_state *st, + Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, + const char *fmt, struct format_choice **choices, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, - char ***rel_attrs, char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, unsigned int *data_length) { char *buf, *ret, *spd_id; int i, buflen; - spd_id = state->plugin_desc->spd_id; + spd_id = st->plugin_desc->spd_id; buflen = DEFAULT_BUFFER_SIZE; do { buf = malloc(buflen); @@ -4559,13 +4212,9 @@ format_format(struct plugin_state *state, Slapi_Entry *e, return NULL; } - i = format_expand(state, e, group, set, - fmt, disallowed, - restrict_subtrees, - ignore_subtrees, - buf, buflen, choices, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list); + i = format_expand(st, e, group, set, + fmt, + buf, buflen, choices); if ((i >= 0) && (i < buflen)) { buf[i] = '\0'; ret = xmemdup(buf, i); @@ -4619,6 +4268,128 @@ format_free_data(char *data) free(data); } } + +void format_free_state(struct format_state **state) +{ + if (state && *state) { + if ((*state)->free_config) { + (*state)->free_config(*state); + } + free(*state); + *state = NULL; + } +} + +char *format__get_data(struct format_state *state, + const char *group, const char *set, + struct slapi_entry *e, + const char *fmt, + unsigned int *data_length) +{ + unsigned int ignored; + return format_format(state, e, group, set, fmt, + NULL, + data_length ? data_length : &ignored); +} + +/* TODO: A stub for now */ +char **format__get_data_set(struct format_state *state, + const char *group, const char *set, + struct slapi_entry *e, + const char *fmt, + unsigned int **data_lengths) +{ + return format_get_data_set_int(state, e, + group, set, + fmt, + data_lengths); +} + +struct format_set_internal_struct { + struct format_set_config config; + struct plugin_state *plugin_state; +}; + +/* Internal helpers to avoid disrupting formatter engine API users for now */ +void __format_state_init_config(struct format_state *state, Slapi_PBlock *pb) +{ + struct format_set_internal_struct *st; + + /* If we are initialized already, return */ + if (!state || state->initialized) { + return; + } + + /* After initialize step we'll have state->cbdata pointing to + * a plugin state, so we wouldn't be able to recover access + * to the 'struct format_set_internal_struct' anymore. */ + st = state->caller_data; + state->config = st->config; + state->caller_data = st->plugin_state; + state->initialized = TRUE; +} + +void __format_state_free_config(struct format_state *state) +{ + /* we don't free the config ourselves here as our + * callers provided separate elements of it already */ +} + + +void __format_state_get_bases_filter(struct format_state *state, + const char *group, const char *set, + char ***bases, char **filter) +{ + backend_get_set_config(NULL, state->caller_data, + group, set, + bases, filter); +} + +void __format_state_free_bases_filter(struct format_state *state, + char ***bases, char **filter) +{ + backend_free_set_config(*bases, *filter); + *bases = NULL; + *filter = NULL; +} + +int __format_state_internal_search_cb(struct format_state *state, + Slapi_PBlock *pb, + void *callback_data, + format_result_callback prc, + format_search_entry_callback psec, + format_referral_entry_callback prec) +{ + return slapi_search_internal_callback_pb(pb, callback_data, prc, psec, prec); +} + +struct format_state * +format_create_state(Slapi_ComponentId *plugin_identity, + Slapi_PluginDesc *plugin_desc, + format_state_init_config init_config, + format_state_free_config free_config, + format_state_get_bases_filter get_bases_filter, + format_state_free_bases_filter free_bases_filter, + format_state_search_callback_pb search_callback_pb, + void *caller_data) +{ + struct format_state *state = NULL; + state = calloc(1, sizeof(*state)); + if (!state) { + return NULL; + } + + state->plugin_identity = plugin_identity; + state->plugin_desc = plugin_desc; + state->caller_data = caller_data; + state->init_config = init_config; + state->free_config = free_config; + state->get_bases_filter = get_bases_filter; + state->free_bases_filter = free_bases_filter; + state->search_callback_pb = search_callback_pb; + return state; +} + char * format_get_data(struct plugin_state *state, Slapi_PBlock *pb /*unused*/, Slapi_Entry *e, @@ -4634,13 +4405,34 @@ format_get_data(struct plugin_state *state, Slapi_PBlock *pb /*unused*/, unsigned int *data_length) { unsigned int ignored; - return format_format(state, e, group, set, fmt, - disallowed, NULL, - restrict_subtrees, ignore_subtrees, - rel_attrs, - ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, - data_length ? data_length : &ignored); + char *result = NULL; + struct format_state *st = NULL; + struct format_set_internal_struct cbdata; + + st = format_create_state(state->plugin_identity, state->plugin_desc, + __format_state_init_config, + __format_state_free_config, + __format_state_get_bases_filter, + __format_state_free_bases_filter, + __format_state_internal_search_cb, + &cbdata); + if (!st) { + return NULL; + } + + cbdata.config.disallowed_chars = disallowed; + cbdata.config.restrict_subtrees = restrict_subtrees; + cbdata.config.ignore_subtrees = ignore_subtrees; + cbdata.config.rel_attrs = rel_attrs; + cbdata.config.ref_attrs = ref_attrs; + cbdata.config.inref_attrs = inref_attrs; + cbdata.config.ref_attr_list = ref_attr_list; + cbdata.config.inref_attr_list = inref_attr_list; + st->init_config(st, pb); + result = format_format(st, e, group, set, fmt, NULL, + data_length ? data_length : &ignored); + format_free_state(&st); + return result; } void @@ -4657,16 +4449,9 @@ format_free_data_set(char **data, unsigned int *data_lengths) } static char ** -format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, +format_get_data_set_int(struct format_state *st, Slapi_Entry *e, const char *group, const char *set, - const char *fmt, const char *disallowed, - const struct slapi_dn **restrict_subtrees, - const struct slapi_dn **ignore_subtrees, - char ***rel_attrs, - char ***ref_attrs, - struct format_inref_attr ***inref_attrs, - struct format_ref_attr_list ***ref_attr_list, - struct format_ref_attr_list ***inref_attr_list, + const char *fmt, unsigned int **data_lengths) { struct format_choice *choices, *this_choice; @@ -4675,10 +4460,8 @@ format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, int combinations, groupsize, i, j, k, offset, length, prev_offset; unsigned int template_len; choices = NULL; - template = format_format(state, e, group, set, fmt, disallowed, - &choices, restrict_subtrees, ignore_subtrees, - rel_attrs, ref_attrs, inref_attrs, - ref_attr_list, inref_attr_list, + template = format_format(st, e, group, set, fmt, + &choices, &template_len); if (template == NULL) { format_free_choices(choices); @@ -4692,7 +4475,7 @@ format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, this_choice = this_choice->next) { if ((this_choice->offset - template) > prev_offset) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "choice: fixed \"%.*s\" at %d\n", (int) (this_choice->offset - template) - prev_offset, @@ -4702,7 +4485,7 @@ format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, } for (i = 0; i < this_choice->n_values; i++) { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "choice: option \"%.*s\" at %ld\n", (int) this_choice->values[i]->bv_len, (char *) this_choice->values[i]->bv_val, @@ -4713,7 +4496,7 @@ format_get_data_set_int(struct plugin_state *state, Slapi_Entry *e, } if (template[prev_offset] != '\0') { slapi_log_error(SLAPI_LOG_PLUGIN, - state->plugin_desc->spd_id, + st->plugin_desc->spd_id, "choice: fixed \"%s\" at %d\n", template + prev_offset, prev_offset); @@ -4799,17 +4582,36 @@ format_get_data_set(struct plugin_state *state, Slapi_PBlock *pb /*unused*/, struct format_ref_attr_list ***inref_attr_list, unsigned int **data_lengths) { - return format_get_data_set_int(state, e, - group, set, - fmt, disallowed, - restrict_subtrees, - ignore_subtrees, - rel_attrs, - ref_attrs, - inref_attrs, - ref_attr_list, - inref_attr_list, - data_lengths); + char **result = NULL; + struct format_state *st = NULL; + struct format_set_internal_struct cbdata; + + st = format_create_state(state->plugin_identity, state->plugin_desc, + __format_state_init_config, + __format_state_free_config, + __format_state_get_bases_filter, + __format_state_free_bases_filter, + __format_state_internal_search_cb, + &cbdata); + if (!st) { + return NULL; + } + + cbdata.config.disallowed_chars = disallowed; + cbdata.config.restrict_subtrees = restrict_subtrees; + cbdata.config.ignore_subtrees = ignore_subtrees; + cbdata.config.rel_attrs = rel_attrs; + cbdata.config.ref_attrs = ref_attrs; + cbdata.config.inref_attrs = inref_attrs; + cbdata.config.ref_attr_list = ref_attr_list; + cbdata.config.inref_attr_list = inref_attr_list; + st->init_config(st, pb); + result = format_get_data_set_int(st, e, + group, set, + fmt, + data_lengths); + format_free_state(&st); + return result; } char * diff --git a/src/format.h b/src/format.h index 626d4a9..3e85c96 100644 --- a/src/format.h +++ b/src/format.h @@ -24,6 +24,42 @@ struct slapi_entry; struct slapi_dn; struct plugin_state; +struct Slapi_ComponentId; +struct Slapi_PluginDesc; + +struct format_state; + +typedef void (*format_result_callback)(int rc, void *callback_data); +typedef int (*format_referral_entry_callback)(char *referral, + void *callback_data); +typedef int (*format_search_entry_callback)(struct slapi_entry *e, + void *callback_data); + +/* An initialization function that fills in configuration details for the formatter + * The function has to mark state->initialized as true if configuration is done */ +typedef void(*format_state_init_config)(struct format_state *state, Slapi_PBlock *pb); + +/* A function to free configuration details for the formatter + * The function has to mark state->initialized as false if configuration is freed + * and set set->config values to NULL */ +typedef void(*format_state_free_config)(struct format_state *state); + +/* A function to return LDAP bases and a filter to search */ +typedef void(*format_state_get_bases_filter)(struct format_state *state, + const char *group, const char *set, + char ***bases, char **filter); +/* A function to free LDAP bases and a filter to search */ +typedef void(*format_state_free_bases_filter)(struct format_state *state, + char ***bases, char **filter); + +/* A callback function similar to slapi_search_internal_callback_pb() + * in case a search needs to be performed elsewhere */ +typedef int(*format_state_search_callback_pb)(struct format_state *state, + Slapi_PBlock *pb, + void *callback_data, + format_result_callback prc, + format_search_entry_callback psec, + format_referral_entry_callback prec); struct format_inref_attr { char *group, *set, *attribute; @@ -39,6 +75,47 @@ struct format_ref_attr_list { int n_links; }; +struct format_set_config { + const char *disallowed_chars; + const struct slapi_dn **restrict_subtrees; + const struct slapi_dn **ignore_subtrees; + char ***rel_attrs; + char ***ref_attrs; + struct format_inref_attr ***inref_attrs; + struct format_ref_attr_list ***ref_attr_list; + struct format_ref_attr_list ***inref_attr_list; +}; + +struct format_state { + Slapi_ComponentId *plugin_identity; + Slapi_PluginDesc *plugin_desc; + void *caller_data; + bool_t initialized; + format_state_init_config init_config; + format_state_free_config free_config; + format_state_get_bases_filter get_bases_filter; + format_state_free_bases_filter free_bases_filter; + format_state_search_callback_pb search_callback_pb; + struct format_set_config config; +}; + +struct format_template { + char *rdn_format; + char **attribute_format; + char *disallowed_chars; +}; + +enum format_flags { + /* Add operations attributes: only needed if LDAP entry is not stored in LDAP backend */ + FORMAT_OPERATIONAL_ATTRS = 0x0001, + /* Perform schema check and add extensible object class if the schema check failed */ + FORMAT_EXTENSIBLE_OBJECT = 0x0002, + /* Reformat resulting entry through slapi_entry2str() / slapi_str2entry() + * to remove duplicates, add RDN values, expand object classes. + * non-well-formed LDIF is accepted.*/ + FORMAT_REFORMAT_ENTRY = 0x0004, +}; + void format_free_attr_list(char **attr_list); char **format_dup_attr_list(char **attr_list); @@ -82,6 +159,64 @@ char **format_get_data_set(struct plugin_state *state, struct format_ref_attr_list ***inref_attr_list, unsigned int **data_lengths); +/* Create `format_state` structure based on the SLAPI plugin-provided details + * about itself and callbacks for the search and the initialization. + * + * Initialization callback should fill in the details of the `format_state.config` + * structure. + * + * Some of the formatting functions require retrieval of configuration of a set + * in a group to allow look up of entries. `get_bases_filter()` and + * `free_bases_filter()` provide management of this information. + * + * Search callback is used by the formatting functions to request retrieval of the + * additional LDAP entries if needed. Its behavior should be similar to + * slapi_search_internall_callback_pb() SLAPI call but it is an abstraction + * to allow retrieving data from another sources (another 398-ds instances, for + * example). + * + * `caller_data` can be used to pass through additional context to all callbacks + * as it will be available as `state->caller_data` for them. + */ +struct format_state * +format_create_state(Slapi_ComponentId *plugin_identity, + Slapi_PluginDesc *plugin_desc, + format_state_init_config init_config, + format_state_free_config free_config, + format_state_get_bases_filter get_bases_filter, + format_state_free_bases_filter free_bases_filter, + format_state_search_callback_pb search_callback_pb, + void *caller_data); +void format_free_state(struct format_state **state); + +/* Return a list of attribute values based on the attribute format `fmt` + * and original LDAP entry `e`. + * Length of each value in the list is returned in `data_lengths`, if provided. */ +char **format__get_data_set(struct format_state *state, + const char *group, const char *set, + struct slapi_entry *e, + const char *fmt, + unsigned int **data_lengths); + +/* Return an attribute value based on the attribute format `fmt` + * and original LDAP entry `e`. + * Length of the value is returned in `data_length`, if provided. */ +char *format__get_data(struct format_state *state, + const char *group, const char *set, + struct slapi_entry *e, + const char *fmt, + unsigned int *data_length); + +/* Update LDAP entry `target` by applying all formatting directives + * from the formatting template `format` to an LDAP entry `e`. + * Returns 0 for success, -1 for errors. */ +int format__get_data_entry(struct format_state *state, + const char *group, const char *set, + struct format_template *format, + struct slapi_entry *e, + struct slapi_entry *target, + enum format_flags flags); + char *format_escape_for_filter(const char *unescaped); char *format_build_dn(const char *attribute, const char *value, const char *container_sdn); From c8366982a902fa9e9103e6e6ca00ad7b8c4bbc39 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 5/7] 0.57.0 --- diff --git a/configure.ac b/configure.ac index 80f2ca2..9f6202a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT(slapi-nis,0.56.2) +AC_INIT(slapi-nis,0.57.0) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE(foreign) LT_INIT([disable-static]) diff --git a/slapi-nis.spec b/slapi-nis.spec index 5bee258..781e108 100644 --- a/slapi-nis.spec +++ b/slapi-nis.spec @@ -10,8 +10,8 @@ %endif Name: slapi-nis -Version: 0.56.2 -Release: 8%{?dist} +Version: 0.57.0 +Release: 1%{?dist} Summary: NIS Server and Schema Compatibility plugins for Directory Server License: GPLv2 URL: http://pagure.io/slapi-nis/ @@ -81,6 +81,9 @@ make check %{_sbindir}/nisserver-plugin-defs %changelog +* Tue Apr 09 2019 Alexander Bokovoy - 0.57.0-1 +- New formatting engine API (internal change) + * Sat Feb 02 2019 Fedora Release Engineering - 0.56.2-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild From 3a9241cc2101c1b4c458cc94ee4e4f17ddfd569a Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 10:12:27 +0000 Subject: [PATCH 6/7] WIP: update test schema and configuration --- diff --git a/tests/config/dse.ldif.initial.in b/tests/config/dse.ldif.initial.in index c97c335..e9fc139 100644 --- a/tests/config/dse.ldif.initial.in +++ b/tests/config/dse.ldif.initial.in @@ -952,22 +952,6 @@ nsslapd-pluginVersion: 1.1.1 nsslapd-pluginVendor: Fedora Project nsslapd-pluginDescription: Unix crypt algorithm (CRYPT) -dn: cn=DES,cn=Password Storage Schemes,cn=plugins,cn=config -objectClass: top -objectClass: nsSlapdPlugin -objectClass: extensibleObject -cn: DES -nsslapd-pluginPath: libdes-plugin -nsslapd-pluginInitfunc: des_init -nsslapd-pluginType: reverpwdstoragescheme -nsslapd-pluginEnabled: on -nsslapd-pluginarg0: nsmultiplexorcredentials -nsslapd-pluginarg1: nsds5ReplicaCredentials -nsslapd-pluginId: des-storage-scheme -nsslapd-pluginVersion: 1.1.1 -nsslapd-pluginVendor: Fedora Project -nsslapd-pluginDescription: DES storage scheme plugin - dn: cn=MD5,cn=Password Storage Schemes,cn=plugins,cn=config objectClass: top objectClass: nsSlapdPlugin diff --git a/tests/config/schema/50ns-directory.ldif b/tests/config/schema/50ns-directory.ldif deleted file mode 100644 index 294a0a8..0000000 --- a/tests/config/schema/50ns-directory.ldif +++ /dev/null @@ -1,121 +0,0 @@ -# -# BEGIN COPYRIGHT BLOCK -# This Program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This Program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA. -# -# In addition, as a special exception, Red Hat, Inc. gives You the additional -# right to link the code of this Program with code not covered under the GNU -# General Public License ("Non-GPL Code") and to distribute linked combinations -# including the two, subject to the limitations in this paragraph. Non-GPL Code -# permitted under this exception must only link to the code of this Program -# through those well defined interfaces identified in the file named EXCEPTION -# found in the source code files (the "Approved Interfaces"). The files of -# Non-GPL Code may instantiate templates or use macros or inline functions from -# the Approved Interfaces without causing the resulting work to be covered by -# the GNU General Public License. Only Red Hat, Inc. may make changes or -# additions to the list of Approved Interfaces. You must obey the GNU General -# Public License in all respects for all of the Program code and other code used -# in conjunction with the Program except the Non-GPL Code covered by this -# exception. If you modify this file, you may extend this exception to your -# version of the file, but you are not obligated to do so. If you do not wish to -# provide this exception without modification, you must delete this exception -# statement from your version and license this file solely under the GPL without -# exception. -# -# -# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. -# Copyright (C) 2005 Red Hat, Inc. -# All rights reserved. -# END COPYRIGHT BLOCK -# -# -# Additional schema used by Netscape Directory Server 4.x -# -dn: cn=schema -attributeTypes: ( nsSecureServerPort-oid NAME 'nsSecureServerPort' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.206 NAME 'filterInfo' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.48 NAME 'replicaPort' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.49 NAME 'replicaUpdateFailedAt' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.50 NAME 'replicaBeginOrc' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.51 NAME 'replicaUpdateReplayed' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.52 NAME 'replicaUpdateSchedule' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.53 NAME 'replicaBindMethod' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.79 NAME 'cirReplicaRoot' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.80 NAME 'cirHost' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.81 NAME 'cirPort' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.82 NAME 'cirBindDn' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.83 NAME 'cirUsePersistentSearch' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.84 NAME 'cirUseSsl' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.85 NAME 'cirBindCredentials' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.86 NAME 'cirLastUpdateApplied' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.87 NAME 'cirUpdateSchedule' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.88 NAME 'cirUpdateFailedat' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.89 NAME 'cirSyncInterval' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.90 NAME 'cirBeginORC' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.197 NAME 'replicaHost' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.202 NAME 'replicaCredentials' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.203 NAME 'replicaEntryFilter' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.204 NAME 'replicaNickName' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.406 NAME 'nsSynchUserIDFormat' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.217 NAME 'replicaCFUpdated' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.218 NAME 'replicaAbandonedChanges' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.407 NAME 'nsSynchUniqueAttribute' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.240 NAME 'replicatedattributelist' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.408 NAME 'replicaLastRelevantChange' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.41 NAME 'ntUserDomainId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.111 NAME 'ntUniqueId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.42 NAME 'ntUserCreateNewAccount' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.43 NAME 'ntUserDeleteAccount' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.44 NAME 'ntGroupDomainId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.45 NAME 'ntGroupCreateNewGroup' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.46 NAME 'ntGroupDeleteGroup' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.47 NAME 'ntGroupType' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.59 NAME 'ntUserPriv' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.60 NAME 'ntUserAuthFlags' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.61 NAME 'ntUserUsrComment' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.62 NAME 'ntUserParms' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.63 NAME 'ntUserUnitsPerWeek' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.64 NAME 'ntUserNumLogons' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.65 NAME 'ntUserLogonServer' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.66 NAME 'ntUserUniqueId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.67 NAME 'ntUserProfile' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.68 NAME 'ntUserPasswordExpired' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.110 NAME 'ntGroupId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.521 NAME 'ntUserHomeDir' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.522 NAME 'ntUserComment' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.523 NAME 'ntUserFlags' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.524 NAME 'ntUserScriptPath' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.525 NAME 'ntUserWorkstations' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.526 NAME 'ntUserLastLogon' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.527 NAME 'ntUserLastLogoff' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.528 NAME 'ntUserAcctExpires' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.529 NAME 'ntUserMaxStorage' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.530 NAME 'ntUserLogonHours' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.531 NAME 'ntUserBadPwCount' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.532 NAME 'ntUserCountryCode' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.533 NAME 'ntUserCodePage' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.534 NAME 'ntUserPrimaryGroupId' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.535 NAME 'ntUserHomeDirDrive' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.536 NAME 'ntGroupAttributes' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape NT Synchronization' ) -attributeTypes: ( 2.16.840.1.113730.3.1.54 NAME 'replicaUseSSL' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.57 NAME 'replicaRoot' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.58 NAME 'replicaBindDn' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'Netscape Directory Server' ) -attributeTypes: ( 2.16.840.1.113730.3.1.69 NAME 'subtreeACI' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'Netscape Directory Server 1.0' ) -attributeTypes: ( 2.16.840.1.113730.3.1.2084 NAME 'nsSymmetricKey' DESC 'A symmetric key - currently used by attribute encryption' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE X-ORIGIN 'attribute encryption' ) -objectClasses: ( 2.16.840.1.113730.3.2.23 NAME 'netscapeDirectoryServer' DESC 'Netscape defined objectclass' SUP top MUST ( objectclass ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( nsDirectoryServer-oid NAME 'nsDirectoryServer' DESC 'Netscape defined objectclass' SUP top MUST ( objectclass $ nsServerID ) MAY ( serverHostName $ nsServerPort $ nsSecureServerPort $ nsBindPassword $ nsBindDN $ nsBaseDN ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.8 NAME 'ntUser' DESC 'Netscape defined objectclass' SUP top MUST ( ntUserDomainId ) MAY ( description $ l $ ou $ seeAlso $ ntUserPriv $ ntUserHomeDir $ ntUserComment $ ntUserFlags $ ntUserScriptPath $ ntUserAuthFlags $ ntUserUsrComment $ ntUserParms $ ntUserWorkstations $ ntUserLastLogon $ ntUserLastLogoff $ ntUserAcctExpires $ ntUserMaxStorage $ ntUserUnitsPerWeek $ ntUserLogonHours $ ntUserBadPwCount $ ntUserNumLogons $ ntUserLogonServer $ ntUserCountryCode $ ntUserCodePage $ ntUserUniqueId $ ntUserPrimaryGroupId $ ntUserProfile $ ntUserHomeDirDrive $ ntUserPasswordExpired $ ntUserCreateNewAccount $ ntUserDeleteAccount $ ntUniqueId) X-ORIGIN 'Netscape NT Synchronization' ) -objectClasses: ( 2.16.840.1.113730.3.2.9 NAME 'ntGroup' DESC 'Netscape defined objectclass' SUP top MUST ( ntUserDomainId ) MAY ( description $ l $ ou $ seeAlso $ ntGroupId $ ntGroupAttributes $ ntGroupCreateNewGroup $ ntGroupDeleteGroup $ ntGroupType $ ntUniqueId) X-ORIGIN 'Netscape NT Synchronization' ) -objectClasses: ( 2.16.840.1.113730.3.2.82 NAME 'nsChangelog4Config' DESC 'Netscape defined objectclass' SUP top MAY ( cn ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.114 NAME 'nsConsumer4Config' DESC 'Netscape defined objectclass' SUP top MAY ( cn ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.36 NAME 'LDAPReplica' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( description $ l $ ou $ seeAlso $ replicaRoot $ replicaHost $ replicaPort $ replicaBindDn $ replicaCredentials $ replicaBindMethod $ replicaUseSSL $ replicaUpdateSchedule $ replicaUpdateReplayed $ replicaUpdateFailedAt $ replicaBeginORC $ replicaNickname $ replicaEntryFilter $ replicatedAttributeList $ replicaCFUpdated $ replicaAbandonedChanges $ replicaLastRelevantChange ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.11 NAME 'cirReplicaSource' DESC 'Netscape defined objectclass' SUP top MUST cn MAY ( cirReplicaRoot $ cirHost $ cirPort $ cirBindDN $ cirUsePersistentSearch $ cirUseSSL $ cirBindCredentials $ cirLastUpdateApplied $ cirUpdateSchedule $ cirSyncInterval $ cirUpdateFailedAt $ cirBeginORC $ replicaNickname $ replicaEntryFilter $ replicatedAttributeList ) X-ORIGIN 'Netscape Directory Server' ) From c3d20573200683055b386b47b78fbe08ea6bef5f Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2019 11:38:18 +0000 Subject: [PATCH 7/7] covscan: use pclose instead of fclose FILE references opened with popen() is better to close with pclose(), not fclose(). --- diff --git a/tests/clients/yp.c b/tests/clients/yp.c index bc2da1f..f900e02 100644 --- a/tests/clients/yp.c +++ b/tests/clients/yp.c @@ -414,6 +414,6 @@ main(int argc, char **argv) return 1; } ret = dispatch(client, output, argc - optind, argv + optind); - fclose(output); + pclose(output); return ret; }