identity management service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_statistics_service.h"
#include "gnunet_identity_service.h"
#include "identity.h"
Go to the source code of this file.
Data Structures | |
struct | Ego |
Information we keep about each ego. More... | |
struct | RenameContext |
Closure for 'handle_ego_rename'. More... | |
Functions | |
static char * | get_ego_filename (struct Ego *ego) |
Get the name of the file we use to store a given ego. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
Called whenever a client is disconnected. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
Add a client to our list of active clients. More... | |
static void | shutdown_task (void *cls) |
Task run during shutdown. More... | |
static void | send_result_code (struct GNUNET_SERVICE_Client *client, uint32_t result_code) |
Send a result code back to the client. More... | |
static struct GNUNET_MQ_Envelope * | create_update_message (struct Ego *ego) |
Create an update message with information about the current state of an ego. More... | |
static void | handle_start_message (void *cls, const struct GNUNET_MessageHeader *message) |
Handler for START message from client, sends information about all identities to the client immediately and adds the client to the notification context for future updates. More... | |
static int | check_lookup_message (void *cls, const struct LookupMessage *message) |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately. More... | |
static void | handle_lookup_message (void *cls, const struct LookupMessage *message) |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately. More... | |
static int | check_lookup_by_suffix_message (void *cls, const struct LookupMessage *message) |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately. More... | |
static void | handle_lookup_by_suffix_message (void *cls, const struct LookupMessage *message) |
Handler for LOOKUP_BY_SUFFIX message from client, sends information about ONE identity to the client immediately. More... | |
static void | notify_listeners (struct Ego *ego) |
Send an updated message for the given ego to all listeners. More... | |
static int | check_create_message (void *cls, const struct CreateRequestMessage *msg) |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_CREATE message. More... | |
static void | handle_create_message (void *cls, const struct CreateRequestMessage *crm) |
Handler for CREATE message from client, creates new identity. More... | |
static void | handle_ego_rename (void *cls, const char *section) |
An ego was renamed; rename it in all subsystems where it is currently set as the default. More... | |
static int | check_rename_message (void *cls, const struct RenameMessage *msg) |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_RENAME message. More... | |
static void | handle_rename_message (void *cls, const struct RenameMessage *rm) |
Handler for RENAME message from client, creates new identity. More... | |
static void | handle_ego_delete (void *cls, const char *section) |
An ego was removed, remove it from all subsystems where it is currently set as the default. More... | |
static int | check_delete_message (void *cls, const struct DeleteMessage *msg) |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_DELETE message. More... | |
static void | handle_delete_message (void *cls, const struct DeleteMessage *dm) |
Handler for DELETE message from client, creates new identity. More... | |
static int | read_from_file (const char *filename, void *buf, size_t buf_size) |
static int | process_ego_file (void *cls, const char *filename) |
Process the given file from the "EGODIR". More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) |
Handle network size estimate clients. More... | |
GNUNET_SERVICE_MAIN ("identity", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(start_message, GNUNET_MESSAGE_TYPE_IDENTITY_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(lookup_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, struct LookupMessage, NULL), GNUNET_MQ_hd_var_size(lookup_by_suffix_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, struct LookupMessage, NULL), GNUNET_MQ_hd_var_size(create_message, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, struct CreateRequestMessage, NULL), GNUNET_MQ_hd_var_size(rename_message, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, struct RenameMessage, NULL), GNUNET_MQ_hd_var_size(delete_message, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, struct DeleteMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Handle to our current configuration. More... | |
static struct GNUNET_CONFIGURATION_Handle * | subsystem_cfg |
Handle to subsystem configuration which for each subsystem contains the name of the default ego. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Handle to the statistics service. More... | |
static struct GNUNET_NotificationContext * | nc |
Notification context, simplifies client broadcasts. More... | |
static char * | ego_directory |
Directory where we store the identities. More... | |
static char * | subsystem_cfg_file |
Configuration file name where subsystem information is kept. More... | |
static struct Ego * | ego_head |
Head of DLL of all egos. More... | |
static struct Ego * | ego_tail |
Tail of DLL of all egos. More... | |
identity management service
The purpose of this service is to manage private keys that represent the various egos/pseudonyms/identities of a GNUnet user.
Todo:
Definition in file gnunet-service-identity.c.
|
static |
Get the name of the file we use to store a given ego.
ego | ego for which we need the filename |
Definition at line 118 of file gnunet-service-identity.c.
References DIR_SEPARATOR_STR, ego_directory, filename, GNUNET_asprintf(), and Ego::identifier.
Referenced by handle_create_message(), handle_delete_message(), and handle_rename_message().
|
static |
Called whenever a client is disconnected.
cls | closure |
client | identification of the client |
app_ctx | client |
Definition at line 139 of file gnunet-service-identity.c.
References GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.
|
static |
Add a client to our list of active clients.
cls | NULL |
client | client to add |
mq | message queue for client |
Definition at line 158 of file gnunet-service-identity.c.
|
static |
Task run during shutdown.
cls | unused |
Definition at line 172 of file gnunet-service-identity.c.
References ego_directory, ego_head, ego_tail, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_STATISTICS_destroy(), Ego::identifier, nc, stats, subsystem_cfg, and subsystem_cfg_file.
Referenced by run().
|
static |
Send a result code back to the client.
client | client that should receive the result code |
result_code | code to transmit |
Definition at line 210 of file gnunet-service-identity.c.
References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ErrorCode_get_hint(), GNUNET_log, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), and ResultCodeMessage::result_code.
Referenced by handle_create_message(), handle_delete_message(), handle_lookup_by_suffix_message(), handle_lookup_message(), and handle_rename_message().
|
static |
Create an update message with information about the current state of an ego.
ego | ego to create message for |
Definition at line 234 of file gnunet-service-identity.c.
References UpdateMessage::end_of_list, env, GNUNET_CRYPTO_private_key_get_length(), GNUNET_CRYPTO_write_private_key_to_buffer(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_msg_extra, GNUNET_NO, Ego::identifier, UpdateMessage::key_len, UpdateMessage::name_len, and Ego::pk.
Referenced by handle_lookup_by_suffix_message(), handle_lookup_message(), and handle_start_message().
|
static |
Handler for START message from client, sends information about all identities to the client immediately and adds the client to the notification context for future updates.
cls | a struct GNUNET_SERVICE_Client * |
message | the message received |
Definition at line 266 of file gnunet-service-identity.c.
References create_update_message(), ego_head, UpdateMessage::end_of_list, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_notification_context_add(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_get_mq(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_YES, UpdateMessage::key_len, UpdateMessage::name_len, nc, and Ego::next.
|
static |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.
cls | unused |
message | the message received |
Definition at line 308 of file gnunet-service-identity.c.
References GNUNET_MQ_check_zero_termination, and GNUNET_OK.
|
static |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.
cls | a struct GNUNET_SERVICE_Client * |
message | the message received |
Definition at line 324 of file gnunet-service-identity.c.
References create_update_message(), ego_head, env, GNUNET_EC_IDENTITY_NOT_FOUND, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), Ego::identifier, name, Ego::next, and send_result_code().
|
static |
Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.
cls | unused |
message | the message received |
Definition at line 358 of file gnunet-service-identity.c.
References GNUNET_MQ_check_zero_termination, and GNUNET_OK.
|
static |
Handler for LOOKUP_BY_SUFFIX message from client, sends information about ONE identity to the client immediately.
cls | a struct GNUNET_SERVICE_Client * |
message | the message received |
Definition at line 374 of file gnunet-service-identity.c.
References create_update_message(), ego_head, env, GNUNET_EC_IDENTITY_NOT_FOUND, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), Ego::identifier, name, Ego::next, and send_result_code().
|
static |
Send an updated message for the given ego to all listeners.
ego | ego to send the update for |
Definition at line 418 of file gnunet-service-identity.c.
References UpdateMessage::end_of_list, GNUNET_CRYPTO_private_key_get_length(), GNUNET_CRYPTO_write_private_key_to_buffer(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_NO, GNUNET_notification_context_broadcast(), UpdateMessage::header, Ego::identifier, UpdateMessage::key_len, UpdateMessage::name_len, nc, Ego::pk, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by handle_create_message(), handle_delete_message(), and handle_rename_message().
|
static |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_CREATE message.
cls | client sending the message |
msg | message of type struct CreateRequestMessage |
Definition at line 449 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, UpdateMessage::key_len, msg, UpdateMessage::name_len, GNUNET_MessageHeader::size, and size.
|
static |
Handler for CREATE message from client, creates new identity.
cls | unused |
crm | the message received |
Definition at line 487 of file gnunet-service-identity.c.
References ego_head, ego_tail, get_ego_filename(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_EC_IDENTITY_NAME_CONFLICT, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_new, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_SYSERR, Ego::identifier, CreateRequestMessage::key_len, Ego::next, notify_listeners(), Ego::pk, and send_result_code().
|
static |
An ego was renamed; rename it in all subsystems where it is currently set as the default.
cls | the 'struct RenameContext' |
section | a section in the configuration to process |
Definition at line 569 of file gnunet-service-identity.c.
References GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, id, RenameContext::new_name, RenameContext::old_name, and subsystem_cfg.
Referenced by handle_rename_message().
|
static |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_RENAME message.
cls | client sending the message |
msg | message of type struct RenameMessage |
Definition at line 600 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, RenameContext::new_name, RenameContext::old_name, GNUNET_MessageHeader::size, and size.
|
static |
Handler for RENAME message from client, creates new identity.
cls | unused |
rm | the message received |
Definition at line 638 of file gnunet-service-identity.c.
References _, ego_head, get_ego_filename(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), GNUNET_EC_IDENTITY_NAME_CONFLICT, GNUNET_EC_IDENTITY_NOT_FOUND, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), handle_ego_rename(), Ego::identifier, RenameContext::new_name, Ego::next, notify_listeners(), RenameContext::old_name, RenameMessage::old_name_len, send_result_code(), subsystem_cfg, and subsystem_cfg_file.
|
static |
An ego was removed, remove it from all subsystems where it is currently set as the default.
cls | name of the removed ego (const char *) |
section | a section in the configuration to process |
Definition at line 720 of file gnunet-service-identity.c.
References GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, id, and subsystem_cfg.
Referenced by handle_delete_message().
|
static |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_DELETE message.
cls | client sending the message |
msg | message of type struct DeleteMessage |
Definition at line 751 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, msg, name, GNUNET_MessageHeader::size, and size.
|
static |
Handler for DELETE message from client, creates new identity.
cls | unused |
dm | the message received |
Definition at line 783 of file gnunet-service-identity.c.
References _, ego_head, ego_tail, get_ego_filename(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_DLL_remove, GNUNET_EC_IDENTITY_NOT_FOUND, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), handle_ego_delete(), Ego::identifier, name, Ego::next, notify_listeners(), send_result_code(), subsystem_cfg, and subsystem_cfg_file.
|
static |
Definition at line 830 of file gnunet-service-identity.c.
References filename, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, and GNUNET_SYSERR.
Referenced by process_ego_file().
|
static |
Process the given file from the "EGODIR".
Parses the file and creates the respective 'struct Ego' in memory.
cls | NULL |
filename | name of the file to parse |
Definition at line 901 of file gnunet-service-identity.c.
References _, DIR_SEPARATOR, ego_head, ego_tail, filename, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_strdup, Ego::identifier, Ego::pk, and read_from_file().
Referenced by run().
|
static |
Handle network size estimate clients.
cls | closure |
server | the initialized server |
c | configuration to use |
Definition at line 942 of file gnunet-service-identity.c.
References _, cfg, ego_directory, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_scan(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_config_missing(), GNUNET_notification_context_create(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_YES, nc, process_ego_file(), shutdown_task(), stats, subsystem_cfg, and subsystem_cfg_file.
GNUNET_SERVICE_MAIN | ( | "identity" | , |
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
& | client_connect_cb, | ||
& | client_disconnect_cb, | ||
NULL | , | ||
GNUNET_MQ_hd_fixed_size(start_message, GNUNET_MESSAGE_TYPE_IDENTITY_START, struct GNUNET_MessageHeader, NULL) | , | ||
GNUNET_MQ_hd_var_size(lookup_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, struct LookupMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(lookup_by_suffix_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, struct LookupMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(create_message, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, struct CreateRequestMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(rename_message, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, struct RenameMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(delete_message, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, struct DeleteMessage, NULL) | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
|
static |
Handle to our current configuration.
Definition at line 72 of file gnunet-service-identity.c.
Referenced by run().
|
static |
Handle to subsystem configuration which for each subsystem contains the name of the default ego.
Definition at line 78 of file gnunet-service-identity.c.
Referenced by handle_delete_message(), handle_ego_delete(), handle_ego_rename(), handle_rename_message(), run(), and shutdown_task().
|
static |
Handle to the statistics service.
Definition at line 83 of file gnunet-service-identity.c.
Referenced by run(), and shutdown_task().
|
static |
Notification context, simplifies client broadcasts.
Definition at line 88 of file gnunet-service-identity.c.
Referenced by handle_start_message(), notify_listeners(), run(), and shutdown_task().
|
static |
Directory where we store the identities.
Definition at line 93 of file gnunet-service-identity.c.
Referenced by get_ego_filename(), run(), and shutdown_task().
|
static |
Configuration file name where subsystem information is kept.
Definition at line 98 of file gnunet-service-identity.c.
Referenced by handle_delete_message(), handle_rename_message(), run(), and shutdown_task().
|
static |
Head of DLL of all egos.
Definition at line 103 of file gnunet-service-identity.c.
Referenced by handle_create_message(), handle_delete_message(), handle_lookup_by_suffix_message(), handle_lookup_message(), handle_rename_message(), handle_start_message(), process_ego_file(), and shutdown_task().
|
static |
Tail of DLL of all egos.
Definition at line 108 of file gnunet-service-identity.c.
Referenced by handle_create_message(), handle_delete_message(), process_ego_file(), and shutdown_task().