summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-11 11:06:24 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-10-11 11:06:24 +0200
commit3b80c8d9daddaeaf033d0b0d3f6cda842a939c8d (patch)
treefff664c29355e61990a3e9e8be043770ea89c1d7
parentf412ffb84409079f236e7046344ef99fdcd02a9a (diff)
fix changes in identities
-rw-r--r--src/identity/plugin_rest_identity.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 247d09282..e052ac6b3 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -1234,11 +1234,46 @@ init_egos (void *cls,
GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
ego_entry->ego = ego;
- GNUNET_asprintf (&ego_entry->identifier, "%s", identifier);
+ ego_entry->identifier = GNUNET_strdup (identifier);
GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head,
handle->ego_tail,
ego_entry);
+ return;
+ }
+ // Check if ego exists
+ for (ego_entry = handle->ego_head; NULL != ego_entry;)
+ {
+ struct EgoEntry *tmp = ego_entry;
+ ego_entry = ego_entry->next;
+ if (ego != tmp->ego)
+ continue;
+ // Deleted
+ if (NULL == identifier)
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->ego_head,
+ handle->ego_tail,
+ tmp);
+ GNUNET_free (tmp->keystring);
+ GNUNET_free (tmp->identifier);
+ GNUNET_free (tmp);
+ }
+ else {
+ // Renamed
+ GNUNET_free (tmp->identifier);
+ tmp->identifier = GNUNET_strdup (identifier);
+ }
+ return;
}
+ // New ego
+ ego_entry = GNUNET_new (struct EgoEntry);
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
+ ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
+ ego_entry->ego = ego;
+ GNUNET_asprintf (&ego_entry->identifier, "%s", identifier);
+ GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head,
+ handle->ego_tail,
+ ego_entry);
+
}
/**