]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make --keygen-family save a key ID file too.
authorNick Mathewson <nickm@torproject.org>
Tue, 25 Feb 2025 17:16:57 +0000 (12:16 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 6 Mar 2025 14:41:54 +0000 (09:41 -0500)
(Requested by @nusenu)

doc/man/tor.1.txt
src/app/main/main.c

index efe78f2004acd3b412bd7f4d97f14c397484fe8b..87fe0378c0fdc6744203ca39e7c6e449ab060319 100644 (file)
@@ -172,6 +172,7 @@ The following options in this section are only recognized on the
     Generate a new family ID key in __basename__`.secret_family_key`.
     To use this key, install it on every relay in your family.
     (Put it in the relay's `KeyDirectory`.)
+    Also, store the corresponding family ID in __basename__`.public_family_id`.
     Then enable the corresponding FamilyID option on your relays.
     See https://community.torproject.org/relay/setup/post-install/family-ids/
     for more information.
index ec1571f0ba46bef39d2d266b750a74dd16684a14..01db726f00794d0b05b456b4264669432fc98ee6 100644 (file)
@@ -836,23 +836,30 @@ static int
 do_keygen_family(const char *fname_base)
 {
   ed25519_public_key_t pk;
-  char *fname = NULL;
+  char *fname_key = NULL, *fname_id = NULL, *id_contents = NULL;
   int r = -1;
 
   if (BUG(!fname_base))
     goto done;
 
-  tor_asprintf(&fname, "%s.secret_family_key", fname_base);
+  tor_asprintf(&fname_key, "%s.secret_family_key", fname_base);
+  tor_asprintf(&fname_id, "%s.public_family_id", fname_base);
 
-  if (create_family_id_key(fname, &pk) < 0)
+  if (create_family_id_key(fname_key, &pk) < 0)
+    goto done;
+  tor_asprintf(&id_contents, "%s\n", ed25519_fmt(&pk));
+  if (write_str_to_file(fname_id, id_contents, 0) < 0)
     goto done;
 
-  printf("# Generated %s\n", fname);
+  printf("# Generated %s\n", fname_key);
   printf("FamilyId %s\n", ed25519_fmt(&pk));
+
   r = 0;
 
  done:
-  tor_free(fname);
+  tor_free(fname_key);
+  tor_free(fname_id);
+  tor_free(id_contents);
   return r;
 }