diff options
Diffstat (limited to 'src/identity/gnunet-service-identity.c')
-rw-r--r-- | src/identity/gnunet-service-identity.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index 52d072967..c61286bd5 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -47,12 +47,12 @@ struct Ego | |||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * We keep egos in a DLL. | 49 | * We keep egos in a DLL. |
50 | */ | 50 | */ |
51 | struct Ego *next; | 51 | struct Ego *next; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * We keep egos in a DLL. | 54 | * We keep egos in a DLL. |
55 | */ | 55 | */ |
56 | struct Ego *prev; | 56 | struct Ego *prev; |
57 | 57 | ||
58 | /** | 58 | /** |
@@ -195,7 +195,7 @@ send_result_code (struct GNUNET_SERVER_Client *client, | |||
195 | "Sending result %d (%s) to client\n", | 195 | "Sending result %d (%s) to client\n", |
196 | (int) result_code, | 196 | (int) result_code, |
197 | emsg); | 197 | emsg); |
198 | GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_NO); | 198 | GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_NO); |
199 | GNUNET_free (rcm); | 199 | GNUNET_free (rcm); |
200 | } | 200 | } |
201 | 201 | ||
@@ -211,7 +211,7 @@ create_update_message (struct Ego *ego) | |||
211 | { | 211 | { |
212 | struct GNUNET_IDENTITY_UpdateMessage *um; | 212 | struct GNUNET_IDENTITY_UpdateMessage *um; |
213 | size_t name_len; | 213 | size_t name_len; |
214 | 214 | ||
215 | name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1); | 215 | name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1); |
216 | um = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + name_len); | 216 | um = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + name_len); |
217 | um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); | 217 | um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); |
@@ -252,7 +252,7 @@ create_set_default_message (struct Ego *ego, | |||
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Handler for START message from client, sends information | 254 | * Handler for START message from client, sends information |
255 | * about all identities to the client immediately and | 255 | * about all identities to the client immediately and |
256 | * adds the client to the notification context for future | 256 | * adds the client to the notification context for future |
257 | * updates. | 257 | * updates. |
258 | * | 258 | * |
@@ -268,7 +268,7 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
268 | struct GNUNET_IDENTITY_UpdateMessage ume; | 268 | struct GNUNET_IDENTITY_UpdateMessage ume; |
269 | struct Ego *ego; | 269 | struct Ego *ego; |
270 | 270 | ||
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
272 | "Received START message from client\n"); | 272 | "Received START message from client\n"); |
273 | GNUNET_SERVER_notification_context_add (nc, client); | 273 | GNUNET_SERVER_notification_context_add (nc, client); |
274 | for (ego = ego_head; NULL != ego; ego = ego->next) | 274 | for (ego = ego_head; NULL != ego; ego = ego->next) |
@@ -282,7 +282,7 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
282 | ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); | 282 | ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); |
283 | ume.end_of_list = htons (GNUNET_YES); | 283 | ume.end_of_list = htons (GNUNET_YES); |
284 | ume.name_len = htons (0); | 284 | ume.name_len = htons (0); |
285 | GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO); | 285 | GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO); |
286 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 286 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
287 | } | 287 | } |
288 | 288 | ||
@@ -325,7 +325,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
325 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 325 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
329 | "Received GET_DEFAULT for service `%s' from client\n", | 329 | "Received GET_DEFAULT for service `%s' from client\n", |
330 | name); | 330 | name); |
331 | if (GNUNET_OK != | 331 | if (GNUNET_OK != |
@@ -335,7 +335,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
335 | &identifier)) | 335 | &identifier)) |
336 | { | 336 | { |
337 | send_result_code (client, 1, gettext_noop ("no default known")); | 337 | send_result_code (client, 1, gettext_noop ("no default known")); |
338 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 338 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | for (ego = ego_head; NULL != ego; ego = ego->next) | 341 | for (ego = ego_head; NULL != ego; ego = ego->next) |
@@ -356,7 +356,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
357 | "Failed to find ego `%s'\n", | 357 | "Failed to find ego `%s'\n", |
358 | name); | 358 | name); |
359 | send_result_code (client, 1, | 359 | send_result_code (client, 1, |
360 | gettext_noop ("default configured, but ego unknown (internal error)")); | 360 | gettext_noop ("default configured, but ego unknown (internal error)")); |
361 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 361 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
362 | } | 362 | } |
@@ -364,7 +364,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
364 | 364 | ||
365 | /** | 365 | /** |
366 | * Compare the given two private keys for equality. | 366 | * Compare the given two private keys for equality. |
367 | * | 367 | * |
368 | * @param pk1 one private key | 368 | * @param pk1 one private key |
369 | * @param pk2 another private key | 369 | * @param pk2 another private key |
370 | * @return 0 if the keys are equal | 370 | * @return 0 if the keys are equal |
@@ -405,7 +405,7 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
405 | sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message; | 405 | sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message; |
406 | name_len = ntohs (sdm->name_len); | 406 | name_len = ntohs (sdm->name_len); |
407 | GNUNET_break (0 == ntohs (sdm->reserved)); | 407 | GNUNET_break (0 == ntohs (sdm->reserved)); |
408 | if (name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size) | 408 | if (name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size) |
409 | { | 409 | { |
410 | GNUNET_break (0); | 410 | GNUNET_break (0); |
411 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 411 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -418,7 +418,7 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
418 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 418 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
422 | "Received SET_DEFAULT for service `%s' from client\n", | 422 | "Received SET_DEFAULT for service `%s' from client\n", |
423 | str); | 423 | str); |
424 | for (ego = ego_head; NULL != ego; ego = ego->next) | 424 | for (ego = ego_head; NULL != ego; ego = ego->next) |
@@ -430,7 +430,7 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
430 | str, | 430 | str, |
431 | "DEFAULT_IDENTIFIER", | 431 | "DEFAULT_IDENTIFIER", |
432 | ego->identifier); | 432 | ego->identifier); |
433 | if (GNUNET_OK != | 433 | if (GNUNET_OK != |
434 | GNUNET_CONFIGURATION_write (subsystem_cfg, | 434 | GNUNET_CONFIGURATION_write (subsystem_cfg, |
435 | subsystem_cfg_file)) | 435 | subsystem_cfg_file)) |
436 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 436 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -440,7 +440,7 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
440 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 440 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
441 | return; | 441 | return; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); | 444 | send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); |
445 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 445 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
446 | } | 446 | } |
@@ -481,7 +481,7 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
481 | const char *str; | 481 | const char *str; |
482 | char *fn; | 482 | char *fn; |
483 | 483 | ||
484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
485 | "Received CREATE message from client\n"); | 485 | "Received CREATE message from client\n"); |
486 | size = ntohs (message->size); | 486 | size = ntohs (message->size); |
487 | if (size <= sizeof (struct GNUNET_IDENTITY_CreateRequestMessage)) | 487 | if (size <= sizeof (struct GNUNET_IDENTITY_CreateRequestMessage)) |
@@ -493,7 +493,7 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
493 | crm = (const struct GNUNET_IDENTITY_CreateRequestMessage *) message; | 493 | crm = (const struct GNUNET_IDENTITY_CreateRequestMessage *) message; |
494 | name_len = ntohs (crm->name_len); | 494 | name_len = ntohs (crm->name_len); |
495 | GNUNET_break (0 == ntohs (crm->reserved)); | 495 | GNUNET_break (0 == ntohs (crm->reserved)); |
496 | if (name_len + sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) != size) | 496 | if (name_len + sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) != size) |
497 | { | 497 | { |
498 | GNUNET_break (0); | 498 | GNUNET_break (0); |
499 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 499 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -528,14 +528,14 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
528 | (void) GNUNET_DISK_directory_create_for_file (fn); | 528 | (void) GNUNET_DISK_directory_create_for_file (fn); |
529 | if (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) != | 529 | if (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) != |
530 | GNUNET_DISK_fn_write (fn, | 530 | GNUNET_DISK_fn_write (fn, |
531 | &crm->private_key, | 531 | &crm->private_key, |
532 | sizeof (struct GNUNET_CRYPTO_EccPrivateKey), | 532 | sizeof (struct GNUNET_CRYPTO_EccPrivateKey), |
533 | GNUNET_DISK_PERM_USER_READ | | 533 | GNUNET_DISK_PERM_USER_READ | |
534 | GNUNET_DISK_PERM_USER_WRITE)) | 534 | GNUNET_DISK_PERM_USER_WRITE)) |
535 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 535 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
536 | "write", fn); | 536 | "write", fn); |
537 | GNUNET_free (fn); | 537 | GNUNET_free (fn); |
538 | notify_listeners (ego); | 538 | notify_listeners (ego); |
539 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 539 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
540 | } | 540 | } |
541 | 541 | ||
@@ -543,7 +543,7 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
543 | /** | 543 | /** |
544 | * Closure for 'handle_ego_rename'. | 544 | * Closure for 'handle_ego_rename'. |
545 | */ | 545 | */ |
546 | struct RenameContext | 546 | struct RenameContext |
547 | { | 547 | { |
548 | /** | 548 | /** |
549 | * Old name. | 549 | * Old name. |
@@ -579,14 +579,14 @@ handle_ego_rename (void *cls, | |||
579 | return; | 579 | return; |
580 | if (0 != strcmp (id, rc->old_name)) | 580 | if (0 != strcmp (id, rc->old_name)) |
581 | { | 581 | { |
582 | GNUNET_free (id); | 582 | GNUNET_free (id); |
583 | return; | 583 | return; |
584 | } | 584 | } |
585 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, | 585 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, |
586 | section, | 586 | section, |
587 | "DEFAULT_IDENTIFIER", | 587 | "DEFAULT_IDENTIFIER", |
588 | rc->new_name); | 588 | rc->new_name); |
589 | GNUNET_free (id); | 589 | GNUNET_free (id); |
590 | } | 590 | } |
591 | 591 | ||
592 | 592 | ||
@@ -613,7 +613,7 @@ handle_rename_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
613 | char *fn_old; | 613 | char *fn_old; |
614 | char *fn_new; | 614 | char *fn_new; |
615 | 615 | ||
616 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 616 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
617 | "Received RENAME message from client\n"); | 617 | "Received RENAME message from client\n"); |
618 | size = ntohs (message->size); | 618 | size = ntohs (message->size); |
619 | if (size <= sizeof (struct GNUNET_IDENTITY_RenameMessage)) | 619 | if (size <= sizeof (struct GNUNET_IDENTITY_RenameMessage)) |
@@ -643,7 +643,7 @@ handle_rename_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
643 | new_name)) | 643 | new_name)) |
644 | { | 644 | { |
645 | send_result_code (client, 1, gettext_noop ("target name already exists")); | 645 | send_result_code (client, 1, gettext_noop ("target name already exists")); |
646 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 646 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
647 | return; | 647 | return; |
648 | } | 648 | } |
649 | } | 649 | } |
@@ -661,14 +661,14 @@ handle_rename_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
661 | GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg, | 661 | GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg, |
662 | &handle_ego_rename, | 662 | &handle_ego_rename, |
663 | &rename_ctx); | 663 | &rename_ctx); |
664 | if (GNUNET_OK != | 664 | if (GNUNET_OK != |
665 | GNUNET_CONFIGURATION_write (subsystem_cfg, | 665 | GNUNET_CONFIGURATION_write (subsystem_cfg, |
666 | subsystem_cfg_file)) | 666 | subsystem_cfg_file)) |
667 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 667 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
668 | _("Failed to write subsystem default identifier map to `%s'.\n"), | 668 | _("Failed to write subsystem default identifier map to `%s'.\n"), |
669 | subsystem_cfg_file); | 669 | subsystem_cfg_file); |
670 | ego->identifier = GNUNET_strdup (new_name); | 670 | ego->identifier = GNUNET_strdup (new_name); |
671 | fn_new = get_ego_filename (ego); | 671 | fn_new = get_ego_filename (ego); |
672 | if (0 != RENAME (fn_old, fn_new)) | 672 | if (0 != RENAME (fn_old, fn_new)) |
673 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); | 673 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); |
674 | GNUNET_free (fn_old); | 674 | GNUNET_free (fn_old); |
@@ -708,14 +708,14 @@ handle_ego_delete (void *cls, | |||
708 | return; | 708 | return; |
709 | if (0 != strcmp (id, identifier)) | 709 | if (0 != strcmp (id, identifier)) |
710 | { | 710 | { |
711 | GNUNET_free (id); | 711 | GNUNET_free (id); |
712 | return; | 712 | return; |
713 | } | 713 | } |
714 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, | 714 | GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, |
715 | section, | 715 | section, |
716 | "DEFAULT_IDENTIFIER", | 716 | "DEFAULT_IDENTIFIER", |
717 | NULL); | 717 | NULL); |
718 | GNUNET_free (id); | 718 | GNUNET_free (id); |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
@@ -738,7 +738,7 @@ handle_delete_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
738 | const char *name; | 738 | const char *name; |
739 | char *fn; | 739 | char *fn; |
740 | 740 | ||
741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
742 | "Received DELETE message from client\n"); | 742 | "Received DELETE message from client\n"); |
743 | size = ntohs (message->size); | 743 | size = ntohs (message->size); |
744 | if (size <= sizeof (struct GNUNET_IDENTITY_DeleteMessage)) | 744 | if (size <= sizeof (struct GNUNET_IDENTITY_DeleteMessage)) |
@@ -769,7 +769,7 @@ handle_delete_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
769 | GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg, | 769 | GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg, |
770 | &handle_ego_delete, | 770 | &handle_ego_delete, |
771 | ego->identifier); | 771 | ego->identifier); |
772 | if (GNUNET_OK != | 772 | if (GNUNET_OK != |
773 | GNUNET_CONFIGURATION_write (subsystem_cfg, | 773 | GNUNET_CONFIGURATION_write (subsystem_cfg, |
774 | subsystem_cfg_file)) | 774 | subsystem_cfg_file)) |
775 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 775 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -830,7 +830,7 @@ process_ego_file (void *cls, | |||
830 | } | 830 | } |
831 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 831 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
832 | "Loaded ego `%s'\n", | 832 | "Loaded ego `%s'\n", |
833 | fn + 1); | 833 | fn + 1); |
834 | ego->identifier = GNUNET_strdup (fn + 1); | 834 | ego->identifier = GNUNET_strdup (fn + 1); |
835 | GNUNET_CONTAINER_DLL_insert (ego_head, | 835 | GNUNET_CONTAINER_DLL_insert (ego_head, |
836 | ego_tail, | 836 | ego_tail, |
@@ -847,7 +847,7 @@ process_ego_file (void *cls, | |||
847 | * @param c configuration to use | 847 | * @param c configuration to use |
848 | */ | 848 | */ |
849 | static void | 849 | static void |
850 | run (void *cls, | 850 | run (void *cls, |
851 | struct GNUNET_SERVER_Handle *server, | 851 | struct GNUNET_SERVER_Handle *server, |
852 | const struct GNUNET_CONFIGURATION_Handle *c) | 852 | const struct GNUNET_CONFIGURATION_Handle *c) |
853 | { | 853 | { |
@@ -892,7 +892,7 @@ run (void *cls, | |||
892 | subsystem_cfg = GNUNET_CONFIGURATION_create (); | 892 | subsystem_cfg = GNUNET_CONFIGURATION_create (); |
893 | if ( (GNUNET_YES == | 893 | if ( (GNUNET_YES == |
894 | GNUNET_DISK_file_test (subsystem_cfg_file)) && | 894 | GNUNET_DISK_file_test (subsystem_cfg_file)) && |
895 | (GNUNET_OK != | 895 | (GNUNET_OK != |
896 | GNUNET_CONFIGURATION_parse (subsystem_cfg, | 896 | GNUNET_CONFIGURATION_parse (subsystem_cfg, |
897 | subsystem_cfg_file)) ) | 897 | subsystem_cfg_file)) ) |
898 | { | 898 | { |
@@ -931,7 +931,7 @@ int | |||
931 | main (int argc, char *const *argv) | 931 | main (int argc, char *const *argv) |
932 | { | 932 | { |
933 | return (GNUNET_OK == | 933 | return (GNUNET_OK == |
934 | GNUNET_SERVICE_run (argc, argv, "identity", | 934 | GNUNET_SERVICE_run (argc, argv, "identity", |
935 | GNUNET_SERVICE_OPTION_NONE, | 935 | GNUNET_SERVICE_OPTION_NONE, |
936 | &run, NULL)) ? 0 : 1; | 936 | &run, NULL)) ? 0 : 1; |
937 | } | 937 | } |