From 2115a54b4ab91d6d573691fc7368fcb8a2db32af Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 5 Apr 2018 14:27:30 -0400 Subject: [PATCH] mod: Move dirauth specific files to its own module This is a pretty big commit but it only moves these files to src/or/dirauth: dircollate.c dirvote.c shared_random.c shared_random_state.c dircollate.h dirvote.h shared_random.h shared_random_state.h Then many files are modified to change the include line for those header files that have moved into a new directory. Without using --disable-module-dirauth, everything builds fine. When using the flag to disable the module, tor doesn't build due to linking errors. This will be addressed in the next commit(s). No code behavior change. Signed-off-by: David Goulet --- src/or/config.c | 3 ++- src/or/control.c | 2 +- src/or/{ => dirauth}/dircollate.c | 0 src/or/{ => dirauth}/dircollate.h | 0 src/or/{ => dirauth}/dirvote.c | 0 src/or/{ => dirauth}/dirvote.h | 0 src/or/{ => dirauth}/shared_random.c | 3 ++- src/or/{ => dirauth}/shared_random.h | 0 src/or/{ => dirauth}/shared_random_state.c | 3 ++- src/or/{ => dirauth}/shared_random_state.h | 0 src/or/directory.c | 5 +++-- src/or/dirserv.c | 3 ++- src/or/hs_common.c | 4 ++-- src/or/hs_service.c | 2 +- src/or/include.am | 20 ++++++++++---------- src/or/main.c | 5 +++-- src/or/networkstatus.c | 5 +++-- src/or/routerlist.c | 3 ++- src/or/routerparse.c | 5 +++-- src/test/test_config.c | 2 +- src/test/test_dir.c | 4 ++-- src/test/test_dir_common.c | 2 +- src/test/test_dir_handle_get.c | 2 +- src/test/test_hs_common.c | 4 ++-- src/test/test_hs_service.c | 4 ++-- src/test/test_microdesc.c | 2 +- src/test/test_routerlist.c | 4 ++-- src/test/test_shared_random.c | 6 +++--- 28 files changed, 51 insertions(+), 42 deletions(-) rename src/or/{ => dirauth}/dircollate.c (100%) rename src/or/{ => dirauth}/dircollate.h (100%) rename src/or/{ => dirauth}/dirvote.c (100%) rename src/or/{ => dirauth}/dirvote.h (100%) rename src/or/{ => dirauth}/shared_random.c (99%) rename src/or/{ => dirauth}/shared_random.h (100%) rename src/or/{ => dirauth}/shared_random_state.c (99%) rename src/or/{ => dirauth}/shared_random_state.h (100%) diff --git a/src/or/config.c b/src/or/config.c index 87a3588db7..8f5839e2d5 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -79,7 +79,6 @@ #include "confparse.h" #include "cpuworker.h" #include "dirserv.h" -#include "dirvote.h" #include "dns.h" #include "dos.h" #include "entrynodes.h" @@ -110,6 +109,8 @@ #include "procmon.h" +#include "dirauth/dirvote.h" + #ifdef HAVE_SYSTEMD # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse diff --git a/src/or/control.c b/src/or/control.c index dda8872182..3e643c2d76 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -76,7 +76,7 @@ #include "router.h" #include "routerlist.h" #include "routerparse.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #ifndef _WIN32 #include diff --git a/src/or/dircollate.c b/src/or/dirauth/dircollate.c similarity index 100% rename from src/or/dircollate.c rename to src/or/dirauth/dircollate.c diff --git a/src/or/dircollate.h b/src/or/dirauth/dircollate.h similarity index 100% rename from src/or/dircollate.h rename to src/or/dirauth/dircollate.h diff --git a/src/or/dirvote.c b/src/or/dirauth/dirvote.c similarity index 100% rename from src/or/dirvote.c rename to src/or/dirauth/dirvote.c diff --git a/src/or/dirvote.h b/src/or/dirauth/dirvote.h similarity index 100% rename from src/or/dirvote.h rename to src/or/dirauth/dirvote.h diff --git a/src/or/shared_random.c b/src/or/dirauth/shared_random.c similarity index 99% rename from src/or/shared_random.c rename to src/or/dirauth/shared_random.c index 13416d6bc7..e9644adf9e 100644 --- a/src/or/shared_random.c +++ b/src/or/dirauth/shared_random.c @@ -91,7 +91,6 @@ #include "shared_random.h" #include "config.h" #include "confparse.h" -#include "dirvote.h" #include "networkstatus.h" #include "routerkeys.h" #include "router.h" @@ -99,6 +98,8 @@ #include "shared_random_state.h" #include "util.h" +#include "dirauth/dirvote.h" + /* String prefix of shared random values in votes/consensuses. */ static const char previous_srv_str[] = "shared-rand-previous-value"; static const char current_srv_str[] = "shared-rand-current-value"; diff --git a/src/or/shared_random.h b/src/or/dirauth/shared_random.h similarity index 100% rename from src/or/shared_random.h rename to src/or/dirauth/shared_random.h diff --git a/src/or/shared_random_state.c b/src/or/dirauth/shared_random_state.c similarity index 99% rename from src/or/shared_random_state.c rename to src/or/dirauth/shared_random_state.c index 53782af59a..11d7a06378 100644 --- a/src/or/shared_random_state.c +++ b/src/or/dirauth/shared_random_state.c @@ -14,11 +14,12 @@ #include "shared_random.h" #include "config.h" #include "confparse.h" -#include "dirvote.h" #include "networkstatus.h" #include "router.h" #include "shared_random_state.h" +#include "dirauth/dirvote.h" + /* Default filename of the shared random state on disk. */ static const char default_fname[] = "sr-state"; diff --git a/src/or/shared_random_state.h b/src/or/dirauth/shared_random_state.h similarity index 100% rename from src/or/shared_random_state.h rename to src/or/dirauth/shared_random_state.h diff --git a/src/or/directory.c b/src/or/directory.c index c419b61d02..8a343ac02c 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -20,7 +20,6 @@ #include "compat.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "entrynodes.h" #include "geoip.h" #include "hs_cache.h" @@ -41,7 +40,7 @@ #include "routerlist.h" #include "routerparse.h" #include "routerset.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) #if !defined(OpenBSD) @@ -49,6 +48,8 @@ #endif #endif +#include "dirauth/dirvote.h" + /** * \file directory.c * \brief Code to send and fetch information from directory authorities and diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 68727f0718..c20e2966c3 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -18,7 +18,6 @@ #include "control.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "hibernate.h" #include "keypin.h" #include "main.h" @@ -34,6 +33,8 @@ #include "routerset.h" #include "torcert.h" +#include "dirauth/dirvote.h" + /** * \file dirserv.c * \brief Directory server core implementation. Manages directory diff --git a/src/or/hs_common.c b/src/or/hs_common.c index 24eb7a104a..fc7bc5729b 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -28,8 +28,8 @@ #include "rendservice.h" #include "routerset.h" #include "router.h" -#include "shared_random.h" -#include "shared_random_state.h" +#include "dirauth/shared_random.h" +#include "dirauth/shared_random_state.h" /* Trunnel */ #include "ed25519_cert.h" diff --git a/src/or/hs_service.c b/src/or/hs_service.c index f6c7e3cd81..ebb58f7f68 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -24,7 +24,7 @@ #include "router.h" #include "routerkeys.h" #include "routerlist.h" -#include "shared_random_state.h" +#include "dirauth/shared_random_state.h" #include "statefile.h" #include "hs_circuit.h" diff --git a/src/or/include.am b/src/or/include.am index 56d41e47dd..9265ecf483 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -41,10 +41,8 @@ LIBTOR_A_SOURCES = \ src/or/consdiffmgr.c \ src/or/control.c \ src/or/cpuworker.c \ - src/or/dircollate.c \ src/or/directory.c \ src/or/dirserv.c \ - src/or/dirvote.c \ src/or/dns.c \ src/or/dnsserv.c \ src/or/dos.c \ @@ -76,8 +74,6 @@ LIBTOR_A_SOURCES = \ src/or/onion.c \ src/or/onion_fast.c \ src/or/onion_tap.c \ - src/or/shared_random.c \ - src/or/shared_random_state.c \ src/or/transports.c \ src/or/parsecommon.c \ src/or/periodic.c \ @@ -121,7 +117,11 @@ LIBTOR_A_SOURCES = \ # The Directory Authority module. if BUILD_MODULE_DIRAUTH -#LIBTOR_A_SOURCES += +LIBTOR_A_SOURCES += \ + src/or/dirauth/dircollate.c \ + src/or/dirauth/dirvote.c \ + src/or/dirauth/shared_random.c \ + src/or/dirauth/shared_random_state.c endif src_or_libtor_a_SOURCES = $(LIBTOR_A_SOURCES) @@ -195,10 +195,8 @@ ORHEADERS = \ src/or/consdiffmgr.h \ src/or/control.h \ src/or/cpuworker.h \ - src/or/dircollate.h \ src/or/directory.h \ src/or/dirserv.h \ - src/or/dirvote.h \ src/or/dns.h \ src/or/dns_structs.h \ src/or/dnsserv.h \ @@ -235,8 +233,6 @@ ORHEADERS = \ src/or/onion_ntor.h \ src/or/onion_tap.h \ src/or/or.h \ - src/or/shared_random.h \ - src/or/shared_random_state.h \ src/or/transports.h \ src/or/parsecommon.h \ src/or/periodic.h \ @@ -273,7 +269,11 @@ ORHEADERS = \ # properly compiled the entry points stub. # The Directory Authority module headers. -#ORHEADERS += +ORHEADERS += \ + src/or/dirauth/dircollate.h \ + src/or/dirauth/dirvote.h \ + src/or/dirauth/shared_random.h \ + src/or/dirauth/shared_random_state.h # This may someday want to be an installed file? noinst_HEADERS += src/or/tor_api.h diff --git a/src/or/main.c b/src/or/main.c index c1103edb3a..b7b7b71624 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -72,7 +72,6 @@ #include "crypto_s2k.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "dns.h" #include "dnsserv.h" #include "dos.h" @@ -103,7 +102,7 @@ #include "routerlist.h" #include "routerparse.h" #include "scheduler.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #include "statefile.h" #include "status.h" #include "tor_api.h" @@ -118,6 +117,8 @@ #include +#include "dirauth/dirvote.h" + #ifdef HAVE_SYSTEMD # if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index b0db0cecbc..f78d9d672b 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -50,7 +50,6 @@ #include "control.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "dos.h" #include "entrynodes.h" #include "hibernate.h" @@ -64,11 +63,13 @@ #include "routerlist.h" #include "routerparse.h" #include "scheduler.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #include "transports.h" #include "torcert.h" #include "channelpadding.h" +#include "dirauth/dirvote.h" + /** Most recently received and validated v3 "ns"-flavored consensus network * status. */ STATIC networkstatus_t *current_ns_consensus = NULL; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1bfbd9f670..7eb9ec7990 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -101,7 +101,6 @@ #include "control.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" #include "entrynodes.h" #include "fp_pair.h" #include "geoip.h" @@ -122,6 +121,8 @@ #include "sandbox.h" #include "torcert.h" +#include "dirauth/dirvote.h" + // #define DEBUG_ROUTERLIST /****************************************************************************/ diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 1834cfad24..84db239155 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -59,7 +59,6 @@ #include "config.h" #include "circuitstats.h" #include "dirserv.h" -#include "dirvote.h" #include "parsecommon.h" #include "policies.h" #include "protover.h" @@ -75,11 +74,13 @@ #include "entrynodes.h" #include "torcert.h" #include "sandbox.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #undef log #include +#include "dirauth/dirvote.h" + /****************************************************************************/ /** List of tokens recognized in router descriptors */ diff --git a/src/test/test_config.c b/src/test/test_config.c index 7983106a2f..461aa646d6 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -24,7 +24,7 @@ #include "control.h" #include "cpuworker.h" #include "dirserv.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "dns.h" #include "entrynodes.h" #include "transports.h" diff --git a/src/test/test_dir.c b/src/test/test_dir.c index df5ae2d594..74153c671a 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -25,7 +25,7 @@ #include "crypto_ed25519.h" #include "directory.h" #include "dirserv.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "entrynodes.h" #include "hibernate.h" #include "memarea.h" @@ -35,7 +35,7 @@ #include "routerlist.h" #include "routerparse.h" #include "routerset.h" -#include "shared_random_state.h" +#include "dirauth/shared_random_state.h" #include "test.h" #include "test_dir_common.h" #include "torcert.h" diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c index fdf43533a8..c3e3662fde 100644 --- a/src/test/test_dir_common.c +++ b/src/test/test_dir_common.c @@ -9,7 +9,7 @@ #include "test.h" #include "container.h" #include "or.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "nodelist.h" #include "routerlist.h" #include "test_dir_common.h" diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 71faf70af2..1bff249df5 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -30,7 +30,7 @@ #include "proto_http.h" #include "geoip.h" #include "dirserv.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "log_test_helpers.h" #ifdef _WIN32 diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index 17ba11ca7d..43a2c5e80c 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -23,12 +23,12 @@ #include "config.h" #include "networkstatus.h" #include "directory.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "nodelist.h" #include "routerlist.h" #include "statefile.h" #include "circuitlist.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #include "util.h" /** Test the validation of HS v3 addresses */ diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 481521520c..fc8e016b52 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -34,7 +34,7 @@ #include "circuitlist.h" #include "circuituse.h" #include "crypto.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "networkstatus.h" #include "nodelist.h" #include "relay.h" @@ -51,7 +51,7 @@ #include "main.h" #include "rendservice.h" #include "statefile.h" -#include "shared_random_state.h" +#include "dirauth/shared_random_state.h" /* Trunnel */ #include "hs/cell_establish_intro.h" diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c index 94b4d5e51f..4b168f49ed 100644 --- a/src/test/test_microdesc.c +++ b/src/test/test_microdesc.c @@ -6,7 +6,7 @@ #include "config.h" #define DIRVOTE_PRIVATE -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "microdesc.h" #include "networkstatus.h" #include "routerlist.h" diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c index c19d66ef9d..71b487f35b 100644 --- a/src/test/test_routerlist.c +++ b/src/test/test_routerlist.c @@ -19,7 +19,7 @@ #include "container.h" #include "control.h" #include "directory.h" -#include "dirvote.h" +#include "dirauth/dirvote.h" #include "entrynodes.h" #include "hibernate.h" #include "microdesc.h" @@ -30,7 +30,7 @@ #include "routerlist.h" #include "routerset.h" #include "routerparse.h" -#include "shared_random.h" +#include "dirauth/shared_random.h" #include "statefile.h" #include "test.h" #include "test_dir_common.h" diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 4fe9ee45f0..30d0d44cac 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -9,9 +9,9 @@ #include "or.h" #include "test.h" #include "config.h" -#include "dirvote.h" -#include "shared_random.h" -#include "shared_random_state.h" +#include "dirauth/dirvote.h" +#include "dirauth/shared_random.h" +#include "dirauth/shared_random_state.h" #include "routerkeys.h" #include "routerlist.h" #include "router.h"