]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a ControlPortFileGroupWritable option
authorNick Mathewson <nickm@torproject.org>
Thu, 12 May 2011 23:17:48 +0000 (19:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 13 May 2011 14:41:29 +0000 (10:41 -0400)
changes/feature3076
doc/tor.1.txt
src/or/config.c
src/or/control.c
src/or/or.h

index ed42e4595bbe614e622362092d43d951b8b940cf..a3dcec87411291e640a90f8769093e312627c84e 100644 (file)
@@ -7,5 +7,8 @@
       type.  This is useful for if the user has selected SocksPort
       "auto", and you need to know which port got chosen.
     - There is a ControlPortWriteToFile option that tells Tor to write
-      its actual control port or ports to a chosen file.
+      its actual control port or ports to a chosen file.  If the option
+      ControlPortFileGroupReadable is set, the file is created as
+      group-readable.
+
 
index 606580db55fe094fbfd7c3f3c1ee6ad19e983b46..d95d764c670fcf21fa050e0f120a63874ff9dc96 100644 (file)
@@ -196,6 +196,11 @@ Other options can be specified either on the command-line (--option
     this address.  Usable by controllers to learn the actual control port
     when ControlPort is set to "auto".
 
+**ControlPortFileGroupReadable** **0**|**1**::
+    If this option is set to 0, don't allow the filesystem group to read the
+    control port file. If the option is set to 1, make the control port
+    file readable by the default GID. (Default: 0).
+
 **DataDirectory** __DIR__::
     Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor)
 
index 5eb62291bc5b83c068e4f534171059ee0821e69b..a7ff28f46274c488382a05e2de2774d52fb7d16b 100644 (file)
@@ -206,6 +206,7 @@ static config_var_t _option_vars[] = {
   V(ContactInfo,                 STRING,   NULL),
   V(ControlListenAddress,        LINELIST, NULL),
   V(ControlPort,                 PORT,     "0"),
+  V(ControlPortFileGroupReadable,BOOL,     "0"),
   V(ControlPortWriteToFile,      FILENAME, NULL),
   V(ControlSocket,               LINELIST, NULL),
   V(CookieAuthentication,        BOOL,     "0"),
index 634674233c0826419fc079d761bbadbf64aabf48..384e579f936abc41e2e81f567d6bb4e95586461b 100644 (file)
@@ -542,6 +542,14 @@ control_ports_write_to_file(void)
     log_warn(LD_CONTROL, "Writing %s failed: %s",
              options->ControlPortWriteToFile, strerror(errno));
   }
+#ifndef MS_WINDOWS
+  if (options->ControlPortFileGroupReadable) {
+    if (chmod(options->ControlPortWriteToFile, 0640)) {
+      log_warn(LD_FS,"Unable to make %s group-readable.",
+               options->ControlPortWriteToFile);
+    }
+  }
+#endif
   tor_free(joined);
   SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
   smartlist_free(lines);
index 412aac98221f9ffae0c1e84655f86994f6738b35..a73d98ab74cf863948dd4da0b2a9f01863f321f9 100644 (file)
@@ -2876,6 +2876,8 @@ typedef struct {
 
   /** File where we should write the ControlPort. */
   char *ControlPortWriteToFile;
+  /** Should that file be group-readable? */
+  int ControlPortFileGroupReadable;
 
 } or_options_t;