[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: IDENTITY/NAMESTORE:
From: |
gnunet |
Subject: |
[gnunet] branch master updated: IDENTITY/NAMESTORE: |
Date: |
Thu, 27 Oct 2022 16:25:21 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 8ccba14bb IDENTITY/NAMESTORE:
8ccba14bb is described below
commit 8ccba14bbf77f784f6490130928a26e678f13736
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Oct 27 23:24:27 2022 +0900
IDENTITY/NAMESTORE:
Remove the concept of "Subsystem default identities".
Add GNUNET_ErrorCodes to IDENTITY subsystem.
---
contrib/sphinx | 2 +-
doc/man/gnunet-identity.1 | 11 -
po/de.po | 2 +-
po/es.po | 2 +-
po/fr.po | 2 +-
po/it.po | 2 +-
po/sr.po | 2 +-
po/sv.po | 2 +-
po/vi.po | 2 +-
po/zh_CN.po | 2 +-
src/identity/Makefile.am | 20 +-
src/identity/gnunet-identity.c | 86 +----
src/identity/gnunet-service-identity.c | 263 +-------------
src/identity/identity.h | 58 ----
src/identity/identity_api.c | 209 +----------
src/identity/plugin_rest_identity.c | 382 +++------------------
src/identity/test_identity.c | 24 +-
src/identity/test_identity_defaults.c | 301 ----------------
src/identity/test_identity_messages.sh | 8 +-
src/include/gnunet_identity_service.h | 8 +-
src/messenger/gnunet-service-messenger_ego_store.c | 30 +-
src/namestore/gnunet-namestore-zonefile.c | 6 +-
src/namestore/gnunet-namestore.c | 120 ++++---
src/reclaim/gnunet-did.c | 6 +-
24 files changed, 227 insertions(+), 1323 deletions(-)
diff --git a/contrib/sphinx b/contrib/sphinx
index 5f853d253..84cb6aaaa 160000
--- a/contrib/sphinx
+++ b/contrib/sphinx
@@ -1 +1 @@
-Subproject commit 5f853d253daa5bc700b549fd40e4086aee1058b8
+Subproject commit 84cb6aaaaebe9b79d5453a8444ee95459c8f5029
diff --git a/doc/man/gnunet-identity.1 b/doc/man/gnunet-identity.1
index 835dfb225..d693d3688 100644
--- a/doc/man/gnunet-identity.1
+++ b/doc/man/gnunet-identity.1
@@ -39,7 +39,6 @@
.Op Fl p | -private-keys
.Op Fl q | -quiet
.Op Fl R Ar MESSAGE | Fl -read= Ns Ar MESSAGE
-.Op Fl s Ar SUBSYSTEM | Fl -set= Ns Ar SUBSYSTEM
.Op Fl V | -verbose
.Op Fl W Ar MESSAGE | Fl -write= Ns Ar MESSAGE
.Op Fl X | -eddsa
@@ -100,16 +99,6 @@ Decrypt (read) a message using the respective ego private
key. Use together with
The message consists of an ephemeral key and the ciphertext, separated by a
dot.
Such messages can be created with
.Fl W .
-.It Fl s Ar SUBSYSTEM | Fl -set= Ns Ar SUBSYSTEM
-Perform "set" operation for the specified
-.Ar SUBSYSTEM
-with the respective ego.
-Needs to be used together with option
-.Fl e .
-After this, the given SUBSYSTEM will use the ego with the specified NAME.
-This will fail if
-.Ar NAME
-does not yet exist.
.It Fl V | -verbose
Be verbose, in particular outputs the public key of freshly created egos.
.It Fl W Ar MESSAGE | Fl -write= Ns Ar MESSAGE
diff --git a/po/de.po b/po/de.po
index e74e6a4cd..eb8f5638a 100644
--- a/po/de.po
+++ b/po/de.po
@@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet 0.10.1\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2015-03-08 16:16+0100\n"
"Last-Translator: Mario Blättermann <mario.blaettermann@gmail.com>\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
diff --git a/po/es.po b/po/es.po
index c98b1d36b..5c37e3cab 100644
--- a/po/es.po
+++ b/po/es.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet 0.9.5a\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2013-02-23 17:50+0100\n"
"Last-Translator: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
diff --git a/po/fr.po b/po/fr.po
index f7678b116..55e5563f9 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet 0.10.1\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2021-11-21 00:53+0100\n"
"Last-Translator: Stéphane Aulery <lkppo@free.fr>\n"
"Language-Team: French <traduc@traduc.org>\n"
diff --git a/po/it.po b/po/it.po
index 3100c062a..9dd11b967 100644
--- a/po/it.po
+++ b/po/it.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet 0.10.1\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2019-10-16 11:00+0200\n"
"Last-Translator: Sebastiano Pistore <sebastianopistore.info@protonmail.ch>\n"
"Language-Team: Italian <tp@lists.linux.it>\n"
diff --git a/po/sr.po b/po/sr.po
index 1d924cb69..03ab80d52 100644
--- a/po/sr.po
+++ b/po/sr.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet-0.10.1\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2020-10-23 18:39+0200\n"
"Last-Translator: Мирослав Николић <miroslavnikolic@rocketmail.com>\n"
"Language-Team: Serbian <(nothing)>\n"
diff --git a/po/sv.po b/po/sv.po
index 04f2ada11..e89762bfe 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GNUnet 0.7.0b\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2006-01-21 17:16+0100\n"
"Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
diff --git a/po/vi.po b/po/vi.po
index 5aeaebbe7..7c9f271c8 100644
--- a/po/vi.po
+++ b/po/vi.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet 0.8.0a\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2008-09-10 22:05+0930\n"
"Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n"
"Language-Team: Vietnamese <vi-VN@googlegroups.com>\n"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 07222df1f..cf29f44b2 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gnunet-0.8.1\n"
"Report-Msgid-Bugs-To: gnunet-developers@mail.gnu.org\n"
-"POT-Creation-Date: 2022-10-27 11:51+0900\n"
+"POT-Creation-Date: 2022-10-27 12:13+0900\n"
"PO-Revision-Date: 2011-07-09 12:12+0800\n"
"Last-Translator: Wylmer Wang <wantinghard@gmail.com>\n"
"Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am
index 5a2110974..12d3906a8 100644
--- a/src/identity/Makefile.am
+++ b/src/identity/Makefile.am
@@ -49,10 +49,10 @@ bin_PROGRAMS = \
gnunet-identity
libexec_PROGRAMS = \
- gnunet-service-identity
+ gnunet-service-identity
gnunet_service_identity_SOURCES = \
- gnunet-service-identity.c
+ gnunet-service-identity.c
gnunet_service_identity_LDADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
@@ -60,7 +60,7 @@ gnunet_service_identity_LDADD = \
gnunet_identity_SOURCES = \
- gnunet-identity.c
+ gnunet-identity.c
gnunet_identity_LDADD = \
libgnunetidentity.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -68,8 +68,7 @@ gnunet_identity_LDADD = \
$(GN_LIBINTL)
check_PROGRAMS = \
- test_identity \
- test_identity_defaults
+ test_identity
check_SCRIPTS = \
test_identity_messages.sh
@@ -85,17 +84,10 @@ test_identity_SOURCES = \
test_identity_LDADD = \
libgnunetidentity.la \
$(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-test_identity_defaults_SOURCES = \
- test_identity_defaults.c
-test_identity_defaults_LDADD = \
- libgnunetidentity.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la
+ $(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
test_identity.conf \
- test_identity_messages.sh
+ test_identity_messages.sh
diff --git a/src/identity/gnunet-identity.c b/src/identity/gnunet-identity.c
index 97dc2ce7e..6f09113d8 100644
--- a/src/identity/gnunet-identity.c
+++ b/src/identity/gnunet-identity.c
@@ -105,11 +105,6 @@ static char *pubkey_msg;
*/
static char *set_ego;
-/**
- * -S option.
- */
-static char *set_subsystem;
-
/**
* Operation handle for set operation.
*/
@@ -178,7 +173,6 @@ test_finished (void)
if ( (NULL == create_op) &&
(NULL == delete_op) &&
(NULL == set_op) &&
- (NULL == set_subsystem) &&
(NULL == write_msg) &&
(NULL == read_msg) &&
(! list) &&
@@ -195,17 +189,17 @@ test_finished (void)
* Deletion operation finished.
*
* @param cls pointer to operation handle
- * @param emsg NULL on success, otherwise an error message
+ * @param ec the error code
*/
static void
delete_finished (void *cls,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_IDENTITY_Operation **op = cls;
*op = NULL;
- if (NULL != emsg)
- fprintf (stderr, "%s\n", gettext (emsg));
+ if (GNUNET_EC_NONE != ec)
+ fprintf (stderr, "%s\n", GNUNET_ErrorCode_get_hint (ec));
test_finished ();
}
@@ -215,12 +209,12 @@ delete_finished (void *cls,
*
* @param cls pointer to operation handle
* @param pk private key of the ego, or NULL on error
- * @param emsg error message, NULL on success
+ * @param ec the error code
*/
static void
create_finished (void *cls,
const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_IDENTITY_Operation **op = cls;
@@ -229,7 +223,7 @@ create_finished (void *cls,
{
fprintf (stderr,
_ ("Failed to create ego: %s\n"),
- emsg);
+ GNUNET_ErrorCode_get_hint (ec));
global_ret = 1;
}
else if (verbose)
@@ -257,25 +251,6 @@ create_finished (void *cls,
}
-/**
- * Function called by #GNUNET_IDENTITY_set up on completion.
- *
- * @param cls NULL
- * @param emsg error message (NULL on success)
- */
-static void
-set_done (void *cls, const char *emsg)
-{
- set_op = NULL;
- if (NULL != emsg)
- {
- fprintf (stderr, _ ("Failed to set default ego: %s\n"), emsg);
- global_ret = 1;
- }
- test_finished ();
-}
-
-
/**
* Encrypt a message given with -W, encrypted using public key of
* an identity given with -k.
@@ -447,35 +422,6 @@ print_ego (void *cls,
char *s;
char *privs;
- if ( (NULL != set_ego) &&
- (NULL != set_subsystem) &&
- (NULL != ego) &&
- (NULL != identifier) &&
- (0 == strcmp (identifier, set_ego)))
- {
- set_op = GNUNET_IDENTITY_set (sh,
- set_subsystem,
- ego,
- &set_done,
- NULL);
- GNUNET_free (set_subsystem);
- set_subsystem = NULL;
- GNUNET_free (set_ego);
- set_ego = NULL;
- }
- if ( (NULL == ego) &&
- (NULL != set_ego) &&
- (NULL != set_subsystem) )
- {
- fprintf (stderr,
- "Could not set ego to `%s' for subsystem `%s', ego not known\n",
- set_ego,
- set_subsystem);
- GNUNET_free (set_subsystem);
- set_subsystem = NULL;
- GNUNET_free (set_ego);
- set_ego = NULL;
- }
if ( (NULL == ego) &&
(NULL != set_ego) &&
(NULL != read_msg) )
@@ -557,12 +503,6 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- if ((NULL != set_subsystem) && (NULL == set_ego))
- {
- fprintf (stderr, "Option -s requires option -e to be specified as
well.\n");
- return;
- }
-
if ((NULL != read_msg) && (NULL == set_ego))
{
fprintf (stderr,
@@ -577,8 +517,7 @@ run (void *cls,
}
sh = GNUNET_IDENTITY_connect (cfg,
(monitor | list) ||
- (NULL != set_ego) ||
- (NULL != set_subsystem)
+ (NULL != set_ego)
? &print_ego
: NULL,
NULL);
@@ -686,7 +625,7 @@ main (int argc, char *const *argv)
"ego",
"NAME",
gettext_noop (
- "set default identity to NAME for a subsystem SUBSYSTEM (use together
with -s), restrict results to NAME (use together with -d) or read and decrypt a
message for NAME (use together with -R)"),
+ "restrict results to NAME (use together with -d) or read and decrypt a
message for NAME (use together with -R)"),
&set_ego),
GNUNET_GETOPT_option_string ('k',
"key",
@@ -702,13 +641,6 @@ main (int argc, char *const *argv)
"private-keys",
gettext_noop ("display private keys as well"),
&private_keys),
- GNUNET_GETOPT_option_string (
- 's',
- "set",
- "SUBSYSTEM",
- gettext_noop (
- "set default identity to EGO for a subsystem SUBSYSTEM (use together
with -e)"),
- &set_subsystem),
GNUNET_GETOPT_option_verbose (&verbose),
GNUNET_GETOPT_OPTION_END
};
diff --git a/src/identity/gnunet-service-identity.c
b/src/identity/gnunet-service-identity.c
index 51fca7816..5e3f7bb35 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -205,30 +205,21 @@ shutdown_task (void *cls)
*
* @param client client that should receive the result code
* @param result_code code to transmit
- * @param emsg error message to include (or NULL for none)
*/
static void
send_result_code (struct GNUNET_SERVICE_Client *client,
- uint32_t result_code,
- const char *emsg)
+ uint32_t result_code)
{
struct ResultCodeMessage *rcm;
struct GNUNET_MQ_Envelope *env;
- size_t elen;
- if (NULL == emsg)
- elen = 0;
- else
- elen = strlen (emsg) + 1;
env =
- GNUNET_MQ_msg_extra (rcm, elen, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
+ GNUNET_MQ_msg (rcm, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE);
rcm->result_code = htonl (result_code);
- if (0 < elen)
- GNUNET_memcpy (&rcm[1], emsg, elen);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending result %d (%s) to client\n",
(int) result_code,
- emsg);
+ GNUNET_ErrorCode_get_hint (result_code));
GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
}
@@ -256,33 +247,6 @@ create_update_message (struct Ego *ego)
}
-/**
- * Create a set default message with information about the current state of an
ego.
- *
- * @param ego ego to create message for
- * @param servicename name of the service to provide in the message
- * @return corresponding set default message
- */
-static struct GNUNET_MQ_Envelope *
-create_set_default_message (struct Ego *ego,
- const char *servicename)
-{
- struct SetDefaultMessage *sdm;
- struct GNUNET_MQ_Envelope *env;
- size_t name_len;
-
- name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1);
- env = GNUNET_MQ_msg_extra (sdm,
- name_len,
- GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
- sdm->name_len = htons (name_len);
- sdm->reserved = htons (0);
- sdm->private_key = ego->pk;
- GNUNET_memcpy (&sdm[1], servicename, name_len);
- return env;
-}
-
-
/**
* Handler for START message from client, sends information
* about all identities to the client immediately and
@@ -370,7 +334,7 @@ handle_lookup_message (void *cls,
GNUNET_SERVICE_client_continue (client);
return;
}
- send_result_code (client, 0, "ego not found");
+ send_result_code (client, GNUNET_EC_IDENTITY_NOT_FOUND);
GNUNET_SERVICE_client_continue (client);
}
@@ -433,200 +397,7 @@ handle_lookup_by_suffix_message (void *cls,
GNUNET_SERVICE_client_continue (client);
return;
}
- send_result_code (client, 0, "ego not found");
- GNUNET_SERVICE_client_continue (client);
-}
-
-
-/**
- * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message
- *
- * @param cls client sending the message
- * @param msg message of type `struct GetDefaultMessage`
- * @return #GNUNET_OK if @a msg is well-formed
- */
-static int
-check_get_default_message (void *cls,
- const struct GetDefaultMessage *msg)
-{
- uint16_t size;
- uint16_t name_len;
- const char *name;
-
- size = ntohs (msg->header.size);
- if (size <= sizeof(struct GetDefaultMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- name = (const char *) &msg[1];
- name_len = ntohs (msg->name_len);
- if ((name_len + sizeof(struct GetDefaultMessage) != size) ||
- (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Handler for GET_DEFAULT message from client, returns
- * default identity for some service.
- *
- * @param cls unused
- * @param gdm the message received
- */
-static void
-handle_get_default_message (void *cls,
- const struct GetDefaultMessage *gdm)
-{
- struct GNUNET_MQ_Envelope *env;
- struct GNUNET_SERVICE_Client *client = cls;
- char *name;
- char *identifier;
-
- name = GNUNET_strdup ((const char *) &gdm[1]);
- GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received GET_DEFAULT for service `%s' from client\n",
- name);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (subsystem_cfg,
- name,
- "DEFAULT_IDENTIFIER",
- &identifier))
- {
- send_result_code (client, 1, gettext_noop ("no default known"));
- GNUNET_SERVICE_client_continue (client);
- GNUNET_free (name);
- return;
- }
- for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
- {
- if (0 == strcmp (ego->identifier, identifier))
- {
- env = create_set_default_message (ego, name);
- GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
- GNUNET_SERVICE_client_continue (client);
- GNUNET_free (identifier);
- GNUNET_free (name);
- return;
- }
- }
- GNUNET_free (identifier);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to find ego `%s'\n",
- name);
- GNUNET_free (name);
- send_result_code (client,
- 1,
- gettext_noop (
- "default configured, but ego unknown (internal error)"));
- GNUNET_SERVICE_client_continue (client);
-}
-
-
-/**
- * Compare the given two private keys for equality.
- *
- * @param pk1 one private key
- * @param pk2 another private key
- * @return 0 if the keys are equal
- */
-static int
-key_cmp (const struct GNUNET_IDENTITY_PrivateKey *pk1,
- const struct GNUNET_IDENTITY_PrivateKey *pk2)
-{
- return GNUNET_memcmp (pk1, pk2);
-}
-
-
-/**
- * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT message
- *
- * @param cls client sending the message
- * @param msg message of type `struct SetDefaultMessage`
- * @return #GNUNET_OK if @a msg is well-formed
- */
-static int
-check_set_default_message (void *cls,
- const struct SetDefaultMessage *msg)
-{
- uint16_t size;
- uint16_t name_len;
- const char *str;
-
- size = ntohs (msg->header.size);
- if (size <= sizeof(struct SetDefaultMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- name_len = ntohs (msg->name_len);
- GNUNET_break (0 == ntohs (msg->reserved));
- if (name_len + sizeof(struct SetDefaultMessage) != size)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- str = (const char *) &msg[1];
- if ('\0' != str[name_len - 1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Handler for SET_DEFAULT message from client, updates
- * default identity for some service.
- *
- * @param cls unused
- * @param sdm the message received
- */
-static void
-handle_set_default_message (void *cls,
- const struct SetDefaultMessage *sdm)
-{
- struct Ego *ego;
- struct GNUNET_SERVICE_Client *client = cls;
- char *str;
-
- str = GNUNET_strdup ((const char *) &sdm[1]);
- GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received SET_DEFAULT for service `%s' from client\n",
- str);
- for (ego = ego_head; NULL != ego; ego = ego->next)
- {
- if (0 == key_cmp (&ego->pk,
- &sdm->private_key))
- {
- GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
- str,
- "DEFAULT_IDENTIFIER",
- ego->identifier);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_write (subsystem_cfg, subsystem_cfg_file))
- GNUNET_log (
- GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to write subsystem default identifier map to `%s'.\n"),
- subsystem_cfg_file);
- send_result_code (client, 0, NULL);
- GNUNET_SERVICE_client_continue (client);
- GNUNET_free (str);
- return;
- }
- }
- send_result_code (client,
- 1,
- _ ("Unknown ego specified for service (internal error)"));
- GNUNET_free (str);
+ send_result_code (client, GNUNET_EC_IDENTITY_NOT_FOUND);
GNUNET_SERVICE_client_continue (client);
}
@@ -716,9 +487,7 @@ handle_create_message (void *cls,
if (0 == strcmp (ego->identifier, str))
{
send_result_code (client,
- 1,
- gettext_noop (
- "identifier already in use for another ego"));
+ GNUNET_EC_IDENTITY_NAME_CONFLICT);
GNUNET_SERVICE_client_continue (client);
GNUNET_free (str);
return;
@@ -730,7 +499,7 @@ handle_create_message (void *cls,
GNUNET_CONTAINER_DLL_insert (ego_head,
ego_tail,
ego);
- send_result_code (client, 0, NULL);
+ send_result_code (client, GNUNET_EC_NONE);
fn = get_ego_filename (ego);
if (GNUNET_OK !=
GNUNET_DISK_fn_write (fn,
@@ -864,7 +633,7 @@ handle_rename_message (void *cls, const struct
RenameMessage *rm)
{
if (0 == strcmp (ego->identifier, new_name))
{
- send_result_code (client, 1, gettext_noop ("target name already
exists"));
+ send_result_code (client, GNUNET_EC_IDENTITY_NAME_CONFLICT);
GNUNET_SERVICE_client_continue (client);
GNUNET_free (old_name);
GNUNET_free (new_name);
@@ -899,14 +668,14 @@ handle_rename_message (void *cls, const struct
RenameMessage *rm)
GNUNET_free (old_name);
GNUNET_free (new_name);
notify_listeners (ego);
- send_result_code (client, 0, NULL);
+ send_result_code (client, GNUNET_EC_NONE);
GNUNET_SERVICE_client_continue (client);
return;
}
}
/* failed to locate old name */
- send_result_code (client, 1, gettext_noop ("no matching ego found"));
+ send_result_code (client, GNUNET_EC_IDENTITY_NOT_FOUND);
GNUNET_free (old_name);
GNUNET_free (new_name);
GNUNET_SERVICE_client_continue (client);
@@ -1018,13 +787,13 @@ handle_delete_message (void *cls, const struct
DeleteMessage *dm)
notify_listeners (ego);
GNUNET_free (ego);
GNUNET_free (name);
- send_result_code (client, 0, NULL);
+ send_result_code (client, GNUNET_EC_NONE);
GNUNET_SERVICE_client_continue (client);
return;
}
}
- send_result_code (client, 1, gettext_noop ("no matching ego found"));
+ send_result_code (client, GNUNET_EC_IDENTITY_NOT_FOUND);
GNUNET_free (name);
GNUNET_SERVICE_client_continue (client);
}
@@ -1221,14 +990,6 @@ GNUNET_SERVICE_MAIN (
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,
diff --git a/src/identity/identity.h b/src/identity/identity.h
index 11c5883bc..57ce091b8 100644
--- a/src/identity/identity.h
+++ b/src/identity/identity.h
@@ -89,8 +89,6 @@ struct ResultCodeMessage
* (currently not used).
*/
uint32_t result_code GNUNET_PACKED;
-
- /* followed by 0-terminated error message (on error) */
};
@@ -139,62 +137,6 @@ struct UpdateMessage
};
-/**
- * Client requests knowledge about default identity for
- * a subsystem from identity service.
- */
-struct GetDefaultMessage
-{
- /**
- * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * Number of bytes in service name string including 0-termination, in NBO.
- */
- uint16_t name_len GNUNET_PACKED;
-
- /**
- * Always zero.
- */
- uint16_t reserved GNUNET_PACKED;
-
-
- /* followed by 0-terminated service name */
-};
-
-
-/**
- * Used from service to client as a result to the GET_DEFAULT
- * message, used from client to service to SET_DEFAULT.
- */
-struct SetDefaultMessage
-{
- /**
- * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * Number of bytes in service name string including 0-termination, in NBO.
- */
- uint16_t name_len GNUNET_PACKED;
-
- /**
- * Always zero.
- */
- uint16_t reserved GNUNET_PACKED;
-
- /**
- * The private key
- */
- struct GNUNET_IDENTITY_PrivateKey private_key;
-
- /* followed by 0-terminated service name */
-};
-
-
/**
* Client requests creation of an identity. Service
* will respond with a result code.
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 934ee31c6..d41e05104 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -279,13 +279,13 @@ reschedule_connect (struct GNUNET_IDENTITY_Handle *h)
op);
if (NULL != op->cont)
op->cont (op->cls,
- "Error in communication with the identity service");
+ GNUNET_EC_SERVICE_COMMUNICATION_FAILED);
else if (NULL != op->cb)
op->cb (op->cls, NULL, NULL, NULL);
else if (NULL != op->create_cont)
op->create_cont (op->cls,
NULL,
- "Failed to communicate with the identity service");
+ GNUNET_EC_SERVICE_COMMUNICATION_FAILED);
GNUNET_free (op);
}
GNUNET_CONTAINER_multihashmap_iterate (h->egos,
@@ -321,24 +321,6 @@ mq_error_handler (void *cls,
}
-/**
- * We received a result code from the service. Check the message
- * is well-formed.
- *
- * @param cls closure
- * @param rcm result message received
- * @return #GNUNET_OK if the message is well-formed
- */
-static int
-check_identity_result_code (void *cls,
- const struct ResultCodeMessage *rcm)
-{
- if (sizeof(*rcm) != htons (rcm->header.size))
- GNUNET_MQ_check_zero_termination (rcm);
- return GNUNET_OK;
-}
-
-
/**
* We received a result code from the service.
*
@@ -351,8 +333,7 @@ handle_identity_result_code (void *cls,
{
struct GNUNET_IDENTITY_Handle *h = cls;
struct GNUNET_IDENTITY_Operation *op;
- uint16_t size = ntohs (rcm->header.size) - sizeof(*rcm);
- const char *str = (0 == size) ? NULL : (const char *) &rcm[1];
+ enum GNUNET_ErrorCode ec = ntohl (rcm->result_code);
op = h->op_head;
if (NULL == op)
@@ -363,11 +344,11 @@ handle_identity_result_code (void *cls,
}
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
if (NULL != op->cont)
- op->cont (op->cls, str);
+ op->cont (op->cls, ec);
else if (NULL != op->cb)
op->cb (op->cls, NULL, NULL, NULL);
else if (NULL != op->create_cont)
- op->create_cont (op->cls, (NULL == str) ? &op->pk : NULL, str);
+ op->create_cont (op->cls, (GNUNET_EC_NONE == ec) ? &op->pk : NULL, ec);
GNUNET_free (op);
}
@@ -476,80 +457,6 @@ handle_identity_update (void *cls,
}
-/**
- * Function called when we receive a set default message from the
- * service.
- *
- * @param cls closure
- * @param sdm message received
- * @return #GNUNET_OK if the message is well-formed
- */
-static int
-check_identity_set_default (void *cls,
- const struct SetDefaultMessage *sdm)
-{
- uint16_t size = ntohs (sdm->header.size) - sizeof(*sdm);
- uint16_t name_len = ntohs (sdm->name_len);
- const char *str = (const char *) &sdm[1];
-
- if ((size != name_len) || ((0 != name_len) && ('\0' != str[name_len - 1])))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- GNUNET_break (0 == ntohs (sdm->reserved));
- return GNUNET_OK;
-}
-
-
-/**
- * Type of a function to call when we receive a message
- * from the service.
- *
- * @param cls closure
- * @param sdm message received
- */
-static void
-handle_identity_set_default (void *cls,
- const struct SetDefaultMessage *sdm)
-{
- struct GNUNET_IDENTITY_Handle *h = cls;
- struct GNUNET_IDENTITY_Operation *op;
- struct GNUNET_HashCode id;
- struct GNUNET_IDENTITY_Ego *ego;
-
- GNUNET_CRYPTO_hash (&sdm->private_key,
- sizeof(sdm->private_key),
- &id);
- ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
- &id);
- if (NULL == ego)
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- op = h->op_head;
- if (NULL == op)
- {
- GNUNET_break (0);
- reschedule_connect (h);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received SET_DEFAULT message from identity service\n");
- GNUNET_CONTAINER_DLL_remove (h->op_head,
- h->op_tail,
- op);
- if (NULL != op->cb)
- op->cb (op->cls,
- ego,
- &ego->ctx,
- ego->name);
- GNUNET_free (op);
-}
-
-
/**
* Try again to connect to the identity service.
*
@@ -560,18 +467,14 @@ reconnect (void *cls)
{
struct GNUNET_IDENTITY_Handle *h = cls;
struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (identity_result_code,
- GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
- struct ResultCodeMessage,
- h),
+ GNUNET_MQ_hd_fixed_size (identity_result_code,
+ GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
+ struct ResultCodeMessage,
+ h),
GNUNET_MQ_hd_var_size (identity_update,
GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
struct UpdateMessage,
h),
- GNUNET_MQ_hd_var_size (identity_set_default,
- GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT,
- struct SetDefaultMessage,
- h),
GNUNET_MQ_handler_end ()
};
struct GNUNET_MQ_Envelope *env;
@@ -661,88 +564,6 @@ GNUNET_IDENTITY_ego_get_public_key (struct
GNUNET_IDENTITY_Ego *ego,
}
-struct GNUNET_IDENTITY_Operation *
-GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h,
- const char *service_name,
- GNUNET_IDENTITY_Callback cb,
- void *cb_cls)
-{
- struct GNUNET_IDENTITY_Operation *op;
- struct GNUNET_MQ_Envelope *env;
- struct GetDefaultMessage *gdm;
- size_t slen;
-
- if (NULL == h->mq)
- return NULL;
- GNUNET_assert (NULL != h->cb);
- slen = strlen (service_name) + 1;
- if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct GetDefaultMessage))
- {
- GNUNET_break (0);
- return NULL;
- }
- op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
- op->h = h;
- op->cb = cb;
- op->cls = cb_cls;
- GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- env =
- GNUNET_MQ_msg_extra (gdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT);
- gdm->name_len = htons (slen);
- gdm->reserved = htons (0);
- GNUNET_memcpy (&gdm[1], service_name, slen);
- GNUNET_MQ_send (h->mq, env);
- return op;
-}
-
-
-/**
- * Set the preferred/default identity for a service.
- *
- * @param h identity service to inform
- * @param service_name for which service is an identity set
- * @param ego new default identity to be set for this service
- * @param cont function to call once the operation finished
- * @param cont_cls closure for @a cont
- * @return handle to abort the operation
- */
-struct GNUNET_IDENTITY_Operation *
-GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h,
- const char *service_name,
- struct GNUNET_IDENTITY_Ego *ego,
- GNUNET_IDENTITY_Continuation cont,
- void *cont_cls)
-{
- struct GNUNET_IDENTITY_Operation *op;
- struct GNUNET_MQ_Envelope *env;
- struct SetDefaultMessage *sdm;
- size_t slen;
-
- if (NULL == h->mq)
- return NULL;
- GNUNET_assert (NULL != h->cb);
- slen = strlen (service_name) + 1;
- if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof(struct SetDefaultMessage))
- {
- GNUNET_break (0);
- return NULL;
- }
- op = GNUNET_new (struct GNUNET_IDENTITY_Operation);
- op->h = h;
- op->cont = cont;
- op->cls = cont_cls;
- GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
- env =
- GNUNET_MQ_msg_extra (sdm, slen, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
- sdm->name_len = htons (slen);
- sdm->reserved = htons (0);
- sdm->private_key = ego->pk;
- GNUNET_memcpy (&sdm[1], service_name, slen);
- GNUNET_MQ_send (h->mq, env);
- return op;
-}
-
-
struct GNUNET_IDENTITY_Operation *
GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *h,
const char *name,
@@ -1119,11 +940,13 @@ GNUNET_IDENTITY_sign_raw_ (const struct
{
case GNUNET_IDENTITY_TYPE_ECDSA:
return GNUNET_CRYPTO_ecdsa_sign_ (&(priv->ecdsa_key), purpose,
- (struct
GNUNET_CRYPTO_EcdsaSignature*)sig);
+ (struct
+ GNUNET_CRYPTO_EcdsaSignature*) sig);
break;
case GNUNET_IDENTITY_TYPE_EDDSA:
return GNUNET_CRYPTO_eddsa_sign_ (&(priv->eddsa_key), purpose,
- (struct
GNUNET_CRYPTO_EddsaSignature*)sig);
+ (struct
+ GNUNET_CRYPTO_EddsaSignature*) sig);
break;
default:
GNUNET_break (0);
@@ -1202,12 +1025,14 @@ GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose,
{
case GNUNET_IDENTITY_TYPE_ECDSA:
return GNUNET_CRYPTO_ecdsa_verify_ (purpose, validate,
- (struct
GNUNET_CRYPTO_EcdsaSignature*)sig,
+ (struct
+ GNUNET_CRYPTO_EcdsaSignature*) sig,
&(pub->ecdsa_key));
break;
case GNUNET_IDENTITY_TYPE_EDDSA:
return GNUNET_CRYPTO_eddsa_verify_ (purpose, validate,
- (struct
GNUNET_CRYPTO_EddsaSignature*)sig,
+ (struct
+ GNUNET_CRYPTO_EddsaSignature*) sig,
&(pub->eddsa_key));
break;
default:
diff --git a/src/identity/plugin_rest_identity.c
b/src/identity/plugin_rest_identity.c
index 5327d0b1f..17d214c15 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -48,11 +48,6 @@
*/
#define GNUNET_REST_API_NS_IDENTITY_NAME "/identity/name"
-/**
- * Identity Subsystem Namespace
- */
-#define GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM "/identity/subsystem"
-
/**
* Identity Namespace with sign specifier
*/
@@ -68,11 +63,6 @@
*/
#define GNUNET_REST_IDENTITY_PARAM_PRIVKEY "privkey"
-/**
- * Parameter subsystem
- */
-#define GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM "subsystem"
-
/**
* Parameter name
*/
@@ -83,16 +73,6 @@
*/
#define GNUNET_REST_IDENTITY_PARAM_NEWNAME "newname"
-/**
- * Error message Unknown Error
- */
-#define GNUNET_REST_IDENTITY_ERROR_UNKNOWN "Unknown Error"
-
-/**
- * Error message No identity found
- */
-#define GNUNET_REST_IDENTITY_NOT_FOUND "No identity found"
-
/**
* Error message Missing identity name
*/
@@ -258,14 +238,9 @@ struct RequestHandle
char *url;
/**
- * Error response message
- */
- char *emsg;
-
- /**
- * Response code
+ * Error code
*/
- int response_code;
+ enum GNUNET_ErrorCode ec;
};
/**
@@ -296,8 +271,6 @@ cleanup_handle (void *cls)
if (NULL != handle->url)
GNUNET_free (handle->url);
- if (NULL != handle->emsg)
- GNUNET_free (handle->emsg);
if (NULL != handle->name)
GNUNET_free (handle->name);
GNUNET_CONTAINER_DLL_remove (requests_head,
@@ -319,20 +292,20 @@ do_error (void *cls)
struct MHD_Response *resp;
json_t *json_error = json_object ();
char *response;
+ int response_code;
- if (NULL == handle->emsg)
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_ERROR_UNKNOWN);
-
- json_object_set_new (json_error, "error", json_string (handle->emsg));
-
- if (0 == handle->response_code)
- handle->response_code = MHD_HTTP_OK;
+ json_object_set_new (json_error, "error",
+ json_string (GNUNET_ErrorCode_get_hint (handle->ec)));
+ json_object_set_new (json_error, "error_code", json_integer (handle->ec));
+ response_code = GNUNET_ErrorCode_get_http_status (handle->ec);
+ if (0 == response_code)
+ response_code = MHD_HTTP_OK;
response = json_dumps (json_error, 0);
resp = GNUNET_REST_create_response (response);
GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
"Content-Type",
"application/json"));
- handle->proc (handle->proc_cls, resp, handle->response_code);
+ handle->proc (handle->proc_cls, resp, response_code);
json_decref (json_error);
GNUNET_free (response);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
@@ -377,101 +350,6 @@ get_egoentry (struct RequestHandle *handle, char *pubkey,
char *name)
}
-/**
- * Callback for GET Request with subsystem
- *
- * @param cls the RequestHandle
- * @param ego the Ego found
- * @param ctx the context
- * @param name the id of the ego
- */
-static void
-ego_get_for_subsystem (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *name)
-{
- struct RequestHandle *handle = cls;
- struct MHD_Response *resp;
- struct GNUNET_IDENTITY_PublicKey public_key;
- json_t *json_root;
- char *result_str;
- char *public_key_string;
-
- if (NULL == ego)
- {
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
- GNUNET_IDENTITY_ego_get_public_key (ego, &public_key);
- public_key_string = GNUNET_IDENTITY_public_key_to_string (&public_key);
-
- // create json with subsystem identity
- json_root = json_object ();
- json_object_set_new (json_root,
- GNUNET_REST_IDENTITY_PARAM_PUBKEY,
- json_string (public_key_string));
- json_object_set_new (json_root,
- GNUNET_REST_IDENTITY_PARAM_NAME,
- json_string (name));
-
- result_str = json_dumps (json_root, 0);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
- resp = GNUNET_REST_create_response (result_str);
- GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
- "Content-Type",
- "application/json"));
- json_decref (json_root);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- GNUNET_free (result_str);
- GNUNET_free (public_key_string);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
-}
-
-
-/**
- * Handle identity GET request for subsystem
- *
- * @param con_handle the connection handle
- * @param url the url
- * @param cls the RequestHandle
- */
-void
-ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
- const char *url,
- void *cls)
-{
- struct RequestHandle *handle = cls;
- char *subsystem;
-
- if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
- {
- handle->emsg = GNUNET_strdup ("Missing subsystem name");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- subsystem = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
- // requested default identity of subsystem
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem);
-
- handle->op = GNUNET_IDENTITY_get (identity_handle,
- subsystem,
- &ego_get_for_subsystem,
- handle);
-
- if (NULL == handle->op)
- {
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-}
-
-
/**
* Handle identity GET request - responds with all identities
*
@@ -603,8 +481,7 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -613,8 +490,7 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -643,8 +519,7 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -653,8 +528,7 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -667,27 +541,28 @@ ego_get_name (struct GNUNET_REST_RequestHandle
*con_handle,
* Processing finished
*
* @param cls request handle
- * @param emsg error message
+ * @param ec error code
*/
static void
-do_finished (void *cls, const char *emsg)
+do_finished (void *cls, enum GNUNET_ErrorCode ec)
{
struct RequestHandle *handle = cls;
struct MHD_Response *resp;
+ int response_code;
handle->op = NULL;
- if (NULL != emsg)
+ handle->ec = ec;
+ if (GNUNET_EC_NONE != ec)
{
- handle->emsg = GNUNET_strdup (emsg);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- if (0 == handle->response_code)
- {
- handle->response_code = MHD_HTTP_NO_CONTENT;
- }
+ if (GNUNET_EC_NONE == handle->ec)
+ response_code = MHD_HTTP_NO_CONTENT;
+ else
+ response_code = GNUNET_ErrorCode_get_http_status (ec);
resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, handle->response_code);
+ handle->proc (handle->proc_cls, resp, response_code);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
}
@@ -697,17 +572,17 @@ do_finished (void *cls, const char *emsg)
*
* @param cls request handle
* @param pk private key of the ego, or NULL on error
- * @param emsg error message
+ * @param ec error code
*/
static void
do_finished_create (void *cls,
const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct RequestHandle *handle = cls;
(void) pk;
- do_finished (handle, emsg);
+ do_finished (handle, ec);
}
@@ -720,8 +595,6 @@ do_finished_create (void *cls,
void
ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry)
{
- struct EgoEntry *ego_entry_tmp;
- struct MHD_Response *resp;
json_t *data_js;
json_error_t err;
char *newname;
@@ -731,7 +604,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
// if no data
if (0 >= handle->data_size)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -742,7 +615,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
if (NULL == data_js)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -757,7 +630,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
// Change name with pubkey or name identifier
if (0 != json_state)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -765,7 +638,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
if (NULL == newname)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -773,22 +646,12 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
if (0 >= strlen (newname))
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- ego_entry_tmp = get_egoentry (handle, NULL, newname);
- if (NULL != ego_entry_tmp)
- {
- // Ego with same name not allowed (even if its the ego we change)
- resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
- json_decref (data_js);
- return;
- }
handle->op = GNUNET_IDENTITY_rename (identity_handle,
ego_entry->identifier,
newname,
@@ -796,7 +659,7 @@ ego_edit (struct RequestHandle *handle, struct EgoEntry
*ego_entry)
handle);
if (NULL == handle->op)
{
- handle->emsg = GNUNET_strdup ("Rename failed");
+ handle->ec = GNUNET_EC_UNKNOWN;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -826,8 +689,7 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -836,8 +698,7 @@ ego_edit_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -866,8 +727,7 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -876,8 +736,7 @@ ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -886,115 +745,6 @@ ego_edit_name (struct GNUNET_REST_RequestHandle
*con_handle,
}
-/**
- * Handle identity subsystem PUT request with name
- *
- * @param con_handle the connection handle
- * @param url the url
- * @param cls the RequestHandle
- */
-void
-ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
- const char *url,
- void *cls)
-{
- struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry;
- json_t *data_js;
- json_error_t err;
- char *newsubsys;
- char *name;
- char term_data[handle->data_size + 1];
- int json_state;
-
- name = NULL;
-
- if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
- {
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
- ego_entry = get_egoentry (handle, NULL, name);
-
- if (NULL == ego_entry)
- {
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
- // if no data
- if (0 >= handle->data_size)
- {
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- // if not json
- term_data[handle->data_size] = '\0';
- GNUNET_memcpy (term_data, handle->data, handle->data_size);
- data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
-
- if (NULL == data_js)
- {
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
- newsubsys = NULL;
- // SUBSYSTEM
- json_state = 0;
- json_state = json_unpack (data_js,
- "{s:s!}",
- GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM,
- &newsubsys);
- // Change subsystem with pubkey or name identifier
- if (0 != json_state)
- {
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
-
- if (NULL == newsubsys)
- {
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
-
- if (0 >= strlen (newsubsys))
- {
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
-
- handle->response_code = MHD_HTTP_NO_CONTENT;
- handle->op = GNUNET_IDENTITY_set (identity_handle,
- newsubsys,
- ego_entry->ego,
- &do_finished,
- handle);
- if (NULL == handle->op)
- {
- handle->emsg = GNUNET_strdup ("Setting subsystem failed");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- json_decref (data_js);
- return;
-}
-
-
/**
* Handle identity POST request
*
@@ -1008,8 +758,6 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
void *cls)
{
struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry;
- struct MHD_Response *resp;
json_t *data_js;
json_error_t err;
char *egoname;
@@ -1027,7 +775,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
if (0 >= handle->data_size)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1036,7 +784,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
if (NULL == data_js)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_NO_DATA);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -1049,7 +797,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_REST_IDENTITY_PARAM_PRIVKEY, &privkey);
if (0 != json_unpack_state)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -1057,31 +805,19 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
if (NULL == egoname)
{
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
if (0 >= strlen (egoname))
{
+ handle->ec = GNUNET_EC_IDENTITY_INVALID;
json_decref (data_js);
- handle->emsg = GNUNET_strdup (GNUNET_REST_ERROR_DATA_INVALID);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
GNUNET_STRINGS_utf8_tolower (egoname, egoname);
- for (ego_entry = ego_head; NULL != ego_entry;
- ego_entry = ego_entry->next)
- {
- if (0 == strcasecmp (egoname, ego_entry->identifier))
- {
- resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
- json_decref (data_js);
- return;
- }
- }
handle->name = GNUNET_strdup (egoname);
if (NULL != privkey)
{
@@ -1095,7 +831,6 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle,
else
pk_ptr = NULL;
json_decref (data_js);
- handle->response_code = MHD_HTTP_CREATED;
handle->op = GNUNET_IDENTITY_create (identity_handle,
handle->name,
pk_ptr,
@@ -1125,8 +860,7 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1135,13 +869,11 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle
*con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->response_code = MHD_HTTP_NO_CONTENT;
handle->op = GNUNET_IDENTITY_delete (identity_handle,
ego_entry->identifier,
&do_finished,
@@ -1169,8 +901,7 @@ ego_delete_name (struct GNUNET_REST_RequestHandle
*con_handle,
if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_MISSING_NAME);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1179,13 +910,11 @@ ego_delete_name (struct GNUNET_REST_RequestHandle
*con_handle,
if (NULL == ego_entry)
{
- handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->response_code = MHD_HTTP_NO_CONTENT;
handle->op = GNUNET_IDENTITY_delete (identity_handle,
ego_entry->identifier,
&do_finished,
@@ -1211,16 +940,14 @@ ego_sign_data_cb (void *cls, struct GNUNET_IDENTITY_Ego
*ego)
if (ego == NULL)
{
- handle->response_code = MHD_HTTP_BAD_REQUEST;
- handle->emsg = GNUNET_strdup ("Ego not found");
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
if (ntohl (ego->pk.type) != GNUNET_IDENTITY_TYPE_EDDSA)
{
- handle->response_code = MHD_HTTP_BAD_REQUEST;
- handle->emsg = GNUNET_strdup ("Ego has to use an EdDSA key");
+ handle->ec = GNUNET_EC_IDENTITY_NOT_FOUND;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1230,8 +957,7 @@ ego_sign_data_cb (void *cls, struct GNUNET_IDENTITY_Ego
*ego)
strlen ( (char*) data),
&sig))
{
- handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
- handle->emsg = GNUNET_strdup ("Signature creation failed");
+ handle->ec = GNUNET_EC_UNKNOWN;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1287,8 +1013,7 @@ ego_sign_data (struct GNUNET_REST_RequestHandle
*con_handle,
handle->rest_handle->url_param_map,
&cache_key_data)))
{
- handle->response_code = MHD_HTTP_BAD_REQUEST;
- handle->emsg = GNUNET_strdup ("URL parameter missing");
+ handle->ec = GNUNET_EC_UNKNOWN;
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -1441,17 +1166,11 @@ rest_process_request (struct GNUNET_REST_RequestHandle
*rest_handle,
{ { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY,
&ego_get_pubkey },
{ MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name },
- { MHD_HTTP_METHOD_GET,
- GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
- &ego_get_subsystem },
{ MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_get_all },
{ MHD_HTTP_METHOD_PUT,
GNUNET_REST_API_NS_IDENTITY_PUBKEY,
&ego_edit_pubkey },
{ MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name },
- { MHD_HTTP_METHOD_PUT,
- GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM,
- &ego_edit_subsystem },
{ MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create },
{ MHD_HTTP_METHOD_DELETE,
GNUNET_REST_API_NS_IDENTITY_PUBKEY,
@@ -1464,7 +1183,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle
*rest_handle,
GNUNET_REST_HANDLER_END };
- handle->response_code = 0;
handle->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
handle->proc_cls = proc_cls;
handle->proc = proc;
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c
index 58c2c8d9e..2c44f73ba 100644
--- a/src/identity/test_identity.c
+++ b/src/identity/test_identity.c
@@ -189,13 +189,13 @@ notification_cb (void *cls,
* Continuation called from successful delete operation.
*
* @param cls NULL
- * @param emsg (should also be NULL)
+ * @param ec
*/
static void
-delete_cont (void *cls, const char *emsg)
+delete_cont (void *cls, enum GNUNET_ErrorCode ec)
{
op = NULL;
- CHECK (NULL == emsg);
+ CHECK (GNUNET_EC_NONE == ec);
res = 0;
end ();
}
@@ -217,12 +217,12 @@ finally_delete (void *cls)
* Continuation called from expected-to-fail rename operation.
*
* @param cls NULL
- * @param emsg (should also be NULL)
+ * @param ec
*/
static void
-fail_rename_cont (void *cls, const char *emsg)
+fail_rename_cont (void *cls, enum GNUNET_ErrorCode ec)
{
- CHECK (NULL != emsg);
+ CHECK (GNUNET_EC_NONE != ec);
op = NULL;
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&finally_delete,
@@ -234,12 +234,12 @@ fail_rename_cont (void *cls, const char *emsg)
* Continuation called from successful rename operation.
*
* @param cls NULL
- * @param emsg (should also be NULL)
+ * @param ec
*/
static void
-success_rename_cont (void *cls, const char *emsg)
+success_rename_cont (void *cls, enum GNUNET_ErrorCode ec)
{
- CHECK (NULL == emsg);
+ CHECK (GNUNET_EC_NONE == ec);
op = GNUNET_IDENTITY_rename (h, "test-id", "test", &fail_rename_cont, NULL);
}
@@ -249,15 +249,15 @@ success_rename_cont (void *cls, const char *emsg)
*
* @param cls NULL
* @param pk private key of the ego, or NULL on error
- * @param emsg error message
+ * @param ec
*/
static void
create_cb (void *cls,
const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
CHECK (NULL != pk);
- CHECK (NULL == emsg);
+ CHECK (GNUNET_EC_NONE == ec);
op =
GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL);
}
diff --git a/src/identity/test_identity_defaults.c
b/src/identity/test_identity_defaults.c
deleted file mode 100644
index 63db58a1a..000000000
--- a/src/identity/test_identity_defaults.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2013 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file identity/test_identity.c
- * @brief testcase for identity service
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_identity_service.h"
-#include "gnunet_testing_lib.h"
-
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
-
-
-/**
- * Return value from 'main'.
- */
-static int res;
-
-/**
- * Handle to identity service.
- */
-static struct GNUNET_IDENTITY_Handle *h;
-
-/**
- * Handle to identity operation.
- */
-static struct GNUNET_IDENTITY_Operation *op;
-
-/**
- * Handle for task for timeout termination.
- */
-static struct GNUNET_SCHEDULER_Task *endbadly_task;
-
-#define CHECK(cond) \
- do \
- { \
- if (! (cond)) \
- { \
- GNUNET_break (0); \
- end (); \
- return; \
- } \
- } while (0)
-
-
-/**
- * Clean up all resources used.
- */
-static void
-cleanup (void *cls)
-{
- (void) cls;
- if (NULL != op)
- {
- GNUNET_IDENTITY_cancel (op);
- op = NULL;
- }
- if (NULL != h)
- {
- GNUNET_IDENTITY_disconnect (h);
- h = NULL;
- }
-}
-
-
-/**
- * Termiante the testcase (failure).
- *
- * @param cls NULL
- */
-static void
-endbadly (void *cls)
-{
- GNUNET_SCHEDULER_shutdown ();
- res = 1;
-}
-
-
-/**
- * Termiante the testcase.
- */
-static void
-end ()
-{
- if (NULL != endbadly_task)
- {
- GNUNET_SCHEDULER_cancel (endbadly_task);
- endbadly_task = NULL;
- }
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-/**
- * Continuation called from successful delete operation.
- *
- * @param cls NULL
- * @param emsg (should also be NULL)
- */
-static void
-delete_cont (void *cls, const char *emsg)
-{
- op = NULL;
- CHECK (NULL == emsg);
- res = 0;
- end ();
-}
-
-
-/**
- * Continuation called from expected-to-fail rename operation.
- *
- * @param cls NULL
- * @param emsg (should also be NULL)
- */
-static void
-get_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- op = NULL;
- CHECK (NULL != ego);
- CHECK (NULL != identifier);
- CHECK (0 == strcmp (identifier, "test-id"));
- op = GNUNET_IDENTITY_delete (h, "test-id", &delete_cont, NULL);
-}
-
-
-/**
- * Called with events about egos.
- *
- * @param cls NULL
- * @param ego ego handle
- * @param ego_ctx context for application to store data for this ego
- * (during the lifetime of this process, initially NULL)
- * @param identifier identifier assigned by the user for this ego,
- * NULL if the user just deleted the ego and it
- * must thus no longer be used
- */
-static void
-dummy_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- (void) cls;
- (void) ego;
- (void) ctx;
- (void) identifier;
-}
-
-
-/**
- * Main function of the test, run from scheduler.
- *
- * @param cls NULL
- * @param cfg configuration we use (also to connect to identity service)
- * @param peer handle to access more of the peer (not used)
- */
-static void
-run_get (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
- GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
- h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL);
- CHECK (NULL != h);
- op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL);
-}
-
-
-/**
- * Continuation called from successful rename operation.
- *
- * @param cls NULL
- * @param emsg (should also be NULL)
- */
-static void
-success_set_cont (void *cls, const char *emsg)
-{
- op = NULL;
- CHECK (NULL == emsg);
- end ();
-}
-
-
-/**
- * Called with events about egos.
- *
- * @param cls NULL
- * @param ego ego handle
- * @param ego_ctx context for application to store data for this ego
- * (during the lifetime of this process, initially NULL)
- * @param identifier identifier assigned by the user for this ego,
- * NULL if the user just deleted the ego and it
- * must thus no longer be used
- */
-static void
-notification_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- if (NULL == ego)
- return; /* skip first call */
- if (NULL == identifier)
- return; /* deletion / shutdown */
- op = GNUNET_IDENTITY_set (h, "test-service", ego, &success_set_cont, NULL);
-}
-
-
-/**
- * Called with events about created ego.
- *
- * @param cls NULL
- * @param pk private key of the ego, or NULL on error
- * @param emsg error message
- */
-static void
-create_cb (void *cls,
- const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
-{
- CHECK (NULL == emsg);
- CHECK (NULL != pk);
- op = NULL;
-}
-
-
-/**
- * Main function of the test, run from scheduler.
- *
- * @param cls NULL
- * @param cfg configuration we use (also to connect to identity service)
- * @param peer handle to access more of the peer (not used)
- */
-static void
-run_set (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
-{
- endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
- GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
- h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
- CHECK (NULL != h);
- op = GNUNET_IDENTITY_create (h,
- "test-id",
- NULL,
- GNUNET_IDENTITY_TYPE_ECDSA,
- &create_cb, NULL);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- GNUNET_DISK_purge_cfg_dir ("test_identity.conf",
- "GNUNET_TEST_HOME");
- res = 1;
- if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
- "identity",
- "test_identity.conf",
- &run_set,
- NULL))
- return 1;
- if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
- "identity",
- "test_identity.conf",
- &run_get,
- NULL))
- return 1;
- GNUNET_DISK_purge_cfg_dir ("test_identity.conf",
- "GNUNET_TEST_HOME");
- return res;
-}
-
-
-/* end of test_identity_defaults.c */
diff --git a/src/identity/test_identity_messages.sh
b/src/identity/test_identity_messages.sh
index 250c6a6f1..daecb1ed2 100755
--- a/src/identity/test_identity_messages.sh
+++ b/src/identity/test_identity_messages.sh
@@ -23,12 +23,12 @@ gnunet-identity -C recipientego -c test_identity.conf
RECIPIENT_KEY=$(gnunet-identity -d -e recipientego -q -c test_identity.conf)
MSG_ENC=$(gnunet-identity -W "$TEST_MSG" -k $RECIPIENT_KEY -c
test_identity.conf)
MSG_DEC=$(gnunet-identity -R "$MSG_ENC" -e recipientego -c test_identity.conf)
-
-if test "$TEST_MSG" != "$MSG_DEC"
+gnunet-identity -D recipientego -c test_identity.conf
+gnunet-arm -e -c test_identity.conf
+if [ "$TEST_MSG" != "$MSG_DEC" ]
then
echo "Failed - $TEST_MSG != $MSG_DEC"
exit 1
fi
-gnunet-identity -D recipientego -c test_identity.conf
-gnunet-arm -e -c test_identity.conf
+
diff --git a/src/include/gnunet_identity_service.h
b/src/include/gnunet_identity_service.h
index c54f6abf8..d234ff552 100644
--- a/src/include/gnunet_identity_service.h
+++ b/src/include/gnunet_identity_service.h
@@ -280,11 +280,11 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *id,
* been completed.
*
* @param cls closure
- * @param emsg NULL on success, otherwise an error message
+ * @param ec the #GNUNET_ErrorCode
*/
typedef void
(*GNUNET_IDENTITY_Continuation) (void *cls,
- const char *emsg);
+ enum GNUNET_ErrorCode ec);
/**
@@ -320,13 +320,13 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle
*h);
*
* @param cls closure
* @param pk private key, NULL on error
- * @param emsg error message, NULL on success
+ * @param ec the #GNUNET_ErrorCode
*/
typedef void
(*GNUNET_IDENTITY_CreateContinuation) (
void *cls,
const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg);
+ enum GNUNET_ErrorCode ec);
/**
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c
b/src/messenger/gnunet-service-messenger_ego_store.c
index 8250d0902..434c418e5 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.c
+++ b/src/messenger/gnunet-service-messenger_ego_store.c
@@ -139,15 +139,19 @@ iterate_create_ego (void *cls,
static void
callback_ego_create (void *cls,
const struct GNUNET_IDENTITY_PrivateKey *key,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
GNUNET_assert (element->identifier);
- if (emsg)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ /**
+ * FIXME: This is dangerous, please handle errors
+ */
+ if (GNUNET_EC_NONE != ec)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
+ GNUNET_ErrorCode_get_hint (ec));
if (key)
{
@@ -360,15 +364,19 @@ delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
static void
callback_ego_rename (void *cls,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
GNUNET_assert (element->identifier);
- if (emsg)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ /**
+ * FIXME: Dangerous, handle error
+ */
+ if (GNUNET_EC_NONE != ec)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
+ GNUNET_ErrorCode_get_hint (ec));
struct GNUNET_HashCode hash;
GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
&hash);
@@ -426,15 +434,19 @@ rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
static void
callback_ego_delete (void *cls,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
GNUNET_assert (element->identifier);
- if (emsg)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ /**
+ * FIXME: Dangerous, handle error
+ */
+ if (GNUNET_EC_NONE != ec)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
+ GNUNET_ErrorCode_get_hint (ec));
create_store_ego (store, element->identifier);
diff --git a/src/namestore/gnunet-namestore-zonefile.c
b/src/namestore/gnunet-namestore-zonefile.c
index 8820dcdfa..d9331aa32 100644
--- a/src/namestore/gnunet-namestore-zonefile.c
+++ b/src/namestore/gnunet-namestore-zonefile.c
@@ -283,12 +283,12 @@ parse_origin (char *token, char *origin)
static void
origin_create_cb (void *cls, const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
id_op = NULL;
- if (NULL != emsg)
+ if (GNUNET_EC_NONE != ec)
{
- fprintf (stderr, "Error: %s\n", emsg);
+ fprintf (stderr, "Error: %s\n", GNUNET_ErrorCode_get_hint (ec));
ret = 1;
GNUNET_SCHEDULER_shutdown ();
return;
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index d6154f0aa..843158c68 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1195,6 +1195,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
unsigned int rd_count;
struct GNUNET_GNSRECORD_Data *rd;
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("replace"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
if (NULL == name)
{
fprintf (stderr,
@@ -1247,6 +1257,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
if (add)
{
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("add"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
if (NULL == name)
{
fprintf (stderr,
@@ -1334,6 +1354,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
}
if (del)
{
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("del"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
if (NULL == name)
{
fprintf (stderr,
@@ -1367,6 +1397,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
}
else if (purge_zone)
{
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("purge-zone"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns,
&zone_pkey,
&zone_iteration_error_cb,
@@ -1381,6 +1421,17 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
else if (list || list_orphaned)
{
if (NULL != name)
+ {
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("list"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
get_qe = GNUNET_NAMESTORE_records_lookup (ns,
&zone_pkey,
name,
@@ -1388,6 +1439,7 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
NULL,
&display_record_lookup,
NULL);
+ }
else
list_it = GNUNET_NAMESTORE_zone_iteration_start2 (ns,
(NULL == ego_name) ?
@@ -1404,6 +1456,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_IDENTITY_PublicKey pubkey;
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("reverse-pkey"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
if (GNUNET_OK !=
GNUNET_IDENTITY_public_key_from_string (reverse_pkey,
&pubkey))
@@ -1426,6 +1488,16 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
char sh[105];
char sname[64];
struct GNUNET_IDENTITY_PublicKey pkey;
+ if (NULL == ego_name)
+ {
+ fprintf (stderr,
+ _ ("Missing option `%s' for operation `%s'\n"),
+ "-z",
+ _ ("uri"));
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
memset (sh, 0, 105);
memset (sname, 0, 64);
@@ -1476,7 +1548,8 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
if (monitor)
{
zm = GNUNET_NAMESTORE_zone_monitor_start2 (cfg,
- &zone_pkey,
+ (NULL != ego_name) ?
+ &zone_pkey : NULL,
GNUNET_YES,
&monitor_error_cb,
NULL,
@@ -1522,44 +1595,6 @@ identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
}
-/**
- * Function called with the default ego to be used for GNS
- * operations. Used if the user did not specify a zone via
- * command-line or environment variables.
- *
- * @param cls NULL
- * @param ego default ego, NULL for none
- * @param ctx NULL
- * @param name unused
- */
-static void
-default_ego_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *name)
-{
- const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
-
- (void) ctx;
- (void) name;
- get_default = NULL;
- if (NULL == ego)
- {
- fprintf (stderr,
- _ ("No default identity configured for `namestore' subsystem\n"
- "Run gnunet-identity -s namestore -e $NAME to set the default
to $NAME\n"
- "Run gnunet-identity -d to get a list of choices for
$NAME\n"));
- GNUNET_SCHEDULER_shutdown ();
- ret = -1;
- return;
- }
- else
- {
- identity_cb ((void *) cfg, ego);
- }
-}
-
-
/**
* Function called with ALL of the egos known to the
* identity service, used on startup if the user did
@@ -1597,11 +1632,10 @@ id_connect_cb (void *cls,
}
if (NULL != ego)
return;
- if (NULL != ego_name)
- el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *)
cfg);
+ if (NULL == ego_name)
+ run_with_zone_pkey (cfg);
else
- get_default =
- GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
+ el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *)
cfg);
}
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c
index b5f5f4922..1f91e0ee2 100644
--- a/src/reclaim/gnunet-did.c
+++ b/src/reclaim/gnunet-did.c
@@ -336,11 +336,11 @@ create_did_cb (enum GNUNET_GenericReturnValue status,
void *cls)
static void
create_did_ego_create_cb (void *cls,
const struct GNUNET_IDENTITY_PrivateKey *pk,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
- if (emsg != NULL)
+ if (GNUNET_EC_NONE != ec)
{
- printf ("%s\n", emsg);
+ printf ("%s\n", GNUNET_ErrorCode_get_hint (ec));
GNUNET_SCHEDULER_add_now (&cleanup, NULL);
ret = 1;
return;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: IDENTITY/NAMESTORE:,
gnunet <=