Commit 6a11cded authored by Peter Palfrader's avatar Peter Palfrader
Browse files

patches/06_add_compile_time_defaults: Only set the User option in the config if

we run as root.  Do not set it when run as debian-tor as Tor then always
insists on changing users which will fail.  (If we run as any other user we
don't set our debian defaults anyway.)


svn:r18397
parent decdf453
Loading
Loading
Loading
Loading
+9 −0
Changes for debian/changelog: 9 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
tor (0.2.1.11-alpha-2~1) experimental; urgency=low

  * patches/06_add_compile_time_defaults: Only set the User option in
    the config if we run as root.  Do not set it when run as debian-tor
    as Tor then always insists on changing users which will fail.  (If
    we run as any other user we don't set our debian defaults anyway.)

 -- Peter Palfrader <weasel@debian.org>  Thu, 05 Feb 2009 00:27:23 +0100

tor (0.2.1.11-alpha-1) experimental; urgency=high
tor (0.2.1.11-alpha-1) experimental; urgency=high


  * New upstream version:
  * New upstream version:
+12 −10
Changes for debian/patches/06_add_compile_time_defaults.dpatch: 12 added lines, 10 removed lines.
Original line number Original line Diff line number Diff line
@@ -23,10 +23,10 @@ esac
exit 0
exit 0


@DPATCH@
@DPATCH@
diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
diff -urNad tor-trunk~/src/or/config.c tor-trunk/src/or/config.c
--- git-trunk-conf~/src/or/config.c	2008-03-11 15:23:01.000000000 +0100
--- tor-trunk~/src/or/config.c	2009-01-18 01:47:33.000000000 +0100
+++ git-trunk-conf/src/or/config.c	2008-03-11 15:30:34.139280421 +0100
+++ tor-trunk/src/or/config.c	2009-02-05 00:25:17.614844812 +0100
@@ -15,6 +15,7 @@
@@ -12,6 +12,7 @@
 #define CONFIG_PRIVATE
 #define CONFIG_PRIVATE
 
 
 #include "or.h"
 #include "or.h"
@@ -34,7 +34,7 @@ diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
 #ifdef MS_WINDOWS
 #ifdef MS_WINDOWS
 #include <shlobj.h>
 #include <shlobj.h>
 #endif
 #endif
@@ -658,6 +659,8 @@
@@ -711,6 +712,8 @@
 #if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
 #if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
 static void check_libevent_version(const char *m, int server);
 static void check_libevent_version(const char *m, int server);
 #endif
 #endif
@@ -43,7 +43,7 @@ diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
 
 
 /** Magic value for or_options_t. */
 /** Magic value for or_options_t. */
 #define OR_OPTIONS_MAGIC 9090909
 #define OR_OPTIONS_MAGIC 9090909
@@ -3634,6 +3637,9 @@
@@ -3917,6 +3920,9 @@
   char *command_arg = NULL;
   char *command_arg = NULL;
   char *errmsg=NULL;
   char *errmsg=NULL;
 
 
@@ -53,12 +53,12 @@ diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
   if (argv) { /* first time we're called. save commandline args */
   if (argv) { /* first time we're called. save commandline args */
     backup_argv = argv;
     backup_argv = argv;
     backup_argc = argc;
     backup_argc = argc;
@@ -5051,3 +5057,60 @@
@@ -5307,3 +5313,62 @@
   puts(routerparse_c_id);
   return 0;
 }
 }
 
 
+/* Checks whether we are running as the debian-tor user.
+/* Checks whether we are running as the debian-tor user.
+ *   Returns -1 on error, 1 if we are debian-tor, 0 if not */
+ *   Returns -1 on error, 2 if we are root, 1 if we are debian-tor, 0 if we are any normal user */
+static int
+static int
+debian_running_as_debiantor()
+debian_running_as_debiantor()
+{
+{
@@ -68,7 +68,7 @@ diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
+  uid = getuid();
+  uid = getuid();
+  /* If we run as root we also apply our debian defaults. */
+  /* If we run as root we also apply our debian defaults. */
+  if (uid == 0)
+  if (uid == 0)
+    return 1;
+    return 2;
+
+
+  pw = getpwuid(uid);
+  pw = getpwuid(uid);
+  if (!pw) {
+  if (!pw) {
@@ -108,9 +108,11 @@ diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
+  tor_assert(var);
+  tor_assert(var);
+  var->initvalue = tor_strdup("1");
+  var->initvalue = tor_strdup("1");
+
+
+  if (running_as_debian == 2) {
+    var = config_find_option(&options_format, "User");
+    var = config_find_option(&options_format, "User");
+    tor_assert(var);
+    tor_assert(var);
+    var->initvalue = tor_strdup("debian-tor");
+    var->initvalue = tor_strdup("debian-tor");
+  };
+
+
+  return 0;
+  return 0;
+}
+}