![]() |
GNUnet
0.11.x
|
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, const char *emsg) |
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 struct GNUNET_MQ_Envelope * | create_set_default_message (struct Ego *ego, const char *servicename) |
Create a set default 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 int | check_get_default_message (void *cls, const struct GetDefaultMessage *msg) |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message. More... | |
static void | handle_get_default_message (void *cls, const struct GetDefaultMessage *gdm) |
Handler for GET_DEFAULT message from client, returns default identity for some service. More... | |
static int | key_cmp (const struct GNUNET_IDENTITY_PrivateKey *pk1, const struct GNUNET_IDENTITY_PrivateKey *pk2) |
Compare the given two private keys for equality. More... | |
static int | check_set_default_message (void *cls, const struct SetDefaultMessage *msg) |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT message. More... | |
static void | handle_set_default_message (void *cls, const struct SetDefaultMessage *sdm) |
Handler for SET_DEFAULT message from client, updates default identity for some service. 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(get_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, struct GetDefaultMessage, NULL), GNUNET_MQ_hd_var_size(set_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, struct SetDefaultMessage, 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.
Referenced by run().
|
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.
Referenced by run().
|
static |
Task run during shutdown.
cls | unused |
Definition at line 172 of file gnunet-service-identity.c.
References e, ego_directory, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_STATISTICS_destroy(), Ego::identifier, 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 |
emsg | error message to include (or NULL for none) |
Definition at line 211 of file gnunet-service-identity.c.
References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), and ResultCodeMessage::result_code.
Referenced by handle_create_message(), handle_delete_message(), handle_get_default_message(), handle_lookup_by_suffix_message(), handle_lookup_message(), handle_rename_message(), and handle_set_default_message().
|
static |
Create an update message with information about the current state of an ego.
ego | ego to create message for |
Definition at line 243 of file gnunet-service-identity.c.
References UpdateMessage::end_of_list, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_msg_extra, GNUNET_NO, Ego::identifier, UpdateMessage::name_len, Ego::pk, and UpdateMessage::private_key.
Referenced by handle_lookup_by_suffix_message(), handle_lookup_message(), and handle_start_message().
|
static |
Create a set default message with information about the current state of an ego.
ego | ego to create message for |
servicename | name of the service to provide in the message |
Definition at line 267 of file gnunet-service-identity.c.
References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MQ_msg_extra, SetDefaultMessage::name_len, Ego::pk, SetDefaultMessage::private_key, and SetDefaultMessage::reserved.
Referenced by handle_get_default_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 296 of file gnunet-service-identity.c.
References create_update_message(), 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::name_len, 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 337 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 353 of file gnunet-service-identity.c.
References create_update_message(), env, 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 387 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 403 of file gnunet-service-identity.c.
References create_update_message(), env, 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 |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message.
cls | client sending the message |
msg | message of type struct GetDefaultMessage |
Definition at line 449 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GetDefaultMessage::header, name, GetDefaultMessage::name_len, GetDefaultMessage::reserved, size, and GNUNET_MessageHeader::size.
|
static |
Handler for GET_DEFAULT message from client, returns default identity for some service.
cls | unused |
client | who sent the message |
message | the message received |
Definition at line 483 of file gnunet-service-identity.c.
References create_set_default_message(), env, gettext_noop, GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, name, Ego::next, and send_result_code().
|
static |
Compare the given two private keys for equality.
pk1 | one private key |
pk2 | another private key |
Definition at line 541 of file gnunet-service-identity.c.
References GNUNET_memcmp.
Referenced by handle_set_default_message().
|
static |
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT message.
cls | client sending the message |
msg | message of type struct SetDefaultMessage |
Definition at line 556 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, SetDefaultMessage::header, SetDefaultMessage::name_len, SetDefaultMessage::reserved, size, and GNUNET_MessageHeader::size.
|
static |
Handler for SET_DEFAULT message from client, updates default identity for some service.
cls | unused |
client | who sent the message |
message | the message received |
Definition at line 595 of file gnunet-service-identity.c.
References _, GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, key_cmp(), Ego::next, Ego::pk, send_result_code(), and subsystem_cfg_file.
|
static |
Send an updated message for the given ego to all listeners.
ego | ego to send the update for |
Definition at line 643 of file gnunet-service-identity.c.
References UpdateMessage::end_of_list, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_NO, GNUNET_notification_context_broadcast(), UpdateMessage::header, Ego::identifier, UpdateMessage::name_len, Ego::pk, UpdateMessage::private_key, 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 669 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, CreateRequestMessage::header, UpdateMessage::name_len, CreateRequestMessage::name_len, CreateRequestMessage::reserved, size, and GNUNET_MessageHeader::size.
|
static |
Handler for CREATE message from client, creates new identity.
cls | unused |
client | who sent the message |
message | the message received |
Definition at line 707 of file gnunet-service-identity.c.
References fn, get_ego_filename(), gettext_noop, GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, 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_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, 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 777 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, and RenameContext::old_name.
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 808 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RenameMessage::header, RenameContext::new_name, RenameMessage::new_name_len, RenameContext::old_name, RenameMessage::old_name_len, size, and GNUNET_MessageHeader::size.
|
static |
Handler for RENAME message from client, creates new identity.
cls | unused |
client | who sent the message |
message | the message received |
Definition at line 847 of file gnunet-service-identity.c.
References _, get_ego_filename(), gettext_noop, GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), 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(), 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 929 of file gnunet-service-identity.c.
References GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, id, and Ego::identifier.
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 960 of file gnunet-service-identity.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, DeleteMessage::header, name, DeleteMessage::name_len, DeleteMessage::reserved, size, and GNUNET_MessageHeader::size.
|
static |
Handler for DELETE message from client, creates new identity.
cls | unused |
client | who sent the message |
message | the message received |
Definition at line 993 of file gnunet-service-identity.c.
References _, fn, get_ego_filename(), gettext_noop, GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_DLL_remove, 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(), and subsystem_cfg_file.
|
static |
Definition at line 1040 of file gnunet-service-identity.c.
References 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 1111 of file gnunet-service-identity.c.
References _, DIR_SEPARATOR, fn, 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 1152 of file gnunet-service-identity.c.
References _, client_connect_cb(), client_disconnect_cb(), create_message(), 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_MESSAGE_TYPE_IDENTITY_CREATE, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MESSAGE_TYPE_IDENTITY_START, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_notification_context_create(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_YES, process_ego_file(), shutdown_task(), and subsystem_cfg_file.
Define "main" method using service macro.
Referenced by run().
|
static |
Handle to our current configuration.
Definition at line 72 of file gnunet-service-identity.c.
|
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.
|
static |
Handle to the statistics service.
Definition at line 83 of file gnunet-service-identity.c.
|
static |
Notification context, simplifies client broadcasts.
Definition at line 88 of file gnunet-service-identity.c.
|
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(), handle_set_default_message(), run(), and shutdown_task().
|
static |
Head of DLL of all egos.
Definition at line 103 of file gnunet-service-identity.c.
|
static |
Tail of DLL of all egos.
Definition at line 108 of file gnunet-service-identity.c.