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
This commit is contained in:
Peter Palfrader 2009-02-04 23:42:39 +00:00
parent decdf4537a
commit 6a11cded87
2 changed files with 24 additions and 13 deletions

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
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
* New upstream version:

View File

@ -23,10 +23,10 @@ esac
exit 0
@DPATCH@
diff -urNad git-trunk-conf~/src/or/config.c git-trunk-conf/src/or/config.c
--- git-trunk-conf~/src/or/config.c 2008-03-11 15:23:01.000000000 +0100
+++ git-trunk-conf/src/or/config.c 2008-03-11 15:30:34.139280421 +0100
@@ -15,6 +15,7 @@
diff -urNad tor-trunk~/src/or/config.c tor-trunk/src/or/config.c
--- tor-trunk~/src/or/config.c 2009-01-18 01:47:33.000000000 +0100
+++ tor-trunk/src/or/config.c 2009-02-05 00:25:17.614844812 +0100
@@ -12,6 +12,7 @@
#define CONFIG_PRIVATE
#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
#include <shlobj.h>
#endif
@@ -658,6 +659,8 @@
@@ -711,6 +712,8 @@
#if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
static void check_libevent_version(const char *m, int server);
#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. */
#define OR_OPTIONS_MAGIC 9090909
@@ -3634,6 +3637,9 @@
@@ -3917,6 +3920,9 @@
char *command_arg = 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 */
backup_argv = argv;
backup_argc = argc;
@@ -5051,3 +5057,60 @@
puts(routerparse_c_id);
@@ -5307,3 +5313,62 @@
return 0;
}
+/* 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
+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();
+ /* If we run as root we also apply our debian defaults. */
+ if (uid == 0)
+ return 1;
+ return 2;
+
+ pw = getpwuid(uid);
+ 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);
+ var->initvalue = tor_strdup("1");
+
+ var = config_find_option(&options_format, "User");
+ tor_assert(var);
+ var->initvalue = tor_strdup("debian-tor");
+ if (running_as_debian == 2) {
+ var = config_find_option(&options_format, "User");
+ tor_assert(var);
+ var->initvalue = tor_strdup("debian-tor");
+ };
+
+ return 0;
+}