From d32b49954fe42bb168fc93ee61ad6e8a99822828 Mon Sep 17 00:00:00 2001 From: Markus Voggenreiter Date: Tue, 29 Oct 2019 21:02:17 +0100 Subject: [PATCH] Fixed Reference Deletion --- src/include/gnunet_gnsrecord_lib.h | 16 +++++++++--- src/reclaim/gnunet-service-reclaim.c | 36 +++++++++++++++++++------- src/reclaim/plugin_gnsrecord_reclaim.c | 6 +++-- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 9e430c2aa..b49e39b76 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h @@ -141,14 +141,24 @@ extern "C" { #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 /** - * Record type for reclaim attestation records + * Record type for reclaim identity attestation */ #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR 65554 /** - * Record type for reclaim attestation references + * Record type for reclaim identity references + */ +#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE 65555 + +/** + * Record type for reclaim attestation records + */ +#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF 65556 + +/** + * Record type for reclaim reference records */ -#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF 65555 +#define GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE_REF 65557 /** * Flags that can be set for a record. diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index 1f320e196..0c27cdbef 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c @@ -1296,7 +1296,7 @@ ref_add_cb (void *cls, } rd_new[rd_count].data_size = buf_size; rd_new[rd_count].data = buf; - rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF; + rd_new[rd_count].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE; rd_new[rd_count].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; rd_new[rd_count].expiration_time = ash->exp.rel_value_us; ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, @@ -1450,19 +1450,27 @@ ticket_iter (void *cls, struct AttributeDeleteHandle *adh = cls; struct TicketRecordsEntry *le; int has_changed = GNUNET_NO; - for (int i = 0; i < rd_count; i++) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Next Zone Iteration %u and record type is %u\n", rd_count, + rd[i].record_type); if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) && - (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) && + (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE_REF != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF != rd[i].record_type)) continue; - if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) - continue; - if (0 != memcmp (rd[i].data, (&adh->attest->id), sizeof(uint64_t))) - continue; - if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) - continue; + if (&adh->claim != NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Claim is existend: %u \n", adh->claim->id); + if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) + continue; + } + if (&adh->attest != NULL) + if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t))) + continue; + if (&adh->reference != NULL) + if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t))) + continue; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute or Attestation/Reference to delete found (%s)\n", @@ -1482,6 +1490,7 @@ ticket_iter (void *cls, adh->tickets_to_update_tail, le); } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Next Zone Iteration \n"); GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1); } @@ -1558,7 +1567,7 @@ update_tickets (void *cls) if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) continue; - if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) + if ((GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE_REF == rd[i].record_type) && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) continue; if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF == rd[i].record_type) @@ -1706,6 +1715,8 @@ handle_attribute_delete_message (void *cls, adh = GNUNET_new (struct AttributeDeleteHandle); adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *) &dam[1], data_len); + adh->reference = NULL; + adh->attest = NULL; adh->r_id = ntohl (dam->id); adh->identity = dam->identity; @@ -1792,6 +1803,8 @@ handle_attestation_delete_message (void *cls, adh = GNUNET_new (struct AttributeDeleteHandle); adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1], data_len); + adh->reference = NULL; + adh->claim = NULL; adh->r_id = ntohl (dam->id); adh->identity = dam->identity; @@ -1947,6 +1960,9 @@ handle_reference_delete_message (void *cls, adh = GNUNET_new (struct AttributeDeleteHandle); adh->reference = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &dam[1], data_len); + adh->attest = NULL; + adh->claim = NULL; + adh->r_id = ntohl (dam->id); adh->identity = dam->identity; adh->label diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c index e00b246c2..0f59082dc 100644 --- a/src/reclaim/plugin_gnsrecord_reclaim.c +++ b/src/reclaim/plugin_gnsrecord_reclaim.c @@ -55,7 +55,7 @@ value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR: - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF: + case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE: return GNUNET_STRINGS_data_to_string_alloc (data, data_size); default: @@ -96,7 +96,7 @@ string_to_value (void *cls, uint32_t type, const char *s, void **data, case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER: case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET: case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR: - case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF: + case GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE: return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size); default: @@ -121,6 +121,8 @@ static struct { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, { "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET }, + { "RECLAIM_REFERENCE", GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE }, + { "RECLAIM_REFERENCE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE_REF }, { "RECLAIM_ATTEST_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF }, { NULL, UINT32_MAX } }; -- 2.25.1