]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Allow searching for family keys in a FamilyKeyDirectory
authorNick Mathewson <nickm@torproject.org>
Thu, 27 Mar 2025 18:41:18 +0000 (14:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 27 Mar 2025 18:53:56 +0000 (14:53 -0400)
doc/man/tor.1.txt
src/app/config/config.c
src/app/config/or_options_st.h
src/app/main/main.c
src/feature/relay/routerkeys.c

index 1b8625dda3d8114fe22b0069a73bdec53ddbf1d2..eb1b10520262700c71bb6a598c6bd3563fbf59f3 100644 (file)
@@ -2502,6 +2502,10 @@ is non-zero):
     (Note that if the seccomp2 Sandbox feature is enabled,
     it is not possible to change the key filenames while Tor is running.)
 
+[[FamilyKeyDirectory]] **FamilyKeyDirectory** __directory__:
+    Configure a directory to use, in place of the key directory,
+    when searching for family ID keys.
+
 [[Nickname]] **Nickname** __name__::
     Set the server's nickname to \'name'. Nicknames must be between 1 and 19
     characters inclusive, and must contain only the characters [a-zA-Z0-9].
index 4a09cef3fb5c082951fdcb7f1fd8a03dfc288fcc..8c20e844d14e9d593acc8dde0209ff39bb12663c 100644 (file)
@@ -471,6 +471,8 @@ static const config_var_t option_vars_[] = {
 
   OBSOLETE("FallbackNetworkstatusFile"),
   VAR("FamilyId",                LINELIST, FamilyId_lines,   NULL),
+  VAR_IMMUTABLE("FamilyKeyDirectory",
+                FILENAME, FamilyKeyDirectory_option, NULL),
   V(FascistFirewall,             BOOL,     "0"),
   V(FirewallPorts,               CSV,      ""),
   OBSOLETE("FastFirstHopPK"),
@@ -1045,6 +1047,7 @@ options_clear_cb(const config_mgr_t *mgr, void *opts)
   }
   tor_free(options->DataDirectory);
   tor_free(options->CacheDirectory);
+  tor_free(options->FamilyKeyDirectory);
   tor_free(options->KeyDirectory);
   tor_free(options->BridgePassword_AuthDigest_);
   tor_free(options->command_arg);
@@ -6989,6 +6992,17 @@ validate_data_directories(or_options_t *options)
     options->CacheDirectory = tor_strdup(options->DataDirectory);
   }
 
+  tor_free(options->FamilyKeyDirectory);
+  if (options->FamilyKeyDirectory_option) {
+    options->FamilyKeyDirectory =
+      get_data_directory(options->FamilyKeyDirectory_option);
+    if (!options->FamilyKeyDirectory)
+      return -1;
+  } else {
+    /* Default to the key directory. */
+    options->FamilyKeyDirectory = tor_strdup(options->KeyDirectory);
+  }
+
   return 0;
 }
 
index 698b954ef0b51ae85d2e8ba7187b4440afa9441a..c36cb7331a281508a8850b67968d3da6c5edc19b 100644 (file)
@@ -89,6 +89,10 @@ struct or_options_t {
   char *KeyDirectory; /**< Where to store keys data, as modified. */
   int KeyDirectoryGroupReadable; /**< Boolean: Is the KeyDirectory g+r? */
 
+  char *FamilyKeyDirectory_option; /**< Where to look for family ID keys,
+                                    * as configured by the user. */
+  char *FamilyKeyDirectory; /**< Where to look for family ID keys. */
+
   char *CacheDirectory_option; /**< Where to store cached data, as
                                * configured by the user. */
   char *CacheDirectory; /**< Where to store cached data, as modified. */
index e2ac5174bf2290703ccd7adae8d3e1da2edeb7bf..36e7bce599adb9ddb23b3ff1fef6505faa91d073 100644 (file)
@@ -960,7 +960,7 @@ sandbox_init_filter(void)
 #ifdef HAVE_MODULE_RELAY
   {
     smartlist_t *family_id_files =
-      list_family_key_files(options, options->KeyDirectory);
+      list_family_key_files(options, options->FamilyKeyDirectory);
 
     SMARTLIST_FOREACH(family_id_files, const char *, fn,
                       OPEN(fn));
index b7a5ddabceff1b454c5b61ad34acb0f34d99091f..fc5a5376d405f9430165d14c7ca86b84864eec02 100644 (file)
@@ -908,7 +908,7 @@ load_family_id_keys(const or_options_t *options,
                     const networkstatus_t *ns)
 {
   if (options->FamilyIds) {
-    if (load_family_id_keys_impl(options, options->KeyDirectory) < 0)
+    if (load_family_id_keys_impl(options, options->FamilyKeyDirectory) < 0)
       return -1;
 
     bool any_missing = false;