summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@freehaven.net>2009-01-03 21:43:05 -0500
committerNick Mathewson <nickm@torproject.org>2009-04-29 14:46:04 -0400
commit6ac3a8b0cd1946e90a4c997e8fad1bfc63890abd (patch)
treee18fffa9c4b0ca4682ca36e607a6b6566946513b /src
parente3ec061bc0ba9aa1bad1615f78fa7fe602e194e0 (diff)
downloadtor-6ac3a8b0cd1946e90a4c997e8fad1bfc63890abd.tar.gz
tor-6ac3a8b0cd1946e90a4c997e8fad1bfc63890abd.zip
Command-line option to dump SHA1 digests of all source files.
Now, when you call tor --digests, it dumps the SHA1 digest of each source file that Tor was built with. We support both 'sha1sum' and 'openssl sha1'. If the user is building from a tarball and they haven't edited anything, they don't need any program that calculates SHA1. If they _have_ modified a file but they don't have a program to calculate SHA1, we try to build so we do not output digests.
Diffstat (limited to 'src')
-rw-r--r--src/common/Makefile.am14
-rw-r--r--src/common/util.c7
-rw-r--r--src/common/util.h2
-rw-r--r--src/or/Makefile.am16
-rw-r--r--src/or/config.c8
5 files changed, 46 insertions, 1 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 105c413343..78c8ab5516 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,6 +1,8 @@
noinst_LIBRARIES = libor.a libor-crypto.a
+EXTRA_DIST = common_sha1.i
+
#CFLAGS = -Wall -Wpointer-arith -O2
if USE_OPENBSD_MALLOC
@@ -14,3 +16,15 @@ libor_a_SOURCES = address.c log.c util.c compat.c container.c mempool.c \
libor_crypto_a_SOURCES = crypto.c aes.c tortls.c torgzip.c
noinst_HEADERS = address.h log.h crypto.h test.h util.h compat.h aes.h torint.h tortls.h strlcpy.c strlcat.c torgzip.h container.h ht.h mempool.h memarea.h ciphers.inc
+
+common_sha1.i: $(libor_SOURCES) $(libor_crypto_a_SOURCES) $(noinst_HEADERS)
+ if test "@SHA1SUM@" != none; then \
+ @SHA1SUM@ $(libor_SOURCES) $(libor_crypto_a_SOURCES) $(noinst_HEADERS) | @SED@ -n 's/^\(.*\)$$/"\1\\n"/p' > common_sha1.i; \
+ elif test "@OPENSSL@" != none; then \
+ @OPENSSL@ sha1 $(libor_SOURCES) $(libor_crypto_a_SOURCES) $(noinst_HEADERS) | @SED@ -n 's/SHA1(\(.*\))= \(.*\)/"\2 \1\\n"/p' > common_sha1.i; \
+ else \
+ rm common_sha1.i; \
+ touch common_sha1.i; \
+ fi
+
+util.o: common_sha1.i
diff --git a/src/common/util.c b/src/common/util.c
index 6310811961..bb227e4b0c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2562,3 +2562,10 @@ write_pidfile(char *filename)
}
}
+const char *
+libor_get_digests(void)
+{
+ return ""
+#include "common_sha1.i"
+ ;
+}
diff --git a/src/common/util.h b/src/common/util.h
index cbf5334c15..363a23b661 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -294,5 +294,7 @@ void start_daemon(void);
void finish_daemon(const char *desired_cwd);
void write_pidfile(char *filename);
+const char *libor_get_digests(void);
+
#endif
diff --git a/src/or/Makefile.am b/src/or/Makefile.am
index 28d7e736dc..03e7900944 100644
--- a/src/or/Makefile.am
+++ b/src/or/Makefile.am
@@ -10,7 +10,7 @@ else
tor_platform_source=
endif
-EXTRA_DIST=ntmain.c
+EXTRA_DIST=ntmain.c or_sha1.i
tor_SOURCES = buffers.c circuitbuild.c circuitlist.c \
circuituse.c command.c config.c \
@@ -52,6 +52,8 @@ test_LDADD = ../common/libor.a ../common/libor-crypto.a \
noinst_HEADERS = or.h eventdns.h eventdns_tor.h micro-revision.i
+config.o: or_sha1.i
+
tor_main.o: micro-revision.i
micro-revision.i: FORCE
@@ -103,5 +105,17 @@ micro-revision.i: FORCE
mv micro-revision.tmp micro-revision.i; \
fi; true
+or_sha1.i: $(tor_SOURCES) test_data.c test.c
+ if test "@SHA1SUM@" != none; then \
+ @SHA1SUM@ $(tor_SOURCES) test_data.c test.c | @SED@ -n 's/^\(.*\)$$/"\1\\n"/p' > or_sha1.i; \
+ elif test "@OPENSSL@" != none; then \
+ @OPENSSL@ sha1 $(tor_SOURCES) test_data.c test.c | @SED@ -n 's/SHA1(\(.*\))= \(.*\)/"\2 \1\\n"/p' > or_sha1.i; \
+ else \
+ rm or_sha1.i; \
+ touch or_sha1.i; \
+ fi
+
+
+
#Dummy target to ensure that micro-revision.i _always_ gets built.
FORCE:
diff --git a/src/or/config.c b/src/or/config.c
index aa61ecf9a5..14418d2beb 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3927,6 +3927,14 @@ options_init_from_torrc(int argc, char **argv)
printf("Tor version %s.\n",get_version());
exit(0);
}
+ if (argc > 1 && (!strcmp(argv[1],"--digests"))) {
+ printf("Tor version %s.\n",get_version());
+ printf("%s", libor_get_digests());
+ printf("%s", ""
+#include "or_sha1.i"
+ );
+ exit(0);
+ }
/* Go through command-line variables */
if (!global_cmdline_options) {