Kaynağa Gözat

Update debian defaults in preparation for starting as root.

Previously the debian defaults were only loaded when we started Tor as
the debian-tor user.  Now they are also loaded when started as root.
In addition to logging, pidfile, datadir and runasdaemon we also change
the User and Group options from their NULL default to "debian-tor" so that
Tor correctly setuids/setgids to the role user the package created.

This will allow us to start the daemon as root.


svn:r13685
Peter Palfrader 17 yıl önce
ebeveyn
işleme
c6a7ab729c

+ 7 - 5
debian/README.Debian

@@ -1,14 +1,16 @@
 This is the Debian package for Tor, The Onion Router.
 This is the Debian package for Tor, The Onion Router.
 
 
 Some changes have been made to the Tor source to integrate it better into
 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:
+Debian.  If Tor is started as root or the 'debian-tor' user, then:
 
 
-- RunAsDaemon is enabled by default.
+- RunAsDaemon is enabled,
-- PidFile is set to /var/run/tor/tor.pid.  No default upstream.
+- PidFile is set to /var/run/tor/tor.pid (No default upstream),
-- default logging goes to /var/log/tor/log instead of stdout.
+- default logging goes to /var/log/tor/log (instead of stdout),
-- DataDirectory is set to /var/lib/tor by default.  Uses $HOME/.tor upstream.
+- DataDirectory is set to /var/lib/tor (uses $HOME/.tor upstream),
+- User and Group are set to "debian-tor".
 
 
 If Tor is started as any other user it behaves just like upstream's.
 If Tor is started as any other user it behaves just like upstream's.
 
 
 -- 
 -- 
 Peter Palfrader, Mon, 24 Jul 2006 05:20:30 +0200
 Peter Palfrader, Mon, 24 Jul 2006 05:20:30 +0200
+                 Sat, 23 Feb 2008 13:44:40 +0100

+ 4 - 1
debian/changelog

@@ -10,8 +10,11 @@ tor (0.2.0.19-alpha+svn-1) unreleased; urgency=low
     Big servers at the moment regularly use more than 10k FDs, so our old
     Big servers at the moment regularly use more than 10k FDs, so our old
     default of 8k no longer is sufficient.  On the other hand we don't want
     default of 8k no longer is sufficient.  On the other hand we don't want
     lower end systems to run out of FDs on Tor's account.
     lower end systems to run out of FDs on Tor's account.
+  * If we run as root also apply debian defaults.
+  * Add User=debian-tor and Group=debian-tor to debian defaults.  That allows
+    us to start Tor as root and have it setuid/setgid to the target user.
 
 
- -- Peter Palfrader <weasel@debian.org>  Wed, 20 Feb 2008 23:38:45 +0100
+ -- Peter Palfrader <weasel@debian.org>  Sat, 23 Feb 2008 13:44:56 +0100
 
 
 tor (0.2.0.19-alpha-1) experimental; urgency=low
 tor (0.2.0.19-alpha-1) experimental; urgency=low
 
 

+ 21 - 9
debian/patches/06_add_compile_time_defaults.dpatch

@@ -23,10 +23,10 @@ esac
 exit 0
 exit 0
 
 
 @DPATCH@
 @DPATCH@
-diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
+diff -urNad trunk~/src/or/config.c trunk/src/or/config.c
---- tor-trunk/src/or/config.c	2007-04-29 04:11:46.261474906 +0200
+--- trunk~/src/or/config.c	2008-02-23 11:08:40.000000000 +0100
-+++ /tmp/dpep.YE8t73/tor-trunk/src/or/config.c	2007-04-29 04:12:24.827577276 +0200
++++ trunk/src/or/config.c	2008-02-23 13:43:05.000000000 +0100
-@@ -14,6 +14,7 @@
+@@ -15,6 +15,7 @@
  #define CONFIG_PRIVATE
  #define CONFIG_PRIVATE
  
  
  #include "or.h"
  #include "or.h"
@@ -34,7 +34,7 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
  #ifdef MS_WINDOWS
  #ifdef MS_WINDOWS
  #include <shlobj.h>
  #include <shlobj.h>
  #endif
  #endif
-@@ -595,6 +596,8 @@
+@@ -660,6 +661,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 tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/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
-@@ -2991,7 +2994,7 @@
+@@ -3522,7 +3525,7 @@
  int
  int
  options_init_from_torrc(int argc, char **argv)
  options_init_from_torrc(int argc, char **argv)
  {
  {
@@ -52,7 +52,7 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
    config_line_t *cl;
    config_line_t *cl;
    char *cf=NULL, *fname=NULL, *errmsg=NULL;
    char *cf=NULL, *fname=NULL, *errmsg=NULL;
    int i, retval;
    int i, retval;
-@@ -3000,6 +3003,9 @@
+@@ -3531,6 +3534,9 @@
    static char **backup_argv;
    static char **backup_argv;
    static int backup_argc;
    static int backup_argc;
  
  
@@ -62,7 +62,7 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/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;
-@@ -3135,7 +3141,8 @@
+@@ -3666,7 +3672,8 @@
   err:
   err:
    tor_free(fname);
    tor_free(fname);
    torrc_fname = NULL;
    torrc_fname = NULL;
@@ -72,7 +72,7 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
    if (errmsg) {
    if (errmsg) {
      log(LOG_WARN,LD_CONFIG,"Failed to parse/validate config: %s", errmsg);
      log(LOG_WARN,LD_CONFIG,"Failed to parse/validate config: %s", errmsg);
      tor_free(errmsg);
      tor_free(errmsg);
-@@ -4320,3 +4327,52 @@
+@@ -5011,3 +5018,64 @@
    puts(routerparse_c_id);
    puts(routerparse_c_id);
  }
  }
  
  
@@ -85,6 +85,10 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
 +  int uid;
 +  int uid;
 +
 +
 +  uid = getuid();
 +  uid = getuid();
++  /* If we run as root we also apply our debian defaults. */
++  if (uid == 0)
++    return 1;
++
 +  pw = getpwuid(uid);
 +  pw = getpwuid(uid);
 +  if (!pw) {
 +  if (!pw) {
 +    log(LOG_WARN, LD_GENERAL, "Could not get passwd information for uid %d.", uid);
 +    log(LOG_WARN, LD_GENERAL, "Could not get passwd information for uid %d.", uid);
@@ -123,5 +127,13 @@ diff -urNad tor-trunk/src/or/config.c /tmp/dpep.YE8t73/tor-trunk/src/or/config.c
 +  tor_assert(var);
 +  tor_assert(var);
 +  var->initvalue = tor_strdup("1");
 +  var->initvalue = tor_strdup("1");
 +
 +
++  var = config_find_option(&options_format, "User");
++  tor_assert(var);
++  var->initvalue = tor_strdup("debian-tor");
++
++  var = config_find_option(&options_format, "Group");
++  tor_assert(var);
++  var->initvalue = tor_strdup("debian-tor");
++
 +  return 0;
 +  return 0;
 +}
 +}