-fix bugs
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Fri, 6 Oct 2017 07:08:23 +0000 (09:08 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Fri, 6 Oct 2017 07:08:23 +0000 (09:08 +0200)
src/identity-provider/gnunet-idp.c
src/identity-provider/gnunet-service-identity-provider.c
src/identity-provider/identity_attribute.c
src/identity-provider/identity_provider_api.c
src/identity-provider/test_idp_issue.sh

index a8739e6f60e9c50f1a1df296467de452a8daedb6..fbe1d9613ec28780cf283d2847a05a30bf6f5130 100644 (file)
@@ -151,7 +151,7 @@ store_attr_cont (void *cls,
                 "%s\n", emsg);
   } else {
     GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
-                "Sucessfully added identity attribute %s=%s\n",
+                "Successfully added identity attribute %s=%s\n",
                 attr_name, attr_value);
   }
   GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
@@ -251,7 +251,7 @@ iter_cb (void *cls,
       break;
     }
     GNUNET_free (attrs_tmp);
-  } else {
+  } else if (list) {
     GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
                 "%s: %s\n", attr->name, (char*)attr->data);
   }
index 0b7f3389e4bde75d9a064e2e655db85eb33aa443..3b3af331ea6f7bbd45b5345fe551217ee2b3e25f 100644 (file)
@@ -1366,7 +1366,7 @@ static void
 process_parallel_lookup (void *cls, uint32_t rd_count,
                          const struct GNUNET_GNSRECORD_Data *rd)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Parallel lookup finished (count=%u)\n", rd_count);
   struct ParallelLookup *parallel_lookup = cls;
   struct ExchangeHandle *handle = parallel_lookup->handle;
@@ -1385,7 +1385,7 @@ process_parallel_lookup (void *cls, uint32_t rd_count,
                                    rd->data_size,
                                    handle->key,
                                    (void**)&data);
-      GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Adding value: %s\n", data);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding value: %s\n", data);
       token_add_attr (handle->token,
                       parallel_lookup->label,
                       data);
@@ -1400,7 +1400,7 @@ process_parallel_lookup (void *cls, uint32_t rd_count,
         data = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
                                                  rd[i].data,
                                                  rd[i].data_size);
-        GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, "Adding value: %s\n", data);
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding value: %s\n", data);
         token_add_attr (handle->token, parallel_lookup->label, data);
         GNUNET_free (data);
       }
@@ -1485,7 +1485,7 @@ process_lookup_result (void *cls, uint32_t rd_count,
               size, rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
 
   scopes = GNUNET_strdup (buf);
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Scopes %s\n", scopes);
   handle->key = GNUNET_CRYPTO_cpabe_deserialize_key ((void*)(buf + strlen (scopes) + 1),
                                          rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)
@@ -1496,7 +1496,7 @@ process_lookup_result (void *cls, uint32_t rd_count,
     GNUNET_asprintf (&lookup_query,
                      "%s.gnu",
                      scope);
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Looking up %s\n", lookup_query);
     parallel_lookup = GNUNET_new (struct ParallelLookup);
     parallel_lookup->handle = handle;
@@ -1776,9 +1776,19 @@ send_ticket_result (struct IdpClient *client,
 
   attrs_size = attribute_list_serialize_get_size (attrs);
 
+  /* store ticket in DB */
+  if (GNUNET_OK != TKT_database->store_ticket (TKT_database->cls,
+                                               ticket,
+                                               attrs))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unable to store ticket after issue\n");
+    GNUNET_break (0);
+  }
+
   env = GNUNET_MQ_msg_extra (irm,
                              sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket2) + attrs_size,
-                       GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT);
+                             GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT);
   ticket_buf = (struct GNUNET_IDENTITY_PROVIDER_Ticket2 *)&irm[1];
   *ticket_buf = *ticket;
   attrs_buf = (char*)&ticket_buf[1];
@@ -1792,8 +1802,8 @@ send_ticket_result (struct IdpClient *client,
 
 static void
 store_ticket_issue_cont (void *cls,
-                        int32_t success,
-                        const char *emsg)
+                         int32_t success,
+                         const char *emsg)
 {
   struct TicketIssueHandle *handle = cls;
 
@@ -1843,10 +1853,10 @@ serialize_abe_keyinfo2 (const struct TicketIssueHandle *handle,
   }
   buf = GNUNET_malloc (attrs_str_len + size);
   write_ptr = buf;
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Writing attributes\n");
   for (le = handle->attrs->list_head; NULL != le; le = le->next) {
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "%s\n", le->attribute->name);
 
 
@@ -1943,6 +1953,7 @@ issue_ticket_after_abe_bootstrap (void *cls,
                                               ih);
   GNUNET_free (ecdhe_privkey);
   GNUNET_free (label);
+  GNUNET_free (attrs);
   GNUNET_free (code_record_data);
 }
 
@@ -2041,7 +2052,7 @@ static void
 process_parallel_lookup2 (void *cls, uint32_t rd_count,
                           const struct GNUNET_GNSRECORD_Data *rd)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Parallel lookup finished (count=%u)\n", rd_count);
   struct ParallelLookup2 *parallel_lookup = cls;
   struct ConsumeTicketHandle *handle = parallel_lookup->handle;
@@ -2056,6 +2067,7 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count,
   GNUNET_CONTAINER_DLL_remove (handle->parallel_lookups_head,
                                handle->parallel_lookups_tail,
                                parallel_lookup);
+  GNUNET_free (parallel_lookup->label);
   GNUNET_free (parallel_lookup);
   if (1 != rd_count)
     GNUNET_break(0);//TODO
@@ -2075,7 +2087,18 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count,
   }
   if (NULL != handle->parallel_lookups_head)
     return; //Wait for more
-  //Else we are done
+  /* Else we are done */
+
+  /* Store ticket in DB */
+  if (GNUNET_OK != TKT_database->store_ticket (TKT_database->cls,
+                                               &handle->ticket,
+                                               handle->attrs))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unable to store ticket after consume\n");
+    GNUNET_break (0);
+  }
+  
   GNUNET_SCHEDULER_cancel (handle->kill_task);
   attrs_len = attribute_list_serialize_get_size (handle->attrs);
   env = GNUNET_MQ_msg_extra (crm,
@@ -2177,7 +2200,7 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
               size, rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey));
 
   scopes = GNUNET_strdup (buf);
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Scopes %s\n", scopes);
   handle->key = GNUNET_CRYPTO_cpabe_deserialize_key ((void*)(buf + strlen (scopes) + 1),
                                                      rd->data_size - sizeof (struct GNUNET_CRYPTO_EcdhePublicKey)
@@ -2188,7 +2211,7 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
     GNUNET_asprintf (&lookup_query,
                      "%s.gnu",
                      scope);
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Looking up %s\n", lookup_query);
     parallel_lookup = GNUNET_new (struct ParallelLookup2);
     parallel_lookup->handle = handle;
@@ -2204,6 +2227,7 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
     GNUNET_CONTAINER_DLL_insert (handle->parallel_lookups_head,
                                  handle->parallel_lookups_tail,
                                  parallel_lookup);
+    GNUNET_free (lookup_query);
   }
   handle->kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES,3),
                                                     &abort_parallel_lookups2,
@@ -2241,7 +2265,7 @@ handle_consume_ticket_message (void *cls,
   GNUNET_asprintf (&lookup_query,
                    "%s.gnu",
                    rnd_label);
-  GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Looking for ABE key under %s\n", lookup_query);
 
   ch->lookup_request
@@ -2252,6 +2276,7 @@ handle_consume_ticket_message (void *cls,
                          GNUNET_GNS_LO_LOCAL_MASTER,
                          &process_consume_abe_key,
                          ch);
+  GNUNET_free (rnd_label);
   GNUNET_free (lookup_query);
   GNUNET_SERVICE_client_continue (idp->client);
 }
index 1c5654946c99096e18223c056de4e3fbc318ac0b..b90a08e3e67708eb8d2ec68aa953d8b32e51f44b 100644 (file)
@@ -114,7 +114,7 @@ attribute_list_deserialize (const char* data,
     le = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry);
     le->attribute = attribute_deserialize (read_ptr,
                                            data_size - (read_ptr - data));
-    GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Deserialized attribute %s\n", le->attribute->name);
     GNUNET_CONTAINER_DLL_insert (attrs->list_head,
                                  attrs->list_tail,
index 6e0ce7b4208c90122235e5e2e20664fa667f7550..371dce86d56c6cb4afa361d740b2fb4b9244958b 100644 (file)
@@ -560,7 +560,7 @@ handle_consume_ticket_result (void *cls,
   uint32_t r_id = ntohl (msg->id);
 
   attrs_len = ntohs (msg->attrs_len);
-  LOG (GNUNET_ERROR_TYPE_MESSAGE,
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing attribute result.\n");
 
 
@@ -641,7 +641,7 @@ handle_attribute_result (void *cls,
   uint32_t r_id = ntohl (msg->id);
 
   attr_len = ntohs (msg->attr_len);
-  LOG (GNUNET_ERROR_TYPE_MESSAGE,
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Processing attribute result.\n");
 
 
index 38369a33ec161788c50a8b20b03da2f2158c6c44..f2f48057d0255cd7825c134ec2bc8696d790dc38 100755 (executable)
@@ -32,6 +32,6 @@ gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf
 gnunet-idp -e testego -a name -V John -c test_idp.conf
 #gnunet-idp -e testego -D -c test_idp.conf
 TICKET=$(gnunet-idp -e testego -i "email,name" -r $SUBJECT_KEY -c test_idp.conf | awk '{print $1}')
-echo "Consuming $TICKET"
+#echo "Consuming $TICKET"
 gnunet-idp -e rpego -C $TICKET -c test_idp.conf
 gnunet-arm -e -c test_idp.conf