]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Command-line option to dump SHA1 digests of all source files.
authorNick Mathewson <nickm@freehaven.net>
Sun, 4 Jan 2009 02:43:05 +0000 (21:43 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 29 Apr 2009 18:46:04 +0000 (14:46 -0400)
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.

.gitignore
ChangeLog
configure.in
src/common/Makefile.am
src/common/util.c
src/common/util.h
src/or/Makefile.am
src/or/config.c

index f5d2d4ee96bc9c420c63e2a469ada6b521de847d..8c80e09c1a467f802033fc2a4c03c6e7241142a7 100644 (file)
 # /src/common/
 /src/common/Makefile
 /src/common/Makefile.in
+/src/common/common_sha1.i
 /src/common/libor.a
 /src/common/libor-crypto.a
 
 # /src/or/
 /src/or/Makefile
 /src/or/Makefile.in
+/src/or/or_sha1.i
 /src/or/micro-revision.*
 /src/or/tor
 /src/or/test
index 3ca41e13b540ba36d2ad46c422bff7fce184d500..5103456d37e22edb45fe4625f53a011308853432 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Changes in version 0.2.2.1-alpha - 2009-??-??
+  o Minor features
+    - New --digests command-line switch to output the digests of the source
+      files Tor was built with.
+
+
 Changes in version 0.2.1.15??? - ????-??-??
   o Minor bugfixes:
     - Actually return -1 in the error case for read_bandwidth_usage. Bug
index a7ea5e1bbcc5ab36e16e466ae397a0f314963715..2b8a91535528df916e36ea92aaa89fe785cbcaf4 100644 (file)
@@ -107,6 +107,10 @@ AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
+AC_PROG_SED
+
+AC_PATH_PROG([SHA1SUM], [sha1sum], none)
+AC_PATH_PROG([OPENSSL], [openssl], none)
 
 TORUSER=_tor
 AC_ARG_WITH(tor-user,
index 105c413343d3f7e0c6e0ec31f369dfbffe043b69..78c8ab5516c21512b64130e92c4f83ed7cd6fac4 100644 (file)
@@ -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
index 631081196105a54c85d329b35410042c19dbbd30..bb227e4b0c6a5fd68ea544446d583a23e8bdefaf 100644 (file)
@@ -2562,3 +2562,10 @@ write_pidfile(char *filename)
   }
 }
 
+const char *
+libor_get_digests(void)
+{
+  return ""
+#include "common_sha1.i"
+    ;
+}
index cbf5334c15739d2c139f5a36fb8b2d5571a3c941..363a23b6611bb7cf5fe2f1a60c9bf6d9aab40483 100644 (file)
@@ -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
 
index 28d7e736dcd4380e4302a84f44457e927c40d951..03e7900944de80a79a0d926cca63781f6c8bd830 100644 (file)
@@ -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:
index aa61ecf9a56367de74dc4254640e345f496a8c96..14418d2beb627ffab4e999feea6bfb0bede3ff87 100644 (file)
@@ -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) {