bugfixes
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 4 Feb 2020 21:50:32 +0000 (22:50 +0100)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Sun, 9 Feb 2020 19:38:10 +0000 (20:38 +0100)
src/include/Makefile.am
src/include/gnunet_protocols.h
src/reclaim/gnunet-reclaim.c
src/reclaim/gnunet-service-reclaim.c
src/reclaim/reclaim_api.c

index b53f2420dec059c0e807e34bf8f097553c547434..69a493f1eca341d48c363e5822f100c0bf5a0aeb 100644 (file)
@@ -57,7 +57,7 @@ gnunetinclude_HEADERS = \
   gnunet_identity_service.h \
   gnunet_abe_lib.h \
   gnunet_reclaim_attribute_lib.h \
-  gnunet_reclaim_attribute_plugin.h \
+  gnunet_reclaim_plugin.h \
   gnunet_reclaim_service.h \
   gnunet_json_lib.h \
   gnunet_load_lib.h \
index d92015787728abee666571855d35f09f363d1e04..e67e35f382db67be4bdc97c1d10b883321d147c6 100644 (file)
@@ -2720,11 +2720,11 @@ extern "C" {
 
 #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT 979
 
-#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START 963
+#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START 980
 
-#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP 964
+#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_STOP 981
 
-#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT 965
+#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_NEXT 982
 
 
 /**************************************************
index 35c1258f554de9d6309797e4d43da555ce652db3..3e31fef4ce3a02390adf5a61259c8ce6ecc85edb 100644 (file)
@@ -208,6 +208,8 @@ do_cleanup (void *cls)
     GNUNET_RECLAIM_cancel (reclaim_op);
   if (NULL != attr_iterator)
     GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
+  if (NULL != attest_iterator)
+    GNUNET_RECLAIM_get_attestations_stop (attest_iterator);
   if (NULL != ticket_iterator)
     GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
   if (NULL != reclaim_handle)
@@ -467,7 +469,6 @@ iter_finished (void *cls)
     {
       claim->attestation = attestation;
     }
-    else
     reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
                                                  pkey,
                                                  claim,
@@ -569,13 +570,14 @@ static void
 attest_iter_finished (void *cls)
 {
   attest_iterator = NULL;
-  //Add new attestation
+
+  // Add new attestation
   if ((NULL != attestation_name) &&
       (NULL != attr_value))
   {
     struct GNUNET_RECLAIM_Attestation *attestation =
       GNUNET_RECLAIM_attestation_new (attestation_name,
-                                      GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, //FIXME hardcoded
+                                      GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, // FIXME hardcoded
                                       attr_value,
                                       strlen (attr_value));
     reclaim_op = GNUNET_RECLAIM_attestation_store (reclaim_handle,
@@ -587,19 +589,20 @@ attest_iter_finished (void *cls)
     return;
 
   }
-  if (list_attestations)
+  if (list_attestations)
   {
-    attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
-                                                         pkey,
-                                                         &iter_error,
-                                                         NULL,
-                                                         &iter_cb,
-                                                         NULL,
-                                                         &iter_finished,
-                                                         NULL);
-
+    cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+    return;
   }
-  cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+  attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
+                                                       pkey,
+                                                       &iter_error,
+                                                       NULL,
+                                                       &iter_cb,
+                                                       NULL,
+                                                       &iter_finished,
+                                                       NULL);
+
 }
 
 
@@ -620,7 +623,7 @@ attest_iter_cb (void *cls,
     attest_str = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
                                                              attest->data,
                                                              attest->data_size);
-    attest_type = GNUNET_RECLAIM_attribute_number_to_typename (attest->type);
+    attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
     id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
     fprintf (stdout,
              "Name: %s; Value: %s (%s); Flag %u; ID: %s\n",
@@ -662,19 +665,6 @@ start_process ()
                                                              NULL);
     return;
   }
-  if (list_attestations)
-  {
-    attest_iterator = GNUNET_RECLAIM_get_attestations_start (reclaim_handle,
-                                                             pkey,
-                                                             &iter_error,
-                                                             NULL,
-                                                             &attest_iter_cb,
-                                                             NULL,
-                                                             &
-                                                             attest_iter_finished,
-                                                             NULL);
-    return;
-  }
 
   if ((NULL != rp) &&
       (GNUNET_OK !=
@@ -697,6 +687,16 @@ start_process ()
 
   attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
   claim = NULL;
+  attest_iterator = GNUNET_RECLAIM_get_attestations_start (reclaim_handle,
+                                                           pkey,
+                                                           &iter_error,
+                                                           NULL,
+                                                           &attest_iter_cb,
+                                                           NULL,
+                                                           &
+                                                           attest_iter_finished,
+                                                           NULL);
+
 }
 
 
@@ -799,7 +799,8 @@ main (int argc, char *const argv[])
     GNUNET_GETOPT_option_string ('I',
                                  "Attestation ID",
                                  "ATTESTATION_ID",
-                                 gettext_noop ("Attestation to use for attribute"),
+                                 gettext_noop (
+                                   "Attestation to use for attribute"),
                                  &attestation_id),
     GNUNET_GETOPT_option_string ('N',
                                  "attestation-name",
index f6fd04eeb24da8ede3cadba0d0b2739f051ed42c..61d0296653084430ebf82df23b6efc4497c8597f 100644 (file)
@@ -1718,31 +1718,26 @@ attr_iter_cb (void *cls,
   struct GNUNET_MQ_Envelope *env;
   char *data_tmp;
 
-  if (rd_count == 0)
+  if ((rd_count != 1) ||
+      (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd->record_type))
   {
     GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
     return;
   }
-
-  for (int i = 0; i<rd_count; i++)
-  {
-    if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE != rd[i].record_type)
-      continue;
-    struct AttributeResultMessage *arm;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
-                label);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Sending ATTRIBUTE_RESULT message\n");
-    env = GNUNET_MQ_msg_extra (arm,
-                               rd[i].data_size,
-                               GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
-    arm->id = htonl (ai->request_id);
-    arm->attr_len = htons (rd[i].data_size);
-    GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
-    data_tmp = (char *) &arm[1];
-    GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
-    GNUNET_MQ_send (ai->client->mq, env);
-  }
+  struct AttributeResultMessage *arm;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
+              label);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Sending ATTRIBUTE_RESULT message\n");
+  env = GNUNET_MQ_msg_extra (arm,
+                             rd->data_size,
+                             GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
+  arm->id = htonl (ai->request_id);
+  arm->attr_len = htons (rd->data_size);
+  GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
+  data_tmp = (char *) &arm[1];
+  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
+  GNUNET_MQ_send (ai->client->mq, env);
 }
 
 
@@ -1907,31 +1902,27 @@ attest_iter_cb (void *cls,
   struct GNUNET_MQ_Envelope *env;
   char *data_tmp;
 
-  if (rd_count == 0)
+  if ((rd_count != 1) ||
+      (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd->record_type))
   {
     GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
     return;
   }
 
-  for (int i = 0; i<rd_count; i++)
-  {
-    if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION != rd[i].record_type)
-      continue;
-    struct AttestationResultMessage *arm;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
-                label);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Sending ATTESTATION_RESULT message\n");
-    env = GNUNET_MQ_msg_extra (arm,
-                               rd[i].data_size,
-                               GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
-    arm->id = htonl (ai->request_id);
-    arm->attestation_len = htons (rd[i].data_size);
-    GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
-    data_tmp = (char *) &arm[1];
-    GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
-    GNUNET_MQ_send (ai->client->mq, env);
-  }
+  struct AttestationResultMessage *arm;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
+              label);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Sending ATTESTATION_RESULT message\n");
+  env = GNUNET_MQ_msg_extra (arm,
+                             rd->data_size,
+                             GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
+  arm->id = htonl (ai->request_id);
+  arm->attestation_len = htons (rd->data_size);
+  GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
+  data_tmp = (char *) &arm[1];
+  GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
+  GNUNET_MQ_send (ai->client->mq, env);
 }
 
 
index 89b9ea0f75502b9b7b4ae69dc58e07fe57970036..3820550c93390f58b3d7ea9c86826c69afcc7f34 100644 (file)
@@ -1423,7 +1423,7 @@ GNUNET_RECLAIM_get_attestations_start (
   ait->identity = *identity;
   GNUNET_CONTAINER_DLL_insert_tail (h->ait_head, h->ait_tail, ait);
   env =
-    GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START);
+    GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_ITERATION_START);
   msg->id = htonl (rid);
   msg->identity = *identity;
   if (NULL == h->mq)