2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file identity/gnunet-service-identity.c
23 * @brief identity management service
24 * @author Christian Grothoff
26 * The purpose of this service is to manage private keys that
27 * represent the various egos/pseudonyms/identities of a GNUnet user.
31 * - auto-initialze default egos; maybe trigger default
32 * initializations (such as gnunet-gns-import.sh?)
35 #include "gnunet_util_lib.h"
36 #include "gnunet_constants.h"
37 #include "gnunet_protocols.h"
38 #include "gnunet_statistics_service.h"
39 #include "gnunet_identity_service.h"
44 * Information we keep about each ego.
50 * We keep egos in a DLL.
55 * We keep egos in a DLL.
60 * Private key of the ego.
62 struct GNUNET_CRYPTO_EccPrivateKey *pk;
65 * String identifier for the ego.
73 * Handle to our current configuration.
75 static const struct GNUNET_CONFIGURATION_Handle *cfg;
78 * Handle to subsystem configuration which for each subsystem contains
79 * the name of the default ego.
81 static struct GNUNET_CONFIGURATION_Handle *subsystem_cfg;
84 * Handle to the statistics service.
86 static struct GNUNET_STATISTICS_Handle *stats;
89 * Notification context, simplifies client broadcasts.
91 static struct GNUNET_SERVER_NotificationContext *nc;
94 * Directory where we store the identities.
96 static char *ego_directory;
99 * Configuration file name where subsystem information is kept.
101 static char *subsystem_cfg_file;
104 * Head of DLL of all egos.
106 static struct Ego *ego_head;
109 * Tail of DLL of all egos.
111 static struct Ego *ego_tail;
115 * Get the name of the file we use to store a given ego.
117 * @param ego ego for which we need the filename
118 * @return full filename for the given ego
121 get_ego_filename (struct Ego *ego)
125 GNUNET_asprintf (&filename,
135 * Task run during shutdown.
141 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147 GNUNET_SERVER_notification_context_destroy (nc);
152 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
155 GNUNET_CONFIGURATION_destroy (subsystem_cfg);
156 subsystem_cfg = NULL;
157 GNUNET_free (subsystem_cfg_file);
158 subsystem_cfg_file = NULL;
159 GNUNET_free (ego_directory);
160 ego_directory = NULL;
161 while (NULL != (e = ego_head))
163 GNUNET_CONTAINER_DLL_remove (ego_head, ego_tail, e);
164 GNUNET_CRYPTO_ecc_key_free (e->pk);
171 * Send a result code back to the client.
173 * @param client client that should receive the result code
174 * @param result_code code to transmit
175 * @param emsg error message to include (or NULL for none)
178 send_result_code (struct GNUNET_SERVER_Client *client,
179 uint32_t result_code,
182 struct GNUNET_IDENTITY_ResultCodeMessage *rcm;
188 elen = strlen (emsg) + 1;
189 rcm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) + elen);
190 rcm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
191 rcm->header.size = htons (sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) + elen);
192 rcm->result_code = htonl (result_code);
193 memcpy (&rcm[1], emsg, elen);
194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
195 "Sending result %d (%s) to client\n",
198 GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_NO);
204 * Create an update message with information about the current state of an ego.
206 * @param ego ego to create message for
207 * @return corresponding update message
209 static struct GNUNET_IDENTITY_UpdateMessage *
210 create_update_message (struct Ego *ego)
212 struct GNUNET_IDENTITY_UpdateMessage *um;
216 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
218 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
219 enc = GNUNET_CRYPTO_ecc_encode_key (ego->pk);
220 pk_len = ntohs (enc->size);
221 um = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + pk_len + name_len);
222 um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
223 um->header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + pk_len + name_len);
224 um->name_len = htons (name_len);
225 um->pk_len = htons (pk_len);
226 str = (char *) &um[1];
227 memcpy (str, enc, pk_len);
228 memcpy (&str[pk_len], ego->identifier, name_len);
235 * Create a set default message with information about the current state of an ego.
237 * @param ego ego to create message for
238 * @param servicename name of the service to provide in the message
239 * @return corresponding set default message
241 static struct GNUNET_IDENTITY_SetDefaultMessage *
242 create_set_default_message (struct Ego *ego,
243 const char *servicename)
245 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
249 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
251 name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1);
252 enc = GNUNET_CRYPTO_ecc_encode_key (ego->pk);
253 pk_len = ntohs (enc->size);
254 sdm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + pk_len + name_len);
255 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
256 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + pk_len + name_len);
257 sdm->name_len = htons (name_len);
258 sdm->pk_len = htons (pk_len);
259 str = (char *) &sdm[1];
260 memcpy (str, enc, pk_len);
261 memcpy (&str[pk_len], servicename, name_len);
268 * Handler for START message from client, sends information
269 * about all identities to the client immediately and
270 * adds the client to the notification context for future
274 * @param client who sent the message
275 * @param message the message received
278 handle_start_message (void *cls, struct GNUNET_SERVER_Client *client,
279 const struct GNUNET_MessageHeader *message)
281 struct GNUNET_IDENTITY_UpdateMessage *um;
282 struct GNUNET_IDENTITY_UpdateMessage ume;
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
286 "Received START message from client\n");
287 GNUNET_SERVER_notification_context_add (nc, client);
288 for (ego = ego_head; NULL != ego; ego = ego->next)
290 um = create_update_message (ego);
291 GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO);
294 ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
295 ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage));
296 ume.pk_len = htons (0);
297 ume.name_len = htons (0);
298 GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO);
299 GNUNET_SERVER_receive_done (client, GNUNET_OK);
304 * Handler for GET_DEFAULT message from client, returns
305 * default identity for some service.
308 * @param client who sent the message
309 * @param message the message received
312 handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client,
313 const struct GNUNET_MessageHeader *message)
315 const struct GNUNET_IDENTITY_GetDefaultMessage *gdm;
316 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
324 "Received GET_DEFAULT message from client\n");
325 size = ntohs (message->size);
326 if (size <= sizeof (struct GNUNET_IDENTITY_GetDefaultMessage))
329 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
332 gdm = (const struct GNUNET_IDENTITY_GetDefaultMessage *) message;
333 name = (const char *) &gdm[1];
334 name_len = ntohs (gdm->name_len);
335 if ( (name_len + sizeof (struct GNUNET_IDENTITY_GetDefaultMessage) != size) ||
336 (0 != ntohs (gdm->reserved)) ||
337 ('\0' != name[name_len - 1]) )
340 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
344 GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
346 "DEFAULT_IDENTIFIER",
349 send_result_code (client, 1, gettext_noop ("no default known"));
350 GNUNET_SERVER_receive_done (client, GNUNET_OK);
353 for (ego = ego_head; NULL != ego; ego = ego->next)
355 if (0 == strcmp (ego->identifier,
358 sdm = create_set_default_message (ego,
360 GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_NO);
362 GNUNET_SERVER_receive_done (client, GNUNET_OK);
366 send_result_code (client, 1,
367 gettext_noop ("default configured, but ego unknown (internal error)"));
368 GNUNET_SERVER_receive_done (client, GNUNET_OK);
373 * Compare the given two private keys for equality.
375 * @param pk1 one private key
376 * @param pk2 another private key
377 * @return 0 if the keys are equal
380 key_cmp (const struct GNUNET_CRYPTO_EccPrivateKey *pk1,
381 const struct GNUNET_CRYPTO_EccPrivateKey *pk2)
383 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p1;
384 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p2;
386 GNUNET_CRYPTO_ecc_key_get_public (pk1, &p1);
387 GNUNET_CRYPTO_ecc_key_get_public (pk2, &p2);
388 return memcmp (&p1, &p2, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded));
393 * Handler for SET_DEFAULT message from client, updates
394 * default identity for some service.
397 * @param client who sent the message
398 * @param message the message received
401 handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client,
402 const struct GNUNET_MessageHeader *message)
404 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
410 struct GNUNET_CRYPTO_EccPrivateKey *pk;
412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
413 "Received SET_DEFAULT message from client\n");
414 size = ntohs (message->size);
415 if (size <= sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
418 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
421 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message;
422 name_len = ntohs (sdm->name_len);
423 pk_len = ntohs (sdm->pk_len);
424 str = (const char *) &sdm[1];
425 if ( (name_len + pk_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size) ||
426 (NULL == (pk = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES))) )
429 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
433 if ('\0' != str[name_len - 1])
436 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
439 for (ego = ego_head; NULL != ego; ego = ego->next)
441 if (0 == key_cmp (ego->pk,
444 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
446 "DEFAULT_IDENTIFIER",
449 GNUNET_CONFIGURATION_write (subsystem_cfg,
451 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
452 _("Failed to write subsystem default identifier map to `%s'.\n"),
454 send_result_code (client, 0, NULL);
455 GNUNET_SERVER_receive_done (client, GNUNET_OK);
456 GNUNET_CRYPTO_ecc_key_free (pk);
460 send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
461 GNUNET_SERVER_receive_done (client, GNUNET_OK);
462 GNUNET_CRYPTO_ecc_key_free (pk);
467 * Send an updated message for the given ego to all listeners.
469 * @param ego ego to send the update for
472 notify_listeners (struct Ego *ego)
474 struct GNUNET_IDENTITY_UpdateMessage *um;
476 um = create_update_message (ego);
477 GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_NO);
483 * Handler for CREATE message from client, creates
487 * @param client who sent the message
488 * @param message the message received
491 handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
492 const struct GNUNET_MessageHeader *message)
494 const struct GNUNET_IDENTITY_CreateRequestMessage *crm;
501 struct GNUNET_CRYPTO_EccPrivateKey *pk;
504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
505 "Received CREATE message from client\n");
506 size = ntohs (message->size);
507 if (size <= sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
510 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
513 crm = (const struct GNUNET_IDENTITY_CreateRequestMessage *) message;
514 name_len = ntohs (crm->name_len);
515 pk_len = ntohs (crm->pk_len);
516 pks = (const char *) &crm[1];
517 if ( (name_len + pk_len + sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) != size) ||
518 (NULL == (pk = GNUNET_CRYPTO_ecc_decode_key (pks, pk_len, GNUNET_YES))) )
521 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
525 if ('\0' != str[name_len - 1])
528 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
531 for (ego = ego_head; NULL != ego; ego = ego->next)
533 if (0 == strcmp (ego->identifier,
536 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego"));
537 GNUNET_SERVER_receive_done (client, GNUNET_OK);
538 GNUNET_CRYPTO_ecc_key_free (pk);
542 ego = GNUNET_new (struct Ego);
544 ego->identifier = GNUNET_strdup (str);
545 GNUNET_CONTAINER_DLL_insert (ego_head,
548 send_result_code (client, 0, NULL);
549 fn = get_ego_filename (ego);
550 (void) GNUNET_DISK_directory_create_for_file (fn);
552 GNUNET_DISK_fn_write (fn, pks, pk_len,
553 GNUNET_DISK_PERM_USER_READ |
554 GNUNET_DISK_PERM_USER_WRITE))
555 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
558 notify_listeners (ego);
559 GNUNET_SERVER_receive_done (client, GNUNET_OK);
564 * Closure for 'handle_ego_rename'.
571 const char *old_name;
576 const char *new_name;
581 * An ego was renamed; rename it in all subsystems where it is
582 * currently set as the default.
584 * @param cls the 'struct RenameContext'
585 * @param section a section in the configuration to process
588 handle_ego_rename (void *cls,
591 struct RenameContext *rc = cls;
595 GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
597 "DEFAULT_IDENTIFIER",
600 if (0 != strcmp (id, rc->old_name))
605 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
607 "DEFAULT_IDENTIFIER",
614 * Handler for RENAME message from client, creates
618 * @param client who sent the message
619 * @param message the message received
622 handle_rename_message (void *cls, struct GNUNET_SERVER_Client *client,
623 const struct GNUNET_MessageHeader *message)
625 const struct GNUNET_IDENTITY_RenameMessage *rm;
627 uint16_t old_name_len;
628 uint16_t new_name_len;
630 const char *old_name;
631 const char *new_name;
632 struct RenameContext rename_ctx;
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "Received RENAME message from client\n");
638 size = ntohs (message->size);
639 if (size <= sizeof (struct GNUNET_IDENTITY_RenameMessage))
642 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
645 rm = (const struct GNUNET_IDENTITY_RenameMessage *) message;
646 old_name_len = ntohs (rm->old_name_len);
647 new_name_len = ntohs (rm->new_name_len);
648 old_name = (const char *) &rm[1];
649 new_name = &old_name[old_name_len];
650 if ( (old_name_len + new_name_len + sizeof (struct GNUNET_IDENTITY_RenameMessage) != size) ||
651 ('\0' != old_name[old_name_len - 1]) ||
652 ('\0' != new_name[new_name_len - 1]) )
655 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
659 /* check if new name is already in use */
660 for (ego = ego_head; NULL != ego; ego = ego->next)
662 if (0 == strcmp (ego->identifier,
665 send_result_code (client, 1, gettext_noop ("target name already exists"));
666 GNUNET_SERVER_receive_done (client, GNUNET_OK);
671 /* locate old name and, if found, perform rename */
672 for (ego = ego_head; NULL != ego; ego = ego->next)
674 if (0 == strcmp (ego->identifier,
677 fn_old = get_ego_filename (ego);
678 GNUNET_free (ego->identifier);
679 rename_ctx.old_name = old_name;
680 rename_ctx.new_name = new_name;
681 GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg,
685 GNUNET_CONFIGURATION_write (subsystem_cfg,
687 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
688 _("Failed to write subsystem default identifier map to `%s'.\n"),
690 ego->identifier = GNUNET_strdup (new_name);
691 fn_new = get_ego_filename (ego);
692 if (0 != RENAME (fn_old, fn_new))
693 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old);
694 GNUNET_free (fn_old);
695 GNUNET_free (fn_new);
696 notify_listeners (ego);
697 send_result_code (client, 0, NULL);
698 GNUNET_SERVER_receive_done (client, GNUNET_OK);
703 /* failed to locate old name */
704 send_result_code (client, 1, gettext_noop ("no matching ego found"));
705 GNUNET_SERVER_receive_done (client, GNUNET_OK);
710 * An ego was removed, remove it from all subsystems where it is
711 * currently set as the default.
713 * @param cls name of the removed ego (const char *)
714 * @param section a section in the configuration to process
717 handle_ego_delete (void *cls,
720 const char *identifier = cls;
724 GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
726 "DEFAULT_IDENTIFIER",
729 if (0 != strcmp (id, identifier))
734 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
736 "DEFAULT_IDENTIFIER",
743 * Handler for DELETE message from client, creates
747 * @param client who sent the message
748 * @param message the message received
751 handle_delete_message (void *cls, struct GNUNET_SERVER_Client *client,
752 const struct GNUNET_MessageHeader *message)
754 const struct GNUNET_IDENTITY_DeleteMessage *dm;
761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
762 "Received DELETE message from client\n");
763 size = ntohs (message->size);
764 if (size <= sizeof (struct GNUNET_IDENTITY_DeleteMessage))
767 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
770 dm = (const struct GNUNET_IDENTITY_DeleteMessage *) message;
771 name = (const char *) &dm[1];
772 name_len = ntohs (dm->name_len);
773 if ( (name_len + sizeof (struct GNUNET_IDENTITY_DeleteMessage) != size) ||
774 (0 != ntohs (dm->reserved)) ||
775 ('\0' != name[name_len - 1]) )
778 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
781 for (ego = ego_head; NULL != ego; ego = ego->next)
783 if (0 == strcmp (ego->identifier,
786 GNUNET_CONTAINER_DLL_remove (ego_head,
789 GNUNET_CONFIGURATION_iterate_sections (subsystem_cfg,
793 GNUNET_CONFIGURATION_write (subsystem_cfg,
795 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
796 _("Failed to write subsystem default identifier map to `%s'.\n"),
798 fn = get_ego_filename (ego);
799 if (0 != UNLINK (fn))
800 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
802 GNUNET_free (ego->identifier);
803 ego->identifier = NULL;
804 notify_listeners (ego);
805 GNUNET_CRYPTO_ecc_key_free (ego->pk);
807 send_result_code (client, 0, NULL);
808 GNUNET_SERVER_receive_done (client, GNUNET_OK);
813 send_result_code (client, 1, gettext_noop ("no matching ego found"));
814 GNUNET_SERVER_receive_done (client, GNUNET_OK);
819 * Process the given file from the "EGODIR". Parses the file
820 * and creates the respective 'struct Ego' in memory.
823 * @param filename name of the file to parse
824 * @return GNUNET_OK to continue to iterate,
825 * GNUNET_NO to stop iteration with no error,
826 * GNUNET_SYSERR to abort iteration with error!
829 process_ego_file (void *cls,
830 const char *filename)
835 fn = strrchr (filename, (int) DIR_SEPARATOR);
841 ego = GNUNET_new (struct Ego);
842 ego->pk = GNUNET_CRYPTO_ecc_key_create_from_file (filename);
846 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
847 _("Failed to parse ego information in `%s'\n"),
852 ego->identifier = GNUNET_strdup (fn);
853 GNUNET_CONTAINER_DLL_insert (ego_head,
861 * Handle network size estimate clients.
864 * @param server the initialized server
865 * @param c configuration to use
869 struct GNUNET_SERVER_Handle *server,
870 const struct GNUNET_CONFIGURATION_Handle *c)
872 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
873 {&handle_start_message, NULL,
874 GNUNET_MESSAGE_TYPE_IDENTITY_START, sizeof (struct GNUNET_MessageHeader)},
875 {&handle_get_default_message, NULL,
876 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, 0},
877 {&handle_set_default_message, NULL,
878 GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, 0},
879 {&handle_create_message, NULL,
880 GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, 0},
881 {&handle_rename_message, NULL,
882 GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, 0},
883 {&handle_delete_message, NULL,
884 GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, 0},
890 GNUNET_CONFIGURATION_get_value_filename (cfg, "identity",
894 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "EGODIR");
895 GNUNET_SCHEDULER_shutdown ();
899 GNUNET_CONFIGURATION_get_value_filename (cfg, "identity",
901 &subsystem_cfg_file))
903 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "SUBSYSTEM_CFG");
904 GNUNET_SCHEDULER_shutdown ();
907 subsystem_cfg = GNUNET_CONFIGURATION_create ();
909 GNUNET_DISK_file_test (subsystem_cfg_file)) &&
911 GNUNET_CONFIGURATION_parse (subsystem_cfg,
912 subsystem_cfg_file)) )
914 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
915 _("Failed to parse subsystem identity configuration file `%s'\n"),
917 GNUNET_SCHEDULER_shutdown ();
920 stats = GNUNET_STATISTICS_create ("identity", cfg);
921 GNUNET_SERVER_add_handlers (server, handlers);
922 nc = GNUNET_SERVER_notification_context_create (server, 1);
924 GNUNET_DISK_directory_create (ego_directory))
926 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
927 _("Failed to create directory `%s' for storing egos\n"),
930 GNUNET_DISK_directory_scan (ego_directory,
933 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
939 * The main function for the network size estimation service.
941 * @param argc number of arguments from the command line
942 * @param argv command line arguments
943 * @return 0 ok, 1 on error
946 main (int argc, char *const *argv)
949 GNUNET_SERVICE_run (argc, argv, "identity",
950 GNUNET_SERVICE_OPTION_NONE,
951 &run, NULL)) ? 0 : 1;
955 /* end of gnunet-service-identity.c */