diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-11-26 15:52:47 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2018-11-26 15:52:47 +0100 |
commit | 1413d53c17872444afe93c767728a2d22c63143e (patch) | |
tree | 33a9ba86a7fccaee4ea887a0ed639f89ac4a9722 | |
parent | 61787bfa37e0ac5998e01d9c4806600033c19c74 (diff) | |
download | gnunet-1413d53c17872444afe93c767728a2d22c63143e.tar.gz gnunet-1413d53c17872444afe93c767728a2d22c63143e.zip |
RECLAIM: fix bootstrapping to not purge all records
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 105 |
1 files changed, 64 insertions, 41 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 3321a79d8..600b5aec0 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -228,6 +228,11 @@ struct AbeBootstrapHandle | |||
228 | * The issuer egos ABE master key | 228 | * The issuer egos ABE master key |
229 | */ | 229 | */ |
230 | struct GNUNET_ABE_AbeMasterKey *abe_key; | 230 | struct GNUNET_ABE_AbeMasterKey *abe_key; |
231 | |||
232 | /** | ||
233 | * Recreate master keys | ||
234 | */ | ||
235 | int recreate; | ||
231 | }; | 236 | }; |
232 | 237 | ||
233 | /** | 238 | /** |
@@ -730,31 +735,6 @@ bootstrap_store_cont (void *cls, | |||
730 | GNUNET_free (abh); | 735 | GNUNET_free (abh); |
731 | } | 736 | } |
732 | 737 | ||
733 | /** | ||
734 | * Generates and stores a new ABE key | ||
735 | */ | ||
736 | static void | ||
737 | bootstrap_store_task (void *cls) | ||
738 | { | ||
739 | struct AbeBootstrapHandle *abh = cls; | ||
740 | struct GNUNET_GNSRECORD_Data rd[1]; | ||
741 | char *key; | ||
742 | |||
743 | rd[0].data_size = GNUNET_ABE_cpabe_serialize_master_key (abh->abe_key, | ||
744 | (void**)&key); | ||
745 | rd[0].data = key; | ||
746 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER; | ||
747 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | ||
748 | rd[0].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; //TODO sane? | ||
749 | abh->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, | ||
750 | &abh->identity, | ||
751 | "+", | ||
752 | 1, | ||
753 | rd, | ||
754 | &bootstrap_store_cont, | ||
755 | abh); | ||
756 | GNUNET_free (key); | ||
757 | } | ||
758 | 738 | ||
759 | /** | 739 | /** |
760 | * Error checking for ABE master | 740 | * Error checking for ABE master |
@@ -784,8 +764,10 @@ bootstrap_abe_result (void *cls, | |||
784 | for (uint32_t i=0;i<rd_count;i++) { | 764 | for (uint32_t i=0;i<rd_count;i++) { |
785 | if (GNUNET_GNSRECORD_TYPE_ABE_MASTER != rd[i].record_type) | 765 | if (GNUNET_GNSRECORD_TYPE_ABE_MASTER != rd[i].record_type) |
786 | continue; | 766 | continue; |
767 | if (GNUNET_YES == abh->recreate) | ||
768 | continue; | ||
787 | abe_key = GNUNET_ABE_cpabe_deserialize_master_key (rd[i].data, | 769 | abe_key = GNUNET_ABE_cpabe_deserialize_master_key (rd[i].data, |
788 | rd[i].data_size); | 770 | rd[i].data_size); |
789 | abh->proc (abh->proc_cls, abe_key); | 771 | abh->proc (abh->proc_cls, abe_key); |
790 | GNUNET_free (abh); | 772 | GNUNET_free (abh); |
791 | return; | 773 | return; |
@@ -793,7 +775,47 @@ bootstrap_abe_result (void *cls, | |||
793 | 775 | ||
794 | //No ABE master found, bootstrapping... | 776 | //No ABE master found, bootstrapping... |
795 | abh->abe_key = GNUNET_ABE_cpabe_create_master_key (); | 777 | abh->abe_key = GNUNET_ABE_cpabe_create_master_key (); |
796 | GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh); | 778 | |
779 | { | ||
780 | struct GNUNET_GNSRECORD_Data rdn[rd_count+1]; | ||
781 | char *key; | ||
782 | unsigned int rd_count_new = rd_count + 1; | ||
783 | |||
784 | for (uint32_t i=0;i<rd_count;i++) { | ||
785 | if ((GNUNET_YES == abh->recreate) && | ||
786 | (GNUNET_GNSRECORD_TYPE_ABE_MASTER == rd[i].record_type)) | ||
787 | { | ||
788 | rdn[i].data_size = GNUNET_ABE_cpabe_serialize_master_key (abh->abe_key, | ||
789 | (void**)&key); | ||
790 | rdn[i].data = key; | ||
791 | rdn[i].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER; | ||
792 | rdn[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | ||
793 | rdn[i].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; //TODO sane? | ||
794 | rd_count_new = rd_count; | ||
795 | } else { | ||
796 | GNUNET_memcpy (&rdn[i], | ||
797 | &rd[i], | ||
798 | sizeof (struct GNUNET_GNSRECORD_Data)); | ||
799 | } | ||
800 | } | ||
801 | if (rd_count < rd_count_new) { | ||
802 | rdn[rd_count].data_size = GNUNET_ABE_cpabe_serialize_master_key (abh->abe_key, | ||
803 | (void**)&key); | ||
804 | rdn[rd_count].data = key; | ||
805 | rdn[rd_count].record_type = GNUNET_GNSRECORD_TYPE_ABE_MASTER; | ||
806 | rdn[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | ||
807 | rdn[rd_count].expiration_time = GNUNET_TIME_UNIT_HOURS.rel_value_us; //TODO sane? | ||
808 | } | ||
809 | |||
810 | abh->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, | ||
811 | &abh->identity, | ||
812 | "+", | ||
813 | rd_count_new, | ||
814 | rdn, | ||
815 | &bootstrap_store_cont, | ||
816 | abh); | ||
817 | GNUNET_free (key); | ||
818 | } | ||
797 | } | 819 | } |
798 | 820 | ||
799 | /** | 821 | /** |
@@ -816,16 +838,17 @@ bootstrap_abe (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | |||
816 | if (GNUNET_YES == recreate) | 838 | if (GNUNET_YES == recreate) |
817 | { | 839 | { |
818 | abh->abe_key = GNUNET_ABE_cpabe_create_master_key (); | 840 | abh->abe_key = GNUNET_ABE_cpabe_create_master_key (); |
819 | GNUNET_SCHEDULER_add_now (&bootstrap_store_task, abh); | 841 | abh->recreate = GNUNET_YES; |
820 | } else { | 842 | } else { |
821 | abh->ns_qe = GNUNET_NAMESTORE_records_lookup (ns_handle, | 843 | abh->recreate = GNUNET_NO; |
822 | identity, | ||
823 | "+", | ||
824 | &bootstrap_abe_error, | ||
825 | abh, | ||
826 | &bootstrap_abe_result, | ||
827 | abh); | ||
828 | } | 844 | } |
845 | abh->ns_qe = GNUNET_NAMESTORE_records_lookup (ns_handle, | ||
846 | identity, | ||
847 | "+", | ||
848 | &bootstrap_abe_error, | ||
849 | abh, | ||
850 | &bootstrap_abe_result, | ||
851 | abh); | ||
829 | } | 852 | } |
830 | 853 | ||
831 | 854 | ||
@@ -1157,7 +1180,7 @@ send_revocation_finished (struct TicketRevocationHandle *rh, | |||
1157 | { | 1180 | { |
1158 | struct GNUNET_MQ_Envelope *env; | 1181 | struct GNUNET_MQ_Envelope *env; |
1159 | struct RevokeTicketResultMessage *trm; | 1182 | struct RevokeTicketResultMessage *trm; |
1160 | 1183 | ||
1161 | GNUNET_break(TKT_database->delete_ticket (TKT_database->cls, | 1184 | GNUNET_break(TKT_database->delete_ticket (TKT_database->cls, |
1162 | &rh->ticket)); | 1185 | &rh->ticket)); |
1163 | 1186 | ||
@@ -1441,7 +1464,7 @@ check_attr_cb (void *cls, | |||
1441 | buf = GNUNET_malloc (buf_size); | 1464 | buf = GNUNET_malloc (buf_size); |
1442 | rh->attrs->list_head->claim->version++; | 1465 | rh->attrs->list_head->claim->version++; |
1443 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, | 1466 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, |
1444 | buf); | 1467 | buf); |
1445 | GNUNET_asprintf (&policy, "%s_%lu", | 1468 | GNUNET_asprintf (&policy, "%s_%lu", |
1446 | rh->attrs->list_head->claim->name, | 1469 | rh->attrs->list_head->claim->name, |
1447 | rh->attrs->list_head->claim->version); | 1470 | rh->attrs->list_head->claim->version); |
@@ -1743,7 +1766,7 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count, | |||
1743 | 1766 | ||
1744 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 1767 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
1745 | attr_le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (data, | 1768 | attr_le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (data, |
1746 | attr_len); | 1769 | attr_len); |
1747 | attr_le->claim->version = ntohl(*(uint32_t*)rd->data); | 1770 | attr_le->claim->version = ntohl(*(uint32_t*)rd->data); |
1748 | GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head, | 1771 | GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head, |
1749 | handle->attrs->list_tail, | 1772 | handle->attrs->list_tail, |
@@ -1775,7 +1798,7 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count, | |||
1775 | crm->identity = handle->ticket.identity; | 1798 | crm->identity = handle->ticket.identity; |
1776 | data_tmp = (char *) &crm[1]; | 1799 | data_tmp = (char *) &crm[1]; |
1777 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (handle->attrs, | 1800 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (handle->attrs, |
1778 | data_tmp); | 1801 | data_tmp); |
1779 | GNUNET_MQ_send (handle->client->mq, env); | 1802 | GNUNET_MQ_send (handle->client->mq, env); |
1780 | GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head, | 1803 | GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head, |
1781 | handle->client->consume_op_tail, | 1804 | handle->client->consume_op_tail, |
@@ -2013,7 +2036,7 @@ attr_store_task (void *cls) | |||
2013 | buf = GNUNET_malloc (buf_size); | 2036 | buf = GNUNET_malloc (buf_size); |
2014 | 2037 | ||
2015 | GNUNET_RECLAIM_ATTRIBUTE_serialize (as_handle->claim, | 2038 | GNUNET_RECLAIM_ATTRIBUTE_serialize (as_handle->claim, |
2016 | buf); | 2039 | buf); |
2017 | 2040 | ||
2018 | GNUNET_asprintf (&policy, | 2041 | GNUNET_asprintf (&policy, |
2019 | "%s_%lu", | 2042 | "%s_%lu", |
@@ -2112,7 +2135,7 @@ handle_attribute_store_message (void *cls, | |||
2112 | 2135 | ||
2113 | as_handle = GNUNET_new (struct AttributeStoreHandle); | 2136 | as_handle = GNUNET_new (struct AttributeStoreHandle); |
2114 | as_handle->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char*)&sam[1], | 2137 | as_handle->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char*)&sam[1], |
2115 | data_len); | 2138 | data_len); |
2116 | 2139 | ||
2117 | as_handle->r_id = ntohl (sam->id); | 2140 | as_handle->r_id = ntohl (sam->id); |
2118 | as_handle->identity = sam->identity; | 2141 | as_handle->identity = sam->identity; |