gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (f409153ec -> 0263818b1)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (f409153ec -> 0263818b1)
Date: Mon, 10 Jun 2019 06:51:05 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from f409153ec eliminate unnecessary ec-mul operation from gnunet-namestore
     new 378e6561f adding comments, restructuring
     new 0263818b1 add option to pass private key via environment variable

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/man/gnunet-namestore.1       |   4 +-
 src/namestore/gnunet-namestore.c | 138 +++++++++++++++++++++++++++------------
 2 files changed, 98 insertions(+), 44 deletions(-)

diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1
index 98d1839b9..7f6e0bcb6 100644
--- a/doc/man/gnunet-namestore.1
+++ b/doc/man/gnunet-namestore.1
@@ -105,7 +105,7 @@ Value to store or remove from the GNS zone.
 Specific format depends on the record type.
 A records expect a dotted decimal IPv4 address, AAAA records an IPv6 address, 
PKEY a public key in GNUnet's printable format, and CNAME and NS records should 
be a domain name.
 .It Fl z Ar EGO | Fl \-zone= Ns Ar EGO
-Specifies the name of the ego controlling the private key for the zone 
(mandatory option).
+Specifies the name of the ego controlling the private key for the zone. If not 
provided, we will attempt to use the default identity set for the "namestore". 
Alternatively, a private key may be passed in Base32-encoding using the 
GNUNET_NAMESTORE_EGO_PRIVATE_KEY environment variable. The latter is useful to 
improve performance of tools like Ascension as it allows the command to skip 
IPC with the identity management subsystem.
 .El
 .\".Sh EXAMPLES
 .\".Sh FILES
@@ -113,7 +113,7 @@ Specifies the name of the ego controlling the private key 
for the zone (mandator
 .Xr gnunet-gns 1 ,
 .Xr gnunet-namestore-gtk 1
 .sp
-The full documentation for gnunet is maintained as a Texinfo manual.
+The full documentation for GNUnet is maintained as a Texinfo manual.
 If the
 .Xr info 1
 and gnunet programs are properly installed at your site, the command
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index e161a741d..26b5a704b 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -972,45 +972,16 @@ replace_cont (void *cls, int success, const char *emsg)
 
 
 /**
- * Callback invoked from identity service with ego information.
- * An @a ego of NULL means the ego was not found.
+ * We have obtained the zone's private key, so now process
+ * the main commands using it.
  *
- * @param cls closure with the configuration
- * @param ego an ego known to identity service, or NULL
+ * @param cfg configuration to use
  */
 static void
-identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
+run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
   struct GNUNET_GNSRECORD_Data rd;
 
-  el = NULL;
-  if ((NULL != name) && (0 != strchr (name, '.')))
-  {
-    fprintf (stderr,
-             _ ("Label `%s' contains `.' which is not allowed\n"),
-             name);
-    GNUNET_SCHEDULER_shutdown ();
-    ret = -1;
-    return;
-  }
-
-  if (NULL == ego)
-  {
-    if (NULL != ego_name)
-    {
-      fprintf (stderr,
-               _ ("Ego `%s' not known to identity service\n"),
-               ego_name);
-    }
-    GNUNET_SCHEDULER_shutdown ();
-    ret = -1;
-    return;
-  }
-  zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
-  GNUNET_free_non_null (ego_name);
-  ego_name = NULL;
-
   if (! (add | del | list | (NULL != nickstring) | (NULL != uri) |
          (NULL != reverse_pkey) | (NULL != recordset)))
   {
@@ -1265,13 +1236,66 @@ identity_cb (void *cls, const struct 
GNUNET_IDENTITY_Ego *ego)
 }
 
 
+/**
+ * Callback invoked from identity service with ego information.
+ * An @a ego of NULL means the ego was not found.
+ *
+ * @param cls closure with the configuration
+ * @param ego an ego known to identity service, or NULL
+ */
+static void
+identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
+{
+  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
+  el = NULL;
+  if ((NULL != name) && (0 != strchr (name, '.')))
+  {
+    fprintf (stderr,
+             _ ("Label `%s' contains `.' which is not allowed\n"),
+             name);
+    GNUNET_SCHEDULER_shutdown ();
+    ret = -1;
+    return;
+  }
+
+  if (NULL == ego)
+  {
+    if (NULL != ego_name)
+    {
+      fprintf (stderr,
+               _ ("Ego `%s' not known to identity service\n"),
+               ego_name);
+    }
+    GNUNET_SCHEDULER_shutdown ();
+    ret = -1;
+    return;
+  }
+  zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
+  GNUNET_free_non_null (ego_name);
+  ego_name = NULL;
+  run_with_zone_pkey (cfg);
+}
+
+
+/**
+ * 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)
 {
-  (void) cls;
+  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
+
   (void) ctx;
   (void) name;
   get_default = NULL;
@@ -1284,11 +1308,23 @@ default_ego_cb (void *cls,
   }
   else
   {
-    identity_cb (cls, ego);
+    identity_cb ((void *) cfg, ego);
   }
 }
 
 
+/**
+ * Function called with ALL of the egos known to the
+ * identity service, used on startup if the user did
+ * not specify a zone on the command-line.
+ * Once the iteration is done (@a ego is NULL), we
+ * ask for the default ego for "namestore".
+ *
+ * @param cls a `struct GNUNET_CONFIGURATION_Handle`
+ * @param ego an ego, NULL for end of iteration
+ * @param ctx NULL
+ * @param name name associated with @a ego
+ */
 static void
 id_connect_cb (void *cls,
                struct GNUNET_IDENTITY_Ego *ego,
@@ -1297,14 +1333,12 @@ id_connect_cb (void *cls,
 {
   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
 
-  (void) cls;
   (void) ctx;
   (void) name;
-  if (NULL == ego)
-  {
-    get_default =
-      GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
-  }
+  if (NULL != ego)
+    return;
+  get_default =
+    GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
 }
 
 
@@ -1322,6 +1356,8 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  const char *pkey_str;
+
   (void) cls;
   (void) args;
   (void) cfgfile;
@@ -1334,7 +1370,25 @@ run (void *cls,
     uri = GNUNET_strdup (args[0]);
 
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg);
-
+  pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
+  if (NULL != pkey_str)
+  {
+    if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str,
+                                                    strlen (pkey_str),
+                                                    &zone_pkey,
+                                                    sizeof (zone_pkey)))
+    {
+      fprintf (stderr,
+               "Malformed private key `%s' in $%s\n",
+               pkey_str,
+               "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
+      ret = 1;
+      GNUNET_SCHEDULER_shutdown ();
+      return;
+    }
+    run_with_zone_pkey (cfg);
+    return;
+  }
   if (NULL == ego_name)
   {
     idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]