[or-cvs] r13685: Update debian defaults in preparation for starting as root. (in tor/trunk/debian: . patches)

weasel at seul.org weasel at seul.org
Sat Feb 23 12:59:53 UTC 2008


Author: weasel
Date: 2008-02-23 07:59:52 -0500 (Sat, 23 Feb 2008)
New Revision: 13685

Modified:
   tor/trunk/debian/README.Debian
   tor/trunk/debian/changelog
   tor/trunk/debian/patches/06_add_compile_time_defaults.dpatch
Log:
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.


Modified: tor/trunk/debian/README.Debian
===================================================================
--- tor/trunk/debian/README.Debian	2008-02-23 00:50:45 UTC (rev 13684)
+++ tor/trunk/debian/README.Debian	2008-02-23 12:59:52 UTC (rev 13685)
@@ -1,14 +1,16 @@
 This is the Debian package for Tor, The Onion Router.
 
 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.
-- 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.
+- RunAsDaemon is enabled,
+- 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 (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.
 
 -- 
 Peter Palfrader, Mon, 24 Jul 2006 05:20:30 +0200
+                 Sat, 23 Feb 2008 13:44:40 +0100

Modified: tor/trunk/debian/changelog
===================================================================
--- tor/trunk/debian/changelog	2008-02-23 00:50:45 UTC (rev 13684)
+++ tor/trunk/debian/changelog	2008-02-23 12:59:52 UTC (rev 13685)
@@ -10,8 +10,11 @@
     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
     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 at debian.org>  Wed, 20 Feb 2008 23:38:45 +0100
+ -- Peter Palfrader <weasel at debian.org>  Sat, 23 Feb 2008 13:44:56 +0100
 
 tor (0.2.0.19-alpha-1) experimental; urgency=low
 

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



More information about the tor-commits mailing list