From ead200164a547a276c1ab92271aee85ccec4e642 Mon Sep 17 00:00:00 2001
From: Peter Palfrader <peter@palfrader.org>
Date: Fri, 12 Nov 2004 17:17:58 +0000
Subject: [PATCH] Do not patch the default torrc to include settings we really
 want.  Instead modify the compiled in default options.

svn:r2813
---
 debian/README.Debian                          | 13 +++++
 debian/changelog                              | 13 ++++-
 debian/patches/00list                         |  5 +-
 .../patches/01_uncomment_datadirectory.dpatch | 37 --------------
 debian/patches/04_run_as_daemon.dpatch        | 38 --------------
 debian/patches/05_log_to_file.dpatch          | 37 --------------
 .../06_add_compile_time_defaults.dpatch       | 51 +++++++++++++++++++
 .../patches/07_log_to_file_by_default.dpatch  | 37 ++++++++++++++
 debian/tor.docs                               |  1 +
 9 files changed, 115 insertions(+), 117 deletions(-)
 create mode 100644 debian/README.Debian
 delete mode 100755 debian/patches/01_uncomment_datadirectory.dpatch
 delete mode 100755 debian/patches/04_run_as_daemon.dpatch
 delete mode 100755 debian/patches/05_log_to_file.dpatch
 create mode 100755 debian/patches/06_add_compile_time_defaults.dpatch
 create mode 100755 debian/patches/07_log_to_file_by_default.dpatch

diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000000..9c03940dbd
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,13 @@
+This is the Debian package for Tor, The Onion Router.
+
+The following changes have been made to the Tor source to integrate it better
+into Debian:
+
+- RunAsDaemon is enabled by default.
+- PidFile is set to /var/run/tor/tor.pid.  No default upstream.
+- default logging goes to /var/log/tor/log instead of stdout.
+- DataDirectory is set to /var/lib/tor by default.  No default upstream.
+
+
+-- 
+Peter Palfrader, Fri, 12 Nov 2004 18:08:54 +0100
diff --git a/debian/changelog b/debian/changelog
index a2c2740d63..aa67cd278e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,17 @@ tor (0.0.8+0.0.9pre5-2) unreleased; urgency=low
   * Make logs readable by the system administrators (group adm).
   * Point to /var/log/tor (the directory) instead of a single
     file (/var/log/tor/log) in the debian patch of the manpage.
-
- -- Peter Palfrader <weasel@debian.org>  Fri, 12 Nov 2004 17:51:13 +0100
+  * Do not patch the default torrc to include settings we really want.
+    Instead modify the compiled in default options.  Those settings are
+    
+    - RunAsDaemon is enabled by default.
+    - PidFile is set to /var/run/tor/tor.pid.  No default upstream.
+    - default logging goes to /var/log/tor/log instead of stdout.
+    - DataDirectory is set to /var/lib/tor by default.  No default upstream.
+    
+    This is also documented in the new debian/README.Debian.
+
+ -- Peter Palfrader <weasel@debian.org>  Fri, 12 Nov 2004 18:11:26 +0100
 
 tor (0.0.8+0.0.9pre5-1) unstable; urgency=low
 
diff --git a/debian/patches/00list b/debian/patches/00list
index 57694fe518..cd17cd1dca 100644
--- a/debian/patches/00list
+++ b/debian/patches/00list
@@ -1,5 +1,4 @@
-01_uncomment_datadirectory.dpatch
 02_add_debian_files_in_manpage.dpatch
 03_tor_manpage_in_section_8.dpatch
-04_run_as_daemon.dpatch
-05_log_to_file.dpatch
+06_add_compile_time_defaults.dpatch
+07_log_to_file_by_default.dpatch
diff --git a/debian/patches/01_uncomment_datadirectory.dpatch b/debian/patches/01_uncomment_datadirectory.dpatch
deleted file mode 100755
index bebd95a121..0000000000
--- a/debian/patches/01_uncomment_datadirectory.dpatch
+++ /dev/null
@@ -1,37 +0,0 @@
-#! /bin/sh -e
-## 01_uncomment_datadirectory.dpatch by  <weasel@debian.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: No description.
-
-if [ $# -lt 1 ]; then
-    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-    exit 1
-fi
-
-[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
-patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
-
-case "$1" in
-    -patch) patch -p1 ${patch_opts} < $0;;
-    -unpatch) patch -R -p1 ${patch_opts} < $0;;
-    *)
-        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-        exit 1;;
-esac
-
-exit 0
-
-@DPATCH@
-diff -urNad tor-0.0.9pre5/src/config/torrc.sample.in /tmp/dpep.bt2Xog/tor-0.0.9pre5/src/config/torrc.sample.in
---- tor-0.0.9pre5/src/config/torrc.sample.in	2004-11-09 21:04:18.000000000 +0100
-+++ /tmp/dpep.bt2Xog/tor-0.0.9pre5/src/config/torrc.sample.in	2004-11-10 03:23:26.072988347 +0100
-@@ -45,7 +45,7 @@
- 
- # The directory for keeping all the keys/etc. By default, we store
- # things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
--#DataDirectory @LOCALSTATEDIR@/lib/tor
-+DataDirectory @LOCALSTATEDIR@/lib/tor
- 
- ##################### Below is just for servers #####################
- 
diff --git a/debian/patches/04_run_as_daemon.dpatch b/debian/patches/04_run_as_daemon.dpatch
deleted file mode 100755
index ed71341a9f..0000000000
--- a/debian/patches/04_run_as_daemon.dpatch
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh -e
-## 04_run_as_daemon.dpatch by  <weasel@debian.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: No description.
-
-if [ $# -lt 1 ]; then
-    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-    exit 1
-fi
-
-[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
-patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
-
-case "$1" in
-    -patch) patch -p1 ${patch_opts} < $0;;
-    -unpatch) patch -R -p1 ${patch_opts} < $0;;
-    *)
-        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-        exit 1;;
-esac
-
-exit 0
-
-@DPATCH@
-diff -urNad cvs/src/config/torrc.sample.in /tmp/dpep.ICyOZe/cvs/src/config/torrc.sample.in
---- cvs/src/config/torrc.sample.in	2004-11-10 03:09:14.931082420 +0100
-+++ /tmp/dpep.ICyOZe/cvs/src/config/torrc.sample.in	2004-11-10 04:32:54.737527368 +0100
-@@ -32,7 +32,8 @@
- 
- # Uncomment this to start the process in the background... or use
- # --runasdaemon 1 on the command line.
--#RunAsDaemon 1
-+RunAsDaemon 1
-+PIDfile /var/run/tor/tor.pid
- 
- # Tor only trusts directories signed with one of these keys, and
- # uses the given addresses to connect to the trusted directory
diff --git a/debian/patches/05_log_to_file.dpatch b/debian/patches/05_log_to_file.dpatch
deleted file mode 100755
index 75c87f5bf0..0000000000
--- a/debian/patches/05_log_to_file.dpatch
+++ /dev/null
@@ -1,37 +0,0 @@
-#! /bin/sh -e
-## 05_log_to_file.dpatch by  <weasel@debian.org>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: No description.
-
-if [ $# -lt 1 ]; then
-    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-    exit 1
-fi
-
-[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
-patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
-
-case "$1" in
-    -patch) patch -p1 ${patch_opts} < $0;;
-    -unpatch) patch -R -p1 ${patch_opts} < $0;;
-    *)
-        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
-        exit 1;;
-esac
-
-exit 0
-
-@DPATCH@
-diff -urNad cvs/src/config/torrc.sample.in /tmp/dpep.5IEZdW/cvs/src/config/torrc.sample.in
---- cvs/src/config/torrc.sample.in	2004-11-10 03:09:14.931082420 +0100
-+++ /tmp/dpep.5IEZdW/cvs/src/config/torrc.sample.in	2004-11-10 04:34:35.090758448 +0100
-@@ -19,6 +19,8 @@
- 
- # Logs go to stdout unless redirected by something else, like one of
- # the below lines, or --logfile on the command line.
-+### Send all messages of level 'notice' or higher to @LOCALSTATEDIR@/log/tor/log
-+Log notice file @LOCALSTATEDIR@/log/tor/log
- ### Send all messages of level 'warn' or higher to @LOCALSTATEDIR@/log/tor/warnings
- #Log warn file @LOCALSTATEDIR@/log/tor/warnings
- ### Send all debug and info messages to @LOCALSTATEDIR@/log/tor/debug
diff --git a/debian/patches/06_add_compile_time_defaults.dpatch b/debian/patches/06_add_compile_time_defaults.dpatch
new file mode 100755
index 0000000000..4702a5add5
--- /dev/null
+++ b/debian/patches/06_add_compile_time_defaults.dpatch
@@ -0,0 +1,51 @@
+#! /bin/sh -e
+## 06_add_compile_time_defaults.dpatch by  <weasel@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad cvs/src/or/config.c /tmp/dpep.XUCqlY/cvs/src/or/config.c
+--- cvs/src/or/config.c	2004-11-12 17:40:22.906576139 +0100
++++ /tmp/dpep.XUCqlY/cvs/src/or/config.c	2004-11-12 17:58:01.603511522 +0100
+@@ -95,7 +95,7 @@
+   VAR("ControlPort",         UINT,     ControlPort,          "0"),
+   VAR("CookieAuthentication",BOOL,     CookieAuthentication, "0"),
+   VAR("DebugLogFile",        STRING,   DebugLogFile,         NULL),
+-  VAR("DataDirectory",       STRING,   DataDirectory,        NULL),
++  VAR("DataDirectory",       STRING,   DataDirectory,        "/var/lib/tor"),
+   VAR("DirPort",             UINT,     DirPort,              "0"),
+   VAR("DirBindAddress",      LINELIST, DirBindAddress,       NULL),
+   VAR("DirFetchPostPeriod",  UINT,     DirFetchPostPeriod,   "600"),
+@@ -135,11 +135,11 @@
+   VAR("ORPort",              UINT,     ORPort,               "0"),
+   VAR("ORBindAddress",       LINELIST, ORBindAddress,        NULL),
+   VAR("OutboundBindAddress", STRING,   OutboundBindAddress,  NULL),
+-  VAR("PidFile",             STRING,   PidFile,              NULL),
++  VAR("PidFile",             STRING,   PidFile,              "/var/run/tor/tor.pid"),
+   VAR("PathlenCoinWeight",   DOUBLE,   PathlenCoinWeight,    "0.3"),
+   VAR("RedirectExit",        LINELIST, RedirectExit,         NULL),
+   OBSOLETE("RouterFile"),
+-  VAR("RunAsDaemon",         BOOL,     RunAsDaemon,          "0"),
++  VAR("RunAsDaemon",         BOOL,     RunAsDaemon,          "1"),
+   VAR("RunTesting",          BOOL,     RunTesting,           "0"),
+   VAR("RecommendedVersions", LINELIST, RecommendedVersions,  NULL),
+   VAR("RendNodes",           STRING,   RendNodes,            NULL),
diff --git a/debian/patches/07_log_to_file_by_default.dpatch b/debian/patches/07_log_to_file_by_default.dpatch
new file mode 100755
index 0000000000..bf4c7da3a5
--- /dev/null
+++ b/debian/patches/07_log_to_file_by_default.dpatch
@@ -0,0 +1,37 @@
+#! /bin/sh -e
+## 07_log_to_file_by_default.dpatch by  <weasel@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad cvs/src/or/config.c /tmp/dpep.fbjWEM/cvs/src/or/config.c
+--- cvs/src/or/config.c	2004-11-12 18:10:35.333768630 +0100
++++ /tmp/dpep.fbjWEM/cvs/src/or/config.c	2004-11-12 18:10:53.432747222 +0100
+@@ -1026,7 +1026,7 @@
+ 
+   /* Special case if no options are given. */
+   if (!options->Logs) {
+-    options->Logs = config_line_prepend(NULL, "Log", "notice-err stdout");
++    options->Logs = config_line_prepend(NULL, "Log", "notice file /var/log/tor/log");
+   }
+ 
+   if (config_init_logs(options, 1)<0) /* Validate the log(s) */
diff --git a/debian/tor.docs b/debian/tor.docs
index a6a14e6c12..8ad419d142 100644
--- a/debian/tor.docs
+++ b/debian/tor.docs
@@ -2,6 +2,7 @@ AUTHORS
 README
 INSTALL
 debian/README.privoxy
+debian/README.Debian
 doc/CLIENTS
 doc/FAQ
 doc/HACKING
-- 
GitLab