aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2006-07-24 03:24:25 +0000
committerPeter Palfrader <peter@palfrader.org>2006-07-24 03:24:25 +0000
commitf968d38f3eacbc395b490ecba6f55e7d0943e047 (patch)
tree5bb5aed05a42ad29ea7cea6b7b094022ed47b994
parent4fccf84004cba03ca777237fd76cba6cefd9137a (diff)
downloadtor-f968d38f3eacbc395b490ecba6f55e7d0943e047.tar
tor-f968d38f3eacbc395b490ecba6f55e7d0943e047.tar.gz
Previously our defaults for DataDirectory, PidFile, RunAsDaemon, and
Log differed from upstreams. Now Tor behaves just like before (with our own DataDirectory and all) only when run as the debian-tor user. If invoked as any other user, Tor will behave just like the pristine upstream version. svn:r6821
-rw-r--r--debian/README.Debian7
-rw-r--r--debian/changelog7
-rwxr-xr-xdebian/patches/06_add_compile_time_defaults.dpatch124
-rwxr-xr-xdebian/patches/07_log_to_file_by_default.dpatch18
4 files changed, 116 insertions, 40 deletions
diff --git a/debian/README.Debian b/debian/README.Debian
index 6c9730d6c..cda020b9e 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -1,13 +1,14 @@
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:
+Some changes have been made to the Tor source to integrate it better into
+Debian. If Tor is started as the 'debian-tor' user, then:
- 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. Uses $HOME/.tor upstream.
+If Tor is started as any other user it behaves just like upstream's.
--
-Peter Palfrader, Fri, 12 Nov 2004 18:08:54 +0100
+Peter Palfrader, Mon, 24 Jul 2006 05:20:30 +0200
diff --git a/debian/changelog b/debian/changelog
index 078d6c7d5..8b0df71d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,13 @@ tor (0.1.2.0-alpha-cvs-1) unstable; urgency=low
* CVS snapshot.
* Forward port 07_log_to_file_by_default.dpatch.
+ * Previously our defaults for DataDirectory, PidFile, RunAsDaemon, and
+ Log differed from upstreams. Now Tor behaves just like before (with
+ our own DataDirectory and all) only when run as the debian-tor user.
+ If invoked as any other user, Tor will behave just like the pristine
+ upstream version.
- -- Peter Palfrader <weasel@debian.org> Thu, 22 Jun 2006 00:12:44 +0200
+ -- Peter Palfrader <weasel@debian.org> Mon, 24 Jul 2006 05:21:00 +0200
tor (0.1.1.21-1) unstable; urgency=low
diff --git a/debian/patches/06_add_compile_time_defaults.dpatch b/debian/patches/06_add_compile_time_defaults.dpatch
index 81e6034d3..8b4e49424 100755
--- a/debian/patches/06_add_compile_time_defaults.dpatch
+++ b/debian/patches/06_add_compile_time_defaults.dpatch
@@ -23,33 +23,97 @@ esac
exit 0
@DPATCH@
-diff -urNad tor-0.1.1.5/src/or/config.c /tmp/dpep.Xv4cHn/tor-0.1.1.5/src/or/config.c
---- tor-0.1.1.9/src/or/config.c 2005-10-17 03:54:24.917618642 +0200
-+++ /tmp/foo/tor/src/or/config.c 2005-10-17 03:57:52.040022393 +0200
-@@ -111,7 +111,7 @@
- VAR("ContactInfo", STRING, ContactInfo, NULL),
- VAR("ControlPort", UINT, ControlPort, "0"),
- VAR("CookieAuthentication",BOOL, CookieAuthentication, "0"),
-- VAR("DataDirectory", STRING, DataDirectory, NULL),
-+ VAR("DataDirectory", STRING, DataDirectory, "/var/lib/tor"),
- VAR("DebugLogFile", STRING, DebugLogFile, NULL),
- VAR("DirAllowPrivateAddresses",BOOL, DirAllowPrivateAddresses, NULL),
- VAR("DirBindAddress", LINELIST, DirBindAddress, NULL),
-@@ -162,7 +162,7 @@
- VAR("ORPort", UINT, ORPort, "0"),
- VAR("OutboundBindAddress", STRING, OutboundBindAddress, NULL),
- VAR("PathlenCoinWeight", DOUBLE, PathlenCoinWeight, "0.3"),
-- VAR("PidFile", STRING, PidFile, NULL),
-+ VAR("PidFile", STRING, PidFile, "/var/run/tor/tor.pid"),
- VAR("ProtocolWarnings", BOOL, ProtocolWarnings, "0"),
- VAR("ReachableAddresses", LINELIST, ReachableAddresses, NULL),
- VAR("RecommendedVersions", LINELIST, RecommendedVersions, NULL),
-@@ -174,7 +174,7 @@
- VAR("RendPostPeriod", INTERVAL, RendPostPeriod, "20 minutes"),
- VAR("RephistTrackTime", INTERVAL, RephistTrackTime, "24 hours"),
- OBSOLETE("RouterFile"),
-- VAR("RunAsDaemon", BOOL, RunAsDaemon, "0"),
-+ VAR("RunAsDaemon", BOOL, RunAsDaemon, "1"),
- VAR("RunTesting", BOOL, RunTesting, "0"),
- VAR("SafeLogging", BOOL, SafeLogging, "1"),
- VAR("ShutdownWaitLength", INTERVAL, ShutdownWaitLength, "30 seconds"),
+diff -urNad tor~/src/or/config.c tor/src/or/config.c
+--- tor~/src/or/config.c 2006-07-23 19:31:29.000000000 +0200
++++ tor/src/or/config.c 2006-07-24 05:13:19.924871985 +0200
+@@ -12,6 +12,7 @@
+ **/
+
+ #include "or.h"
++#include <pwd.h>
+ #ifdef MS_WINDOWS
+ #include <shlobj.h>
+ #endif
+@@ -396,6 +397,10 @@
+ static void check_libevent_version(const char *m, const char *v, int server);
+ #endif
+
++static int debian_running_as_debiantor();
++static int debian_config_fix_defaults();
++
++
+ /*static*/ or_options_t *options_new(void);
+
+ #define OR_OPTIONS_MAGIC 9090909
+@@ -2663,7 +2668,7 @@
+ int
+ options_init_from_torrc(int argc, char **argv)
+ {
+- or_options_t *oldoptions, *newoptions;
++ or_options_t *oldoptions, *newoptions = NULL;
+ config_line_t *cl;
+ char *cf=NULL, *fname=NULL, *errmsg=NULL;
+ int i, retval;
+@@ -2671,6 +2676,9 @@
+ static char **backup_argv;
+ static int backup_argc;
+
++ if (debian_config_fix_defaults() < 0)
++ goto err;
++
+ if (argv) { /* first time we're called. save commandline args */
+ backup_argv = argv;
+ backup_argc = argc;
+@@ -3948,3 +3956,52 @@
+ puts(routerparse_c_id);
+ }
+
++/* Checks whether we are running as the debian-tor user.
++ * Returns -1 on error, 1 if we are debian-tor, 0 if not */
++static int
++debian_running_as_debiantor()
++{
++ struct passwd *pw = NULL;
++ int uid;
++
++ uid = getuid();
++ pw = getpwuid(uid);
++ if (!pw) {
++ log(LOG_WARN, LD_GENERAL, "Could not get passwd information for %d.", uid);
++ return -1;
++ }
++ assert(pw->pw_name);
++ if (strcmp(pw->pw_name, "debian-tor") == 0)
++ return 1;
++ else
++ return 0;
++}
++
++static int
++debian_config_fix_defaults()
++{
++ config_var_t *var;
++ static int fixed = 0;
++ int running_as_debian;
++
++ if (fixed) return 0;
++ fixed = 1;
++
++ running_as_debian = debian_running_as_debiantor();
++ if (running_as_debian < 0) return -1;
++ if (!running_as_debian) return 0;
++
++ var = config_find_option(&options_format, "DataDirectory");
++ tor_assert(var);
++ var->initvalue = tor_strdup("/var/lib/tor");
++
++ var = config_find_option(&options_format, "PidFile");
++ tor_assert(var);
++ var->initvalue = tor_strdup("/var/run/tor/tor.pid");
++
++ var = config_find_option(&options_format, "RunAsDaemon");
++ tor_assert(var);
++ var->initvalue = tor_strdup("1");
++
++ return 0;
++}
diff --git a/debian/patches/07_log_to_file_by_default.dpatch b/debian/patches/07_log_to_file_by_default.dpatch
index c925c5efe..809c5ddcf 100755
--- a/debian/patches/07_log_to_file_by_default.dpatch
+++ b/debian/patches/07_log_to_file_by_default.dpatch
@@ -23,16 +23,22 @@ esac
exit 0
@DPATCH@
-diff -urNad tor-0.1.2.0-alpha-cvs/src/or/config.c /tmp/dpep.YwfNhI/tor-0.1.2.0-alpha-cvs/src/or/config.c
---- tor-0.1.2.0-alpha-cvs/src/or/config.c
-+++ /tmp/dpep.YwfNhI/tor-0.1.2.0-alpha-cvs/src/or/config.c
-@@ -2079,7 +2079,7 @@
+diff -urNad tor~/src/or/config.c tor/src/or/config.c
+--- tor~/src/or/config.c 2006-07-24 05:15:02.576170550 +0200
++++ tor/src/or/config.c 2006-07-24 05:18:45.286651501 +0200
+@@ -2118,8 +2118,13 @@
+ REJECT("Failed to normalize old Log options. See logs for details.");
/* Special case on first boot if no Log options are given. */
- if (!options->Logs && !options->RunAsDaemon && !from_setconf)
- config_line_append(&options->Logs, "Log", "notice stdout");
-+ if (!options->Logs && !from_setconf)
-+ config_line_append(&options->Logs, "Log", "notice file /var/log/tor/log");
++ if (debian_running_as_debiantor()) {
++ if (!options->Logs && !from_setconf)
++ config_line_append(&options->Logs, "Log", "notice file /var/log/tor/log");
++ } else {
++ if (!options->Logs && !options->RunAsDaemon && !from_setconf)
++ config_line_append(&options->Logs, "Log", "notice stdout");
++ }
if (options_init_logs(options, 1)<0) /* Validate the log(s) */
REJECT("Failed to validate Log options. See logs for details.");