1 /* Copyright (c) 2003 by International Business Machines, Inc.
3 * International Business Machines, Inc. (hereinafter called IBM) grants
4 * permission under its copyrights to use, copy, modify, and distribute this
5 * Software with or without fee, provided that the above copyright notice and
6 * all paragraphs of this notice appear in all copies, and that the name of IBM
7 * not be used in connection with the marketing of any product incorporating
8 * the Software or modifications thereof, without specific, written prior
11 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
13 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
14 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
15 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
16 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
23 #include <ac/socket.h>
24 #include <ac/string.h>
29 #include "../back-ldap/back-ldap.h"
30 #include "back-meta.h"
32 #undef ldap_debug /* silence a warning in ldap-int.h */
34 #include "../../../libraries/libldap/ldap-int.h"
49 enum type_of_result err;
56 struct berval* query_uuid,
57 struct exception* result)
59 struct query_info info;
61 Operation op_tmp = *op;
63 struct timeval time_in;
64 struct timeval time_out;
67 slap_callback cb = { remove_func, NULL };
68 snprintf(filter_str, sizeof(filter_str), "(queryid=%s)",
70 filter = str2filter(filter_str);
71 info.uuid = query_uuid;
75 cb.sc_private = &info;
77 op_tmp.o_tag = LDAP_REQ_SEARCH;
78 op_tmp.o_protocol = LDAP_VERSION3;
79 op_tmp.o_callback = &cb;
80 op_tmp.o_time = slap_get_time();
81 op_tmp.o_do_not_cache = 1;
82 op_tmp.o_caching_on = 1;
84 op_tmp.o_req_dn = op->o_bd->be_suffix[0];
85 op_tmp.o_req_ndn = op->o_bd->be_nsuffix[0];
86 op_tmp.ors_scope = LDAP_SCOPE_SUBTREE;
87 op_tmp.ors_deref = LDAP_DEREF_NEVER;
88 op_tmp.ors_slimit = 0;
89 op_tmp.ors_tlimit = 0;
90 op_tmp.ors_filter = filter;
91 op_tmp.ors_filterstr.bv_val = filter_str;
92 op_tmp.ors_filterstr.bv_len = strlen(filter_str);
93 op_tmp.ors_attrs = NULL;
94 op_tmp.ors_attrsonly = 0;
96 op->o_bd->be_search( &op_tmp, rs );
98 result->type = info.err;
99 result->rc = info.deleted;
110 struct query_info *info = op->o_callback->sc_private;
113 struct timeval time_in;
114 struct timeval time_out;
119 Operation op_tmp = *op;
121 size = get_entry_size(rs->sr_entry, 0, NULL);
123 for (attr = rs->sr_entry->e_attrs; attr!= NULL; attr = attr->a_next) {
124 if (attr->a_desc == slap_schema.si_ad_queryid) {
125 for (count=0; attr->a_vals[count].bv_val; count++)
132 info->err = REMOVE_ERR;
138 LDAP_LOG( BACK_META, DETAIL1,
139 "DELETING ENTRY SIZE=%d TEMPLATE=%s\n",
140 size, attr->a_vals[0].bv_val, 0 );
142 Debug( LDAP_DEBUG_ANY, "DELETING ENTRY SIZE=%d TEMPLATE=%s\n",
143 size, attr->a_vals[0].bv_val, 0 );
146 op_tmp.o_req_dn = rs->sr_entry->e_name;
147 op_tmp.o_req_ndn = rs->sr_entry->e_nname;
149 if (op->o_bd->be_delete(&op_tmp, rs)) {
150 info->err = REMOVE_ERR;
157 mod = (Modifications*)malloc(sizeof(Modifications));
158 mod->sml_op = LDAP_MOD_DELETE;
159 mod->sml_type.bv_len = sizeof("queryid");
160 mod->sml_type.bv_val = "queryid";
161 mod->sml_desc = slap_schema.si_ad_queryid;
162 mod->sml_bvalues = (struct berval*) malloc( 2 * sizeof( struct berval) );
163 ber_dupbv(mod->sml_bvalues, info->uuid);
164 mod->sml_bvalues[1].bv_val = NULL;
165 mod->sml_bvalues[1].bv_len = 0;
166 mod->sml_next = NULL;
168 LDAP_LOG( BACK_META, DETAIL1,
169 "REMOVING TEMP ATTR : TEMPLATE=%s\n",
170 attr->a_vals[0].bv_val, 0, 0 );
172 Debug( LDAP_DEBUG_ANY, "REMOVING TEMP ATTR : TEMPLATE=%s\n",
173 attr->a_vals[0].bv_val, 0, 0 );
176 op_tmp.o_req_dn = rs->sr_entry->e_name;
177 op_tmp.o_req_ndn = rs->sr_entry->e_nname;
178 op_tmp.orm_modlist = mod;
180 if (op->o_bd->be_modify( &op_tmp, rs )) {
181 info->err = REMOVE_ERR;
184 info->freed += LDIF_SIZE_NEEDED(9, (strlen(info->uuid->bv_val)));
189 #endif /* LDAP_CACHING */