summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-10 06:50:19 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-10 06:50:19 +0200
commit0263818b1ec7ef1115196002f9ba70e5cb766bf4 (patch)
tree55fe9c04e28ee92d297ee67c3b78cff715f4c14a
parent378e6561f3c706ef0b71e09574af26940a9be3fa (diff)
add option to pass private key via environment variable
-rw-r--r--doc/man/gnunet-namestore.14
-rw-r--r--src/namestore/gnunet-namestore.c22
2 files changed, 23 insertions, 3 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 b678086df..26b5a704b 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1356,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;
@@ -1368,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);