aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 19:12:17 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 19:12:17 +0200
commit8c48060e129877767f58a8403deba8a4beaeea24 (patch)
tree79cbe944d851c7c7536b63641eb36cb96a87b4b5
parentb12644f83637c2508a11927490ae0b94d8ee4095 (diff)
downloadgnunet-8c48060e129877767f58a8403deba8a4beaeea24.tar.gz
gnunet-8c48060e129877767f58a8403deba8a4beaeea24.zip
-fix rest plugin issues
-rw-r--r--src/gns/plugin_rest_gns.c8
-rw-r--r--src/identity/plugin_rest_identity.c1
-rw-r--r--src/namestore/plugin_rest_namestore.c1
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c2
-rw-r--r--src/reclaim/oidc_helper.c2
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c27
-rw-r--r--src/reclaim/plugin_rest_reclaim.c7
-rw-r--r--src/rest/gnunet-rest-server.c2
-rw-r--r--src/rest/plugin_rest_config.c8
9 files changed, 31 insertions, 27 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index a3006ce23..1d560515c 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -405,8 +405,6 @@ libgnunet_plugin_rest_gns_init (void *cls)
405 struct GNUNET_REST_Plugin *api; 405 struct GNUNET_REST_Plugin *api;
406 406
407 cfg = cls; 407 cfg = cls;
408 if (NULL != plugin.cfg)
409 return NULL; /* can only initialize once! */
410 memset (&plugin, 0, sizeof(struct Plugin)); 408 memset (&plugin, 0, sizeof(struct Plugin));
411 plugin.cfg = cfg; 409 plugin.cfg = cfg;
412 api = GNUNET_new (struct GNUNET_REST_Plugin); 410 api = GNUNET_new (struct GNUNET_REST_Plugin);
@@ -437,12 +435,14 @@ void *
437libgnunet_plugin_rest_gns_done (void *cls) 435libgnunet_plugin_rest_gns_done (void *cls)
438{ 436{
439 struct GNUNET_REST_Plugin *api = cls; 437 struct GNUNET_REST_Plugin *api = cls;
440 struct Plugin *plugin = api->cls; 438 struct Plugin *plugin;
441 439
442 plugin->cfg = NULL;
443 if (NULL != gns) 440 if (NULL != gns)
444 GNUNET_GNS_disconnect (gns); 441 GNUNET_GNS_disconnect (gns);
445 442
443 plugin = api->cls;
444
445 plugin->cfg = NULL;
446 446
447 GNUNET_free (allow_methods); 447 GNUNET_free (allow_methods);
448 GNUNET_free (api); 448 GNUNET_free (api);
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 6859396d6..5e7d719f0 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -1353,6 +1353,7 @@ libgnunet_plugin_rest_identity_init (void *cls)
1353 MHD_HTTP_METHOD_PUT, 1353 MHD_HTTP_METHOD_PUT,
1354 MHD_HTTP_METHOD_DELETE, 1354 MHD_HTTP_METHOD_DELETE,
1355 MHD_HTTP_METHOD_OPTIONS); 1355 MHD_HTTP_METHOD_OPTIONS);
1356 state = ID_REST_STATE_INIT;
1356 identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); 1357 identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
1357 1358
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n")); 1359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n"));
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c
index c993518ea..0d52b5625 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/namestore/plugin_rest_namestore.c
@@ -1065,6 +1065,7 @@ libgnunet_plugin_rest_namestore_init (void *cls)
1065 api->cls = &plugin; 1065 api->cls = &plugin;
1066 api->name = GNUNET_REST_API_NS_NAMESTORE; 1066 api->name = GNUNET_REST_API_NS_NAMESTORE;
1067 api->process_request = &rest_process_request; 1067 api->process_request = &rest_process_request;
1068 state = ID_REST_STATE_INIT;
1068 GNUNET_asprintf (&allow_methods, 1069 GNUNET_asprintf (&allow_methods,
1069 "%s, %s, %s, %s, %s", 1070 "%s, %s, %s, %s, %s",
1070 MHD_HTTP_METHOD_GET, 1071 MHD_HTTP_METHOD_GET,
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c
index 1d7461b1a..669330b39 100644
--- a/src/peerinfo-tool/plugin_rest_peerinfo.c
+++ b/src/peerinfo-tool/plugin_rest_peerinfo.c
@@ -800,6 +800,8 @@ libgnunet_plugin_rest_peerinfo_done (void *cls)
800 struct Plugin *plugin = api->cls; 800 struct Plugin *plugin = api->cls;
801 801
802 plugin->cfg = NULL; 802 plugin->cfg = NULL;
803 if (NULL != peerinfo_handle)
804 GNUNET_PEERINFO_disconnect (peerinfo_handle);
803 805
804 GNUNET_free (allow_methods); 806 GNUNET_free (allow_methods);
805 GNUNET_free (api); 807 GNUNET_free (api);
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index 9b5938c43..d0345108e 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -621,6 +621,7 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
621 621
622 // cmp code_challenge code_verifier 622 // cmp code_challenge code_verifier
623 code_challenge_len = ntohl (params->code_challenge_len); 623 code_challenge_len = ntohl (params->code_challenge_len);
624 code_challenge = ((char *) &params[1]);
624 if (0 != code_challenge_len) /* Only check if this code requires a CV */ 625 if (0 != code_challenge_len) /* Only check if this code requires a CV */
625 { 626 {
626 if (NULL == code_verifier) 627 if (NULL == code_verifier)
@@ -639,7 +640,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
639 // encode code verifier 640 // encode code verifier
640 GNUNET_STRINGS_base64url_encode (code_verifier_hash, 256 / 8, 641 GNUNET_STRINGS_base64url_encode (code_verifier_hash, 256 / 8,
641 &expected_code_challenge); 642 &expected_code_challenge);
642 code_challenge = ((char *) &params[1]);
643 GNUNET_free (code_verifier_hash); 643 GNUNET_free (code_verifier_hash);
644 if (0 != 644 if (0 !=
645 strncmp (expected_code_challenge, code_challenge, code_challenge_len)) 645 strncmp (expected_code_challenge, code_challenge, code_challenge_len))
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 3221c1cce..db138c26b 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -1971,7 +1971,6 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1971 struct GNUNET_RECLAIM_AttestationList *al = NULL; 1971 struct GNUNET_RECLAIM_AttestationList *al = NULL;
1972 struct GNUNET_RECLAIM_Ticket ticket; 1972 struct GNUNET_RECLAIM_Ticket ticket;
1973 struct GNUNET_CRYPTO_EcdsaPublicKey cid; 1973 struct GNUNET_CRYPTO_EcdsaPublicKey cid;
1974 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
1975 struct GNUNET_HashCode cache_key; 1974 struct GNUNET_HashCode cache_key;
1976 struct MHD_Response *resp; 1975 struct MHD_Response *resp;
1977 char *grant_type; 1976 char *grant_type;
@@ -2043,7 +2042,6 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2043 GNUNET_SCHEDULER_add_now (&do_error, handle); 2042 GNUNET_SCHEDULER_add_now (&do_error, handle);
2044 return; 2043 return;
2045 } 2044 }
2046 privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
2047 2045
2048 // REQUIRED code verifier 2046 // REQUIRED code verifier
2049 code_verifier = get_url_parameter_copy (handle, OIDC_CODE_VERIFIER_KEY); 2047 code_verifier = get_url_parameter_copy (handle, OIDC_CODE_VERIFIER_KEY);
@@ -2590,6 +2588,12 @@ libgnunet_plugin_rest_openid_connect_init (void *cls)
2590 return api; 2588 return api;
2591} 2589}
2592 2590
2591static int
2592cleanup_hashmap (void *cls, const struct GNUNET_HashCode *key, void *value)
2593{
2594 GNUNET_free (value);
2595 return GNUNET_YES;
2596}
2593 2597
2594/** 2598/**
2595 * Exit point from the plugin. 2599 * Exit point from the plugin.
@@ -2606,18 +2610,13 @@ libgnunet_plugin_rest_openid_connect_done (void *cls)
2606 2610
2607 plugin->cfg = NULL; 2611 plugin->cfg = NULL;
2608 2612
2609 struct GNUNET_CONTAINER_MultiHashMapIterator *hashmap_it; 2613 if (NULL != OIDC_cookie_jar_map)
2610 void *value = NULL; 2614 {
2611 hashmap_it = 2615 GNUNET_CONTAINER_multihashmap_iterate (OIDC_cookie_jar_map,
2612 GNUNET_CONTAINER_multihashmap_iterator_create (OIDC_cookie_jar_map); 2616 &cleanup_hashmap,
2613 while (GNUNET_YES == 2617 NULL);
2614 GNUNET_CONTAINER_multihashmap_iterator_next (hashmap_it, NULL, 2618 GNUNET_CONTAINER_multihashmap_destroy (OIDC_cookie_jar_map);
2615 value)) 2619 }
2616 GNUNET_free (value);
2617 GNUNET_CONTAINER_multihashmap_iterator_destroy (hashmap_it);
2618 GNUNET_CONTAINER_multihashmap_destroy (OIDC_cookie_jar_map);
2619
2620 GNUNET_CONTAINER_multihashmap_iterator_destroy (hashmap_it);
2621 GNUNET_free (allow_methods); 2620 GNUNET_free (allow_methods);
2622 if (NULL != gns_handle) 2621 if (NULL != gns_handle)
2623 GNUNET_GNS_disconnect (gns_handle); 2622 GNUNET_GNS_disconnect (gns_handle);
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index c2d14825e..0aeb0647a 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -1422,12 +1422,14 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1422 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL; 1422 handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
1423 handle->proc_cls = proc_cls; 1423 handle->proc_cls = proc_cls;
1424 handle->proc = proc; 1424 handle->proc = proc;
1425 state = ID_REST_STATE_INIT;
1426 handle->rest_handle = rest_handle; 1425 handle->rest_handle = rest_handle;
1427 1426
1428 handle->url = GNUNET_strdup (rest_handle->url); 1427 handle->url = GNUNET_strdup (rest_handle->url);
1429 if (handle->url[strlen (handle->url) - 1] == '/') 1428 if (handle->url[strlen (handle->url) - 1] == '/')
1430 handle->url[strlen (handle->url) - 1] = '\0'; 1429 handle->url[strlen (handle->url) - 1] = '\0';
1430 handle->timeout_task =
1431 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1432
1431 if (GNUNET_NO == 1433 if (GNUNET_NO ==
1432 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) 1434 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1433 { 1435 {
@@ -1435,8 +1437,6 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1435 return GNUNET_NO; 1437 return GNUNET_NO;
1436 } 1438 }
1437 1439
1438 handle->timeout_task =
1439 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1440 return GNUNET_YES; 1440 return GNUNET_YES;
1441} 1441}
1442 1442
@@ -1470,6 +1470,7 @@ libgnunet_plugin_rest_reclaim_init (void *cls)
1470 MHD_HTTP_METHOD_DELETE, 1470 MHD_HTTP_METHOD_DELETE,
1471 MHD_HTTP_METHOD_OPTIONS); 1471 MHD_HTTP_METHOD_OPTIONS);
1472 identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL); 1472 identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
1473 state = ID_REST_STATE_INIT;
1473 idp = GNUNET_RECLAIM_connect (cfg); 1474 idp = GNUNET_RECLAIM_connect (cfg);
1474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1475 _ ("Identity Provider REST API initialized\n")); 1476 _ ("Identity Provider REST API initialized\n"));
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 8a1c7e32f..e6e03b16d 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -937,7 +937,7 @@ do_shutdown (void *cls)
937 GNUNET_CONTAINER_DLL_remove (plugins_head, 937 GNUNET_CONTAINER_DLL_remove (plugins_head,
938 plugins_tail, 938 plugins_tail,
939 ple); 939 ple);
940 GNUNET_PLUGIN_unload (ple->libname, NULL); 940 GNUNET_PLUGIN_unload (ple->libname, ple->plugin);
941 GNUNET_free (ple->libname); 941 GNUNET_free (ple->libname);
942 GNUNET_free (ple); 942 GNUNET_free (ple);
943 } 943 }
diff --git a/src/rest/plugin_rest_config.c b/src/rest/plugin_rest_config.c
index d9ae57acd..e5d0fffb0 100644
--- a/src/rest/plugin_rest_config.c
+++ b/src/rest/plugin_rest_config.c
@@ -392,15 +392,13 @@ libgnunet_plugin_rest_config_init (void *cls)
392 cfg = cls; 392 cfg = cls;
393 struct GNUNET_REST_Plugin *api; 393 struct GNUNET_REST_Plugin *api;
394 394
395 if (NULL != plugin.cfg)
396 return NULL; /* can only initialize once! */
397 memset (&plugin, 0, sizeof(struct Plugin)); 395 memset (&plugin, 0, sizeof(struct Plugin));
398 plugin.cfg = cfg; 396 plugin.cfg = cfg;
399 api = GNUNET_new (struct GNUNET_REST_Plugin); 397 api = GNUNET_new (struct GNUNET_REST_Plugin);
400 api->cls = &plugin; 398 api->cls = &plugin;
401 api->name = GNUNET_REST_API_NS_CONFIG; 399 api->name = GNUNET_REST_API_NS_CONFIG;
402 api->process_request = &rest_config_process_request; 400 api->process_request = &rest_config_process_request;
403 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("CONFIG REST API initialized\n")); 401 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("CONFIG REST API initialized\n"));
404 return api; 402 return api;
405} 403}
406 404
@@ -415,7 +413,9 @@ void *
415libgnunet_plugin_rest_config_done (void *cls) 413libgnunet_plugin_rest_config_done (void *cls)
416{ 414{
417 struct GNUNET_REST_Plugin *api = cls; 415 struct GNUNET_REST_Plugin *api = cls;
418 struct Plugin *plugin = api->cls; 416 struct Plugin *plugin;
417
418 plugin = api->cls;
419 419
420 plugin->cfg = NULL; 420 plugin->cfg = NULL;
421 GNUNET_free (api); 421 GNUNET_free (api);