aboutsummaryrefslogtreecommitdiff
path: root/src/identity/gnunet-service-identity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/gnunet-service-identity.c')
-rw-r--r--src/identity/gnunet-service-identity.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index fdd7cfdc1..155c49cc5 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V. 3 Copyright (C) 2013 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */ 17 */
20 18
21/** 19/**
@@ -373,11 +371,12 @@ handle_get_default_message (void *cls,
373 struct GNUNET_MQ_Envelope *env; 371 struct GNUNET_MQ_Envelope *env;
374 struct GNUNET_SERVICE_Client *client = cls; 372 struct GNUNET_SERVICE_Client *client = cls;
375 struct Ego *ego; 373 struct Ego *ego;
376 const char *name; 374 char *name;
377 char *identifier; 375 char *identifier;
378 376
379 377
380 name = (const char *) &gdm[1]; 378 name = GNUNET_strdup ((const char *) &gdm[1]);
379 GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "Received GET_DEFAULT for service `%s' from client\n", 381 "Received GET_DEFAULT for service `%s' from client\n",
383 name); 382 name);
@@ -389,6 +388,7 @@ handle_get_default_message (void *cls,
389 { 388 {
390 send_result_code (client, 1, gettext_noop ("no default known")); 389 send_result_code (client, 1, gettext_noop ("no default known"));
391 GNUNET_SERVICE_client_continue (client); 390 GNUNET_SERVICE_client_continue (client);
391 GNUNET_free (name);
392 return; 392 return;
393 } 393 }
394 for (ego = ego_head; NULL != ego; ego = ego->next) 394 for (ego = ego_head; NULL != ego; ego = ego->next)
@@ -401,6 +401,7 @@ handle_get_default_message (void *cls,
401 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); 401 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
402 GNUNET_SERVICE_client_continue (client); 402 GNUNET_SERVICE_client_continue (client);
403 GNUNET_free (identifier); 403 GNUNET_free (identifier);
404 GNUNET_free (name);
404 return; 405 return;
405 } 406 }
406 } 407 }
@@ -408,6 +409,7 @@ handle_get_default_message (void *cls,
408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
409 "Failed to find ego `%s'\n", 410 "Failed to find ego `%s'\n",
410 name); 411 name);
412 GNUNET_free (name);
411 send_result_code (client, 1, 413 send_result_code (client, 1,
412 gettext_noop ("default configured, but ego unknown (internal error)")); 414 gettext_noop ("default configured, but ego unknown (internal error)"));
413 GNUNET_SERVICE_client_continue (client); 415 GNUNET_SERVICE_client_continue (client);
@@ -479,9 +481,11 @@ handle_set_default_message (void *cls,
479{ 481{
480 struct Ego *ego; 482 struct Ego *ego;
481 struct GNUNET_SERVICE_Client *client = cls; 483 struct GNUNET_SERVICE_Client *client = cls;
482 const char *str; 484 char *str;
485
486 str = GNUNET_strdup ((const char *) &sdm[1]);
487 GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str);
483 488
484 str = (const char *) &sdm[1];
485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
486 "Received SET_DEFAULT for service `%s' from client\n", 490 "Received SET_DEFAULT for service `%s' from client\n",
487 str); 491 str);
@@ -502,10 +506,12 @@ handle_set_default_message (void *cls,
502 subsystem_cfg_file); 506 subsystem_cfg_file);
503 send_result_code (client, 0, NULL); 507 send_result_code (client, 0, NULL);
504 GNUNET_SERVICE_client_continue (client); 508 GNUNET_SERVICE_client_continue (client);
509 GNUNET_free (str);
505 return; 510 return;
506 } 511 }
507 } 512 }
508 send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); 513 send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
514 GNUNET_free (str);
509 GNUNET_SERVICE_client_continue (client); 515 GNUNET_SERVICE_client_continue (client);
510} 516}
511 517
@@ -587,12 +593,13 @@ handle_create_message (void *cls,
587{ 593{
588 struct GNUNET_SERVICE_Client *client = cls; 594 struct GNUNET_SERVICE_Client *client = cls;
589 struct Ego *ego; 595 struct Ego *ego;
590 const char *str; 596 char *str;
591 char *fn; 597 char *fn;
592 598
593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 599 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
594 "Received CREATE message from client\n"); 600 "Received CREATE message from client\n");
595 str = (const char *) &crm[1]; 601 str = GNUNET_strdup ((const char *) &crm[1]);
602 GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str);
596 for (ego = ego_head; NULL != ego; ego = ego->next) 603 for (ego = ego_head; NULL != ego; ego = ego->next)
597 { 604 {
598 if (0 == strcmp (ego->identifier, 605 if (0 == strcmp (ego->identifier,
@@ -600,6 +607,7 @@ handle_create_message (void *cls,
600 { 607 {
601 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego")); 608 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego"));
602 GNUNET_SERVICE_client_continue (client); 609 GNUNET_SERVICE_client_continue (client);
610 GNUNET_free (str);
603 return; 611 return;
604 } 612 }
605 } 613 }
@@ -622,6 +630,7 @@ handle_create_message (void *cls,
622 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 630 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
623 "write", fn); 631 "write", fn);
624 GNUNET_free (fn); 632 GNUNET_free (fn);
633 GNUNET_free (str);
625 notify_listeners (ego); 634 notify_listeners (ego);
626 GNUNET_SERVICE_client_continue (client); 635 GNUNET_SERVICE_client_continue (client);
627} 636}
@@ -728,18 +737,22 @@ handle_rename_message (void *cls,
728{ 737{
729 uint16_t old_name_len; 738 uint16_t old_name_len;
730 struct Ego *ego; 739 struct Ego *ego;
731 const char *old_name; 740 char *old_name;
732 const char *new_name; 741 char *new_name;
733 struct RenameContext rename_ctx; 742 struct RenameContext rename_ctx;
734 struct GNUNET_SERVICE_Client *client = cls; 743 struct GNUNET_SERVICE_Client *client = cls;
735 char *fn_old; 744 char *fn_old;
736 char *fn_new; 745 char *fn_new;
746 const char *old_name_tmp;
737 747
738 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
739 "Received RENAME message from client\n"); 749 "Received RENAME message from client\n");
740 old_name_len = ntohs (rm->old_name_len); 750 old_name_len = ntohs (rm->old_name_len);
741 old_name = (const char *) &rm[1]; 751 old_name_tmp = (const char *) &rm[1];
742 new_name = &old_name[old_name_len]; 752 old_name = GNUNET_strdup (old_name_tmp);
753 GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
754 new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
755 GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], new_name);
743 756
744 /* check if new name is already in use */ 757 /* check if new name is already in use */
745 for (ego = ego_head; NULL != ego; ego = ego->next) 758 for (ego = ego_head; NULL != ego; ego = ego->next)
@@ -749,6 +762,8 @@ handle_rename_message (void *cls,
749 { 762 {
750 send_result_code (client, 1, gettext_noop ("target name already exists")); 763 send_result_code (client, 1, gettext_noop ("target name already exists"));
751 GNUNET_SERVICE_client_continue (client); 764 GNUNET_SERVICE_client_continue (client);
765 GNUNET_free (old_name);
766 GNUNET_free (new_name);
752 return; 767 return;
753 } 768 }
754 } 769 }
@@ -778,6 +793,8 @@ handle_rename_message (void *cls,
778 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); 793 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old);
779 GNUNET_free (fn_old); 794 GNUNET_free (fn_old);
780 GNUNET_free (fn_new); 795 GNUNET_free (fn_new);
796 GNUNET_free (old_name);
797 GNUNET_free (new_name);
781 notify_listeners (ego); 798 notify_listeners (ego);
782 send_result_code (client, 0, NULL); 799 send_result_code (client, 0, NULL);
783 GNUNET_SERVICE_client_continue (client); 800 GNUNET_SERVICE_client_continue (client);
@@ -787,6 +804,8 @@ handle_rename_message (void *cls,
787 804
788 /* failed to locate old name */ 805 /* failed to locate old name */
789 send_result_code (client, 1, gettext_noop ("no matching ego found")); 806 send_result_code (client, 1, gettext_noop ("no matching ego found"));
807 GNUNET_free (old_name);
808 GNUNET_free (new_name);
790 GNUNET_SERVICE_client_continue (client); 809 GNUNET_SERVICE_client_continue (client);
791} 810}
792 811
@@ -870,13 +889,15 @@ handle_delete_message (void *cls,
870 const struct DeleteMessage *dm) 889 const struct DeleteMessage *dm)
871{ 890{
872 struct Ego *ego; 891 struct Ego *ego;
873 const char *name; 892 char *name;
874 char *fn; 893 char *fn;
875 struct GNUNET_SERVICE_Client *client = cls; 894 struct GNUNET_SERVICE_Client *client = cls;
876 895
877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
878 "Received DELETE message from client\n"); 897 "Received DELETE message from client\n");
879 name = (const char *) &dm[1]; 898 name = GNUNET_strdup ((const char *) &dm[1]);
899 GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
900
880 for (ego = ego_head; NULL != ego; ego = ego->next) 901 for (ego = ego_head; NULL != ego; ego = ego->next)
881 { 902 {
882 if (0 == strcmp (ego->identifier, 903 if (0 == strcmp (ego->identifier,
@@ -903,6 +924,7 @@ handle_delete_message (void *cls,
903 notify_listeners (ego); 924 notify_listeners (ego);
904 GNUNET_free (ego->pk); 925 GNUNET_free (ego->pk);
905 GNUNET_free (ego); 926 GNUNET_free (ego);
927 GNUNET_free (name);
906 send_result_code (client, 0, NULL); 928 send_result_code (client, 0, NULL);
907 GNUNET_SERVICE_client_continue (client); 929 GNUNET_SERVICE_client_continue (client);
908 return; 930 return;
@@ -910,6 +932,7 @@ handle_delete_message (void *cls,
910 } 932 }
911 933
912 send_result_code (client, 1, gettext_noop ("no matching ego found")); 934 send_result_code (client, 1, gettext_noop ("no matching ego found"));
935 GNUNET_free (name);
913 GNUNET_SERVICE_client_continue (client); 936 GNUNET_SERVICE_client_continue (client);
914} 937}
915 938