aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2020-12-27 21:43:47 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2020-12-27 21:43:47 +0900
commit7b32281b71e450827ff90f00451f5e5e98c0521e (patch)
treeda46c45025d48462e6d9139bf2fe5c407df95c32 /src/reclaim
parent75a3a90fb765da872383b8f85b2d4087186dc3db (diff)
downloadgnunet-7b32281b71e450827ff90f00451f5e5e98c0521e.tar.gz
gnunet-7b32281b71e450827ff90f00451f5e5e98c0521e.zip
-hunting memleaks
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/oidc_helper.c23
-rw-r--r--src/reclaim/plugin_reclaim_credential_jwt.c22
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c40
-rw-r--r--src/reclaim/plugin_rest_reclaim.c2
-rw-r--r--src/reclaim/reclaim_attribute.c31
-rw-r--r--src/reclaim/reclaim_credential.c32
6 files changed, 123 insertions, 27 deletions
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index 041a2fe47..84a90833c 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -193,6 +193,7 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
193 json_object_set_new (body, "iss", json_string (SERVER_ADDRESS)); 193 json_object_set_new (body, "iss", json_string (SERVER_ADDRESS));
194 // sub REQUIRED public key identity, not exceed 255 ASCII length 194 // sub REQUIRED public key identity, not exceed 255 ASCII length
195 json_object_set_new (body, "sub", json_string (subject)); 195 json_object_set_new (body, "sub", json_string (subject));
196 GNUNET_free (subject);
196 pres_val_str = NULL; 197 pres_val_str = NULL;
197 source_name = NULL; 198 source_name = NULL;
198 int i = 0; 199 int i = 0;
@@ -202,14 +203,14 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
202 GNUNET_asprintf (&source_name, 203 GNUNET_asprintf (&source_name,
203 "src%d", 204 "src%d",
204 i); 205 i);
205 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
206 "Adding new presentation source #%d\n", i); 207 "Adding new presentation source #%d\n", i);
207 aggr_sources_jwt = json_object (); 208 aggr_sources_jwt = json_object ();
208 pres_val_str = 209 pres_val_str =
209 GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type, 210 GNUNET_RECLAIM_presentation_value_to_string (ple->presentation->type,
210 ple->presentation->data, 211 ple->presentation->data,
211 ple->presentation->data_size); 212 ple->presentation->data_size);
212 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213 "Presentation is: %s\n", pres_val_str); 214 "Presentation is: %s\n", pres_val_str);
214 json_object_set_new (aggr_sources_jwt, 215 json_object_set_new (aggr_sources_jwt,
215 GNUNET_RECLAIM_presentation_number_to_typename ( 216 GNUNET_RECLAIM_presentation_number_to_typename (
@@ -224,7 +225,9 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
224 225
225 for (le = attrs->list_head; NULL != le; le = le->next) 226 for (le = attrs->list_head; NULL != le; le = le->next)
226 { 227 {
227 228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
229 "Processing %s for userinfo body\n",
230 le->attribute->name);
228 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) 231 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
229 { 232 {
230 233
@@ -260,18 +263,6 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
260 int j = 0; 263 int j = 0;
261 for (ple = presentations->list_head; NULL != ple; ple = ple->next) 264 for (ple = presentations->list_head; NULL != ple; ple = ple->next)
262 { 265 {
263 char *tmp;
264 tmp = GNUNET_STRINGS_data_to_string_alloc (&le->attribute->credential,
265 sizeof (le->attribute->credential));
266 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
267 "Checking : %s\n", tmp);
268 GNUNET_free (tmp);
269
270 tmp = GNUNET_STRINGS_data_to_string_alloc (&ple->presentation->credential_id,
271 sizeof (ple->presentation->credential_id));
272 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
273 " against: %s\n", tmp);
274 GNUNET_free (tmp);
275 if (GNUNET_YES == 266 if (GNUNET_YES ==
276 GNUNET_RECLAIM_id_is_equal (&ple->presentation->credential_id, 267 GNUNET_RECLAIM_id_is_equal (&ple->presentation->credential_id,
277 &le->attribute->credential)) 268 &le->attribute->credential))
@@ -289,7 +280,7 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
289 GNUNET_asprintf (&source_name, 280 GNUNET_asprintf (&source_name,
290 "src%d", 281 "src%d",
291 j); 282 j);
292 json_object_set_new (aggr_names, le->attribute->data, 283 json_object_set_new (aggr_names, le->attribute->name,
293 json_string (source_name)); 284 json_string (source_name));
294 GNUNET_free (source_name); 285 GNUNET_free (source_name);
295 } 286 }
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c
index f30ead570..c1e12f4a0 100644
--- a/src/reclaim/plugin_reclaim_credential_jwt.c
+++ b/src/reclaim/plugin_reclaim_credential_jwt.c
@@ -173,6 +173,7 @@ jwt_parse_attributes (void *cls,
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt); 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decoded JWT: %s\n", decoded_jwt);
174 GNUNET_assert (NULL != decoded_jwt); 174 GNUNET_assert (NULL != decoded_jwt);
175 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 175 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
176 GNUNET_free (decoded_jwt);
176 const char *key; 177 const char *key;
177 json_t *value; 178 json_t *value;
178 json_object_foreach (json_val, key, value) { 179 json_object_foreach (json_val, key, value) {
@@ -197,6 +198,7 @@ jwt_parse_attributes (void *cls,
197 strlen (val_str)); 198 strlen (val_str));
198 GNUNET_free (val_str); 199 GNUNET_free (val_str);
199 } 200 }
201 json_decref (json_val);
200 GNUNET_free (jwt_string); 202 GNUNET_free (jwt_string);
201 return attrs; 203 return attrs;
202} 204}
@@ -260,11 +262,17 @@ jwt_get_issuer (void *cls,
260 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 262 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
261 (void **) &decoded_jwt); 263 (void **) &decoded_jwt);
262 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 264 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
265 GNUNET_free (decoded_jwt);
266 GNUNET_free (jwt_string);
267 if (NULL == json_val)
268 return NULL;
263 issuer_json = json_object_get (json_val, "iss"); 269 issuer_json = json_object_get (json_val, "iss");
264 if ((NULL == issuer_json) || (! json_is_string (issuer_json))) 270 if ((NULL == issuer_json) || (! json_is_string (issuer_json))) {
271 json_decref (json_val);
265 return NULL; 272 return NULL;
273 }
266 issuer = GNUNET_strdup (json_string_value (issuer_json)); 274 issuer = GNUNET_strdup (json_string_value (issuer_json));
267 GNUNET_free (jwt_string); 275 json_decref (json_val);
268 return issuer; 276 return issuer;
269} 277}
270 278
@@ -331,11 +339,17 @@ jwt_get_expiration (void *cls,
331 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), 339 GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body),
332 (void **) &decoded_jwt); 340 (void **) &decoded_jwt);
333 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); 341 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
342 GNUNET_free (decoded_jwt);
343 GNUNET_free (jwt_string);
344 if (NULL == json_val)
345 return GNUNET_SYSERR;
334 exp_json = json_object_get (json_val, "exp"); 346 exp_json = json_object_get (json_val, "exp");
335 if ((NULL == exp_json) || (! json_is_integer (exp_json))) 347 if ((NULL == exp_json) || (! json_is_integer (exp_json))) {
348 json_decref (json_val);
336 return GNUNET_SYSERR; 349 return GNUNET_SYSERR;
350 }
337 exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000; 351 exp->abs_value_us = json_integer_value (exp_json) * 1000 * 1000;
338 GNUNET_free (jwt_string); 352 json_decref (json_val);
339 return GNUNET_OK; 353 return GNUNET_OK;
340} 354}
341 355
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 5eb1ff093..0ee61755b 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -610,6 +610,10 @@ cleanup_handle (struct RequestHandle *handle)
610 GNUNET_free (handle->oidc->response_type); 610 GNUNET_free (handle->oidc->response_type);
611 GNUNET_free (handle->oidc->scope); 611 GNUNET_free (handle->oidc->scope);
612 GNUNET_free (handle->oidc->state); 612 GNUNET_free (handle->oidc->state);
613 if (NULL != handle->oidc->claims)
614 GNUNET_free (handle->oidc->claims);
615 if (NULL != handle->oidc->code_challenge)
616 GNUNET_free (handle->oidc->code_challenge);
613 GNUNET_free (handle->oidc); 617 GNUNET_free (handle->oidc);
614 } 618 }
615 if (NULL!=handle->attr_idtoken_list) 619 if (NULL!=handle->attr_idtoken_list)
@@ -1193,8 +1197,7 @@ attr_in_claims_request (struct RequestHandle *handle,
1193 return GNUNET_YES; 1197 return GNUNET_YES;
1194 1198
1195 /** Try claims parameter if not in scope */ 1199 /** Try claims parameter if not in scope */
1196 if ((NULL != handle->oidc->claims) && 1200 if (NULL != handle->oidc->claims)
1197 (GNUNET_YES != ret))
1198 { 1201 {
1199 root = json_loads (handle->oidc->claims, JSON_DECODE_ANY, &error); 1202 root = json_loads (handle->oidc->claims, JSON_DECODE_ANY, &error);
1200 claims_j = json_object_get (root, claims_parameter); 1203 claims_j = json_object_get (root, claims_parameter);
@@ -1708,8 +1711,6 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1708 handle->ego_entry = ego_tail; 1711 handle->ego_entry = ego_tail;
1709 } 1712 }
1710 } 1713 }
1711 handle->oidc->scope = get_url_parameter_copy (handle, OIDC_SCOPE_KEY);
1712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scope: %s\n", handle->oidc->scope);
1713 if (NULL == handle->tld) 1714 if (NULL == handle->tld)
1714 GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle); 1715 GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle);
1715 if (NULL == handle->tld) 1716 if (NULL == handle->tld)
@@ -1872,11 +1873,18 @@ parse_credentials_post_body (struct RequestHandle *handle,
1872 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle 1873 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle
1873 ->url_param_map, 1874 ->url_param_map,
1874 &cache_key)) 1875 &cache_key))
1876 {
1877 GNUNET_free (*client_id);
1878 *client_id = NULL;
1875 return GNUNET_SYSERR; 1879 return GNUNET_SYSERR;
1880 }
1876 pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, 1881 pass = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map,
1877 &cache_key); 1882 &cache_key);
1878 if (NULL == pass) 1883 if (NULL == pass) {
1884 GNUNET_free (*client_id);
1885 *client_id = NULL;
1879 return GNUNET_SYSERR; 1886 return GNUNET_SYSERR;
1887 }
1880 *client_secret = strdup (pass); 1888 *client_secret = strdup (pass);
1881 return GNUNET_OK; 1889 return GNUNET_OK;
1882} 1890}
@@ -1938,12 +1946,16 @@ check_authorization (struct RequestHandle *handle,
1938 GNUNET_free (expected_pass); 1946 GNUNET_free (expected_pass);
1939 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_CLIENT); 1947 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_CLIENT);
1940 handle->response_code = MHD_HTTP_UNAUTHORIZED; 1948 handle->response_code = MHD_HTTP_UNAUTHORIZED;
1949 GNUNET_free (received_cpw);
1950 GNUNET_free (received_cid);
1941 return GNUNET_SYSERR; 1951 return GNUNET_SYSERR;
1942 } 1952 }
1943 GNUNET_free (expected_pass); 1953 GNUNET_free (expected_pass);
1944 } 1954 }
1945 else 1955 else
1946 { 1956 {
1957 GNUNET_free (received_cpw);
1958 GNUNET_free (received_cid);
1947 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_SERVER_ERROR); 1959 handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_SERVER_ERROR);
1948 handle->edesc = GNUNET_strdup ("gnunet configuration failed"); 1960 handle->edesc = GNUNET_strdup ("gnunet configuration failed");
1949 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 1961 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
@@ -2102,9 +2114,13 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2102 handle->edesc = GNUNET_strdup ("invalid code"); 2114 handle->edesc = GNUNET_strdup ("invalid code");
2103 handle->response_code = MHD_HTTP_BAD_REQUEST; 2115 handle->response_code = MHD_HTTP_BAD_REQUEST;
2104 GNUNET_free (code); 2116 GNUNET_free (code);
2117 if (NULL != code_verifier)
2118 GNUNET_free (code_verifier);
2105 GNUNET_SCHEDULER_add_now (&do_error, handle); 2119 GNUNET_SCHEDULER_add_now (&do_error, handle);
2106 return; 2120 return;
2107 } 2121 }
2122 if (NULL != code_verifier)
2123 GNUNET_free (code_verifier);
2108 2124
2109 // create jwt 2125 // create jwt
2110 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, 2126 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg,
@@ -2116,6 +2132,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2116 handle->edesc = GNUNET_strdup ("gnunet configuration failed"); 2132 handle->edesc = GNUNET_strdup ("gnunet configuration failed");
2117 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 2133 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2118 GNUNET_free (code); 2134 GNUNET_free (code);
2135 if (NULL != nonce)
2136 GNUNET_free (nonce);
2119 GNUNET_SCHEDULER_add_now (&do_error, handle); 2137 GNUNET_SCHEDULER_add_now (&do_error, handle);
2120 return; 2138 return;
2121 } 2139 }
@@ -2131,6 +2149,8 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2131 handle->edesc = GNUNET_strdup ("No signing secret configured!"); 2149 handle->edesc = GNUNET_strdup ("No signing secret configured!");
2132 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 2150 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
2133 GNUNET_free (code); 2151 GNUNET_free (code);
2152 if (NULL != nonce)
2153 GNUNET_free (nonce);
2134 GNUNET_SCHEDULER_add_now (&do_error, handle); 2154 GNUNET_SCHEDULER_add_now (&do_error, handle);
2135 return; 2155 return;
2136 } 2156 }
@@ -2141,6 +2161,9 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2141 &expiration_time, 2161 &expiration_time,
2142 (NULL != nonce) ? nonce : NULL, 2162 (NULL != nonce) ? nonce : NULL,
2143 jwt_secret); 2163 jwt_secret);
2164 GNUNET_free (jwt_secret);
2165 if (NULL != nonce)
2166 GNUNET_free (nonce);
2144 access_token = OIDC_access_token_new (&ticket); 2167 access_token = OIDC_access_token_new (&ticket);
2145 /* Store mapping from access token to code so we can later 2168 /* Store mapping from access token to code so we can later
2146 * fall back on the provided attributes in userinfo 2169 * fall back on the provided attributes in userinfo
@@ -2293,6 +2316,8 @@ consume_timeout (void*cls)
2293 handle->edesc = GNUNET_strdup ("invalid code"); 2316 handle->edesc = GNUNET_strdup ("invalid code");
2294 handle->response_code = MHD_HTTP_BAD_REQUEST; 2317 handle->response_code = MHD_HTTP_BAD_REQUEST;
2295 GNUNET_free (cached_code); 2318 GNUNET_free (cached_code);
2319 if (NULL != nonce)
2320 GNUNET_free (nonce);
2296 GNUNET_SCHEDULER_add_now (&do_error, handle); 2321 GNUNET_SCHEDULER_add_now (&do_error, handle);
2297 return; 2322 return;
2298 } 2323 }
@@ -2337,7 +2362,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2337 const struct EgoEntry *aud_ego; 2362 const struct EgoEntry *aud_ego;
2338 const struct GNUNET_IDENTITY_PrivateKey *privkey; 2363 const struct GNUNET_IDENTITY_PrivateKey *privkey;
2339 2364
2340 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Getting userinfo\n"); 2365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting userinfo\n");
2341 GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, 2366 GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY,
2342 strlen (OIDC_AUTHORIZATION_HEADER_KEY), 2367 strlen (OIDC_AUTHORIZATION_HEADER_KEY),
2343 &cache_key); 2368 &cache_key);
@@ -2403,7 +2428,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2403 GNUNET_free (authorization); 2428 GNUNET_free (authorization);
2404 return; 2429 return;
2405 } 2430 }
2406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Consuming ticket\n"); 2431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Consuming ticket\n");
2407 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); 2432 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego);
2408 handle->attr_userinfo_list = 2433 handle->attr_userinfo_list =
2409 GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 2434 GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
@@ -2617,6 +2642,7 @@ oidc_config_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2617 oidc_config_str = json_dumps (oidc_config, JSON_INDENT (1)); 2642 oidc_config_str = json_dumps (oidc_config, JSON_INDENT (1));
2618 resp = GNUNET_REST_create_response (oidc_config_str); 2643 resp = GNUNET_REST_create_response (oidc_config_str);
2619 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2644 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
2645 json_decref (oidc_config);
2620 GNUNET_free (oidc_config_str); 2646 GNUNET_free (oidc_config_str);
2621 cleanup_handle (handle); 2647 cleanup_handle (handle);
2622} 2648}
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 022744c82..84456b386 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -974,9 +974,11 @@ attr_collect (void *cls,
974 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, 974 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
975 sizeof(attr->id)); 975 sizeof(attr->id));
976 json_object_set_new (attr_obj, "id", json_string (id_str)); 976 json_object_set_new (attr_obj, "id", json_string (id_str));
977 GNUNET_free (id_str);
977 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential, 978 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->credential,
978 sizeof(attr->credential)); 979 sizeof(attr->credential));
979 json_object_set_new (attr_obj, "credential", json_string (id_str)); 980 json_object_set_new (attr_obj, "credential", json_string (id_str));
981 GNUNET_free (id_str);
980 json_array_append (handle->resp_object, attr_obj); 982 json_array_append (handle->resp_object, attr_obj);
981 json_decref (attr_obj); 983 json_decref (attr_obj);
982 GNUNET_free (tmp_value); 984 GNUNET_free (tmp_value);
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c
index 2217987ac..14690d7c9 100644
--- a/src/reclaim/reclaim_attribute.c
+++ b/src/reclaim/reclaim_attribute.c
@@ -102,6 +102,37 @@ init ()
102 NULL); 102 NULL);
103} 103}
104 104
105/**
106 * Dual function to #init().
107 */
108void __attribute__ ((destructor))
109RECLAIM_ATTRIBUTE_fini ()
110{
111 struct Plugin *plugin;
112 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
113 const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default ();
114
115 if (pd != dpd)
116 GNUNET_OS_init (dpd);
117
118 for (unsigned int i = 0; i < num_plugins; i++)
119 {
120 plugin = attr_plugins[i];
121 GNUNET_break (NULL ==
122 GNUNET_PLUGIN_unload (plugin->library_name,
123 plugin->api));
124 GNUNET_free (plugin->library_name);
125 GNUNET_free (plugin);
126 }
127 GNUNET_free (attr_plugins);
128
129 if (pd != dpd)
130 GNUNET_OS_init (pd);
131
132 attr_plugins = NULL;
133}
134
135
105 136
106/** 137/**
107 * Convert a type name to the corresponding number 138 * Convert a type name to the corresponding number
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c
index b85ba5955..05601c3d3 100644
--- a/src/reclaim/reclaim_credential.c
+++ b/src/reclaim/reclaim_credential.c
@@ -104,6 +104,38 @@ init ()
104 104
105 105
106/** 106/**
107 * Dual function to #init().
108 */
109void __attribute__ ((destructor))
110RECLAIM_CREDENTIAL_fini ()
111{
112 struct Plugin *plugin;
113 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
114 const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default ();
115
116 if (pd != dpd)
117 GNUNET_OS_init (dpd);
118
119 for (unsigned int i = 0; i < num_plugins; i++)
120 {
121 plugin = credential_plugins[i];
122 GNUNET_break (NULL ==
123 GNUNET_PLUGIN_unload (plugin->library_name,
124 plugin->api));
125 GNUNET_free (plugin->library_name);
126 GNUNET_free (plugin);
127 }
128 GNUNET_free (credential_plugins);
129
130 if (pd != dpd)
131 GNUNET_OS_init (pd);
132
133 credential_plugins = NULL;
134}
135
136
137
138/**
107 * Convert an credential type name to the corresponding number 139 * Convert an credential type name to the corresponding number
108 * 140 *
109 * @param typename name to convert 141 * @param typename name to convert