summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug117875
-rw-r--r--changes/bug120614
-rw-r--r--changes/bug1270010
-rw-r--r--changes/bug127284
-rw-r--r--changes/bug128647
-rw-r--r--changes/bug129084
-rw-r--r--doc/tor.1.txt9
-rwxr-xr-xscripts/maint/checkSpace.pl30
-rw-r--r--src/common/compat.c13
-rw-r--r--src/common/torgzip.c2
-rw-r--r--src/or/config.c23
-rw-r--r--src/or/config.h2
-rw-r--r--src/or/control.c1
-rw-r--r--src/or/ext_orport.c1
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/relay.c8
-rw-r--r--src/or/router.c2
-rw-r--r--src/test/test_entrynodes.c17
18 files changed, 133 insertions, 11 deletions
diff --git a/changes/bug11787 b/changes/bug11787
new file mode 100644
index 0000000000..014662d921
--- /dev/null
+++ b/changes/bug11787
@@ -0,0 +1,5 @@
+ o Minor bugfixes (directory bandwidth performance):
+ - Don't flush the zlib buffer aggressively when compressing
+ directory information for clients. This should save about 7% of
+ the bandwidth currently used for compressed descriptors and
+ microdescriptors. Fixes bug 11787; bugfix on 0.1.1.23.
diff --git a/changes/bug12061 b/changes/bug12061
new file mode 100644
index 0000000000..308417cce8
--- /dev/null
+++ b/changes/bug12061
@@ -0,0 +1,4 @@
+ o Minor features:
+ - On unix, you can now use named pipes as the target of the Log
+ option, and other options that try to append to files. Closes
+ ticket 12061. Patch from "carlo von lynX".
diff --git a/changes/bug12700 b/changes/bug12700
new file mode 100644
index 0000000000..1d8caeb8bd
--- /dev/null
+++ b/changes/bug12700
@@ -0,0 +1,10 @@
+ o Minor bugfixes:
+ - When logging information about an EXTEND2 or EXTENDED2 cell, log
+ their names correctly. Fixes part of bug 12700; bugfix on
+ 0.2.4.8-alpha.
+
+ o Minor bugfixes:
+ - When logging information about a relay cell whose command we
+ don't recognize, log its command as an integer. Fixes part of
+ bug 12700; bugfix on 0.2.1.10-alpha.
+
diff --git a/changes/bug12728 b/changes/bug12728
new file mode 100644
index 0000000000..ee392457b4
--- /dev/null
+++ b/changes/bug12728
@@ -0,0 +1,4 @@
+
+ o Minor bugfixes:
+ - When generating our family list, remove spaces from around the
+ entries there. Fixes bug 12728; bugfix on 0.2.1.7-alpha.
diff --git a/changes/bug12864 b/changes/bug12864
new file mode 100644
index 0000000000..79e751f427
--- /dev/null
+++ b/changes/bug12864
@@ -0,0 +1,7 @@
+ o Minor bugfixes:
+ - Restore the functionality of CookieAuthFileGroupReadable. Fixes bug
+ 12864; bugfix on 0.2.5.1-alpha.
+
+ o Minor features:
+ - Add an ExtORPortCookieAuthFileGroupReadable option to make the
+ cookie file for the ExtORPort g+r by default.
diff --git a/changes/bug12908 b/changes/bug12908
new file mode 100644
index 0000000000..bd6784cbd2
--- /dev/null
+++ b/changes/bug12908
@@ -0,0 +1,4 @@
+ o Minor features:
+ - Warn about attempts to run hidden services and relays in the
+ same process: that's probably not a good idea. Closes ticket
+ 12908.
diff --git a/doc/tor.1.txt b/doc/tor.1.txt
index 5a16a70b2c..ce42a9bed9 100644
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@ -224,6 +224,13 @@ GENERAL OPTIONS
for the Extended ORPort's cookie file -- the cookie file is needed
for pluggable transports to communicate through the Extended ORPort.
+[[ExtORPortCookieAuthFileGroupReadable]] **ExtORPortCookieAuthFileGroupReadable** **0**|**1**::
+ If this option is set to 0, don't allow the filesystem group to read the
+ Extended OR Port cookie file. If the option is set to 1, make the cookie
+ file readable by the default GID. [Making the file readable by other
+ groups is not yet implemented; let us know if you need this for some
+ reason.] (Default: 0)
+
[[ConnLimit]] **ConnLimit** __NUM__::
The minimum number of file descriptors that must be available to the Tor
process before it will start. Tor will ask the OS for as many file
@@ -312,7 +319,7 @@ GENERAL OPTIONS
If set, this option overrides the default location and file name
for Tor's cookie file. (See CookieAuthentication above.)
-[[CookieAuthFileGroupReadable]] **CookieAuthFileGroupReadable** **0**|**1**|__Groupname__::
+[[CookieAuthFileGroupReadable]] **CookieAuthFileGroupReadable** **0**|**1**::
If this option is set to 0, don't allow the filesystem group to read the
cookie file. If the option is set to 1, make the cookie file readable by
the default GID. [Making the file readable by other groups is not yet
diff --git a/scripts/maint/checkSpace.pl b/scripts/maint/checkSpace.pl
index 682dbced00..b529103367 100755
--- a/scripts/maint/checkSpace.pl
+++ b/scripts/maint/checkSpace.pl
@@ -13,30 +13,45 @@ for $fn (@ARGV) {
$incomment = 0;
while (<F>) {
## Warn about windows-style newlines.
+ # (We insist on lines that end with a single LF character, not
+ # CR LF.)
if (/\r/) {
print " CR:$fn:$.\n";
}
## Warn about tabs.
+ # (We only use spaces)
if (/\t/) {
print " TAB:$fn:$.\n";
}
- ## Warn about markers that don't have a space in front of them
+ ## Warn about labels that don't have a space in front of them
+ # (We indent every label at least one space)
if (/^[a-zA-Z_][a-zA-Z_0-9]*:/) {
print "nosplabel:$fn:$.\n";
}
## Warn about trailing whitespace.
+ # (We don't allow whitespace at the end of the line; make your
+ # editor highlight it for you so you can stop adding it in.)
if (/ +$/) {
print "Space\@EOL:$fn:$.\n";
}
## Warn about control keywords without following space.
+ # (We put a space after every 'if', 'while', 'for', 'switch', etc)
if ($C && /\s(?:if|while|for|switch)\(/) {
print " KW(:$fn:$.\n";
}
## Warn about #else #if instead of #elif.
+ # (We only allow #elif)
if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
print " #else#if:$fn:$.\n";
}
## Warn about some K&R violations
+ # (We use K&R-style C, where open braces go on the same line as
+ # the statement that introduces them. In other words:
+ # if (a) {
+ # stuff;
+ # } else {
+ # other stuff;
+ # }
if (/^\s+\{/ and $lastline =~ /^\s*(if|while|for|else if)/ and
$lastline !~ /\{$/) {
print "non-K&R {:$fn:$.\n";
@@ -46,10 +61,13 @@ for $fn (@ARGV) {
}
$lastline = $_;
## Warn about unnecessary empty lines.
+ # (Don't put an empty line before a line that contains nothing
+ # but a closing brace.)
if ($lastnil && /^\s*}\n/) {
print " UnnecNL:$fn:$.\n";
}
## Warn about multiple empty lines.
+ # (At most one blank line in a row.)
if ($lastnil && /^$/) {
print " DoubleNL:$fn:$.\n";
} elsif (/^$/) {
@@ -59,6 +77,7 @@ for $fn (@ARGV) {
}
## Terminals are still 80 columns wide in my world. I refuse to
## accept double-line lines.
+ # (Don't make lines wider than 80 characters, including newline.)
if (/^.{80}/) {
print " Wide:$fn:$.\n";
}
@@ -83,11 +102,13 @@ for $fn (@ARGV) {
s!"(?:[^\"]+|\\.)*"!"X"!g;
next if /^\#/;
## Warn about C++-style comments.
+ # (Use C style comments only.)
if (m!//!) {
# print " //:$fn:$.\n";
s!//.*!!;
}
## Warn about unquoted braces preceded by non-space.
+ # (No character except a space should come before a {)
if (/([^\s'])\{/) {
print " $1\{:$fn:$.\n";
}
@@ -101,6 +122,8 @@ for $fn (@ARGV) {
# print " {X:$fn:$.\n";
#}
## Warn about function calls with space before parens.
+ # (Don't put a space between the name of a function and its
+ # arguments.)
if (/(\w+)\s\(([A-Z]*)/) {
if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
$1 ne "switch" and $1 ne "return" and $1 ne "int" and
@@ -110,6 +133,9 @@ for $fn (@ARGV) {
}
}
## Warn about functions not declared at start of line.
+ # (When you're declaring functions, put "static" and "const"
+ # and the return type on one line, and the function name at
+ # the start of a new line.)
if ($in_func_head ||
($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
@@ -130,6 +156,8 @@ for $fn (@ARGV) {
}
}
}
+ ## Warn if the file doesn't end with a blank line.
+ # (End each file with a single blank line.)
if (! $lastnil) {
print " EOL\@EOF:$fn:$.\n";
}
diff --git a/src/common/compat.c b/src/common/compat.c
index c4f5987d5a..278e5c5241 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -981,14 +981,23 @@ tor_fd_getpos(int fd)
#endif
}
-/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success. */
+/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success.
+ * If the file is a pipe, do nothing and succeed.
+ **/
int
tor_fd_seekend(int fd)
{
#ifdef _WIN32
return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
#else
- return lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+ off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+#ifdef ESPIPE
+ /* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
+ * no need to worry. */
+ if (rc < 0 && errno == ESPIPE)
+ rc = 0;
+#endif
+ return (rc < 0) ? -1 : 0;
#endif
}
diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 15451ee30d..239cab9cac 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -472,7 +472,7 @@ tor_zlib_process(tor_zlib_state_t *state,
state->stream.avail_out = (unsigned int)*out_len;
if (state->compress) {
- err = deflate(&state->stream, finish ? Z_FINISH : Z_SYNC_FLUSH);
+ err = deflate(&state->stream, finish ? Z_FINISH : Z_NO_FLUSH);
} else {
err = inflate(&state->stream, finish ? Z_FINISH : Z_SYNC_FLUSH);
}
diff --git a/src/or/config.c b/src/or/config.c
index 2535a72d39..3e1eb2dc0e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -238,6 +238,7 @@ static config_var_t option_vars_[] = {
V(ExtendAllowPrivateAddresses, BOOL, "0"),
VPORT(ExtORPort, LINELIST, NULL),
V(ExtORPortCookieAuthFile, STRING, NULL),
+ V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"),
V(ExtraInfoStatistics, BOOL, "1"),
V(FallbackDir, LINELIST, NULL),
@@ -2566,6 +2567,13 @@ options_validate(or_options_t *old_options, or_options_t *options,
REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
#endif
+ if (server_mode(options) && options->RendConfigLines)
+ log_warn(LD_CONFIG,
+ "Tor is currently configured as a relay and a hidden service. "
+ "That's not very secure: you should probably run your hidden service "
+ "in a separate Tor process, at least -- see "
+ "https://trac.torproject.org/8742");
+
/* XXXX require that the only port not be DirPort? */
/* XXXX require that at least one port be listened-upon. */
if (n_ports == 0 && !options->RendConfigLines)
@@ -6843,11 +6851,14 @@ config_maybe_load_geoip_files_(const or_options_t *options,
* in <b>cookie_out</b>.
* Then write it down to <b>fname</b> and prepend it with <b>header</b>.
*
+ * If <b>group_readable</b> is set, set <b>fname</b> to be readable
+ * by the default GID.
+ *
* If the whole procedure was successful, set
* <b>cookie_is_set_out</b> to True. */
int
init_cookie_authentication(const char *fname, const char *header,
- int cookie_len,
+ int cookie_len, int group_readable,
uint8_t **cookie_out, int *cookie_is_set_out)
{
char cookie_file_str_len = strlen(header) + cookie_len;
@@ -6880,6 +6891,16 @@ init_cookie_authentication(const char *fname, const char *header,
goto done;
}
+#ifndef _WIN32
+ if (group_readable) {
+ if (chmod(fname, 0640)) {
+ log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
+ }
+ }
+#else
+ (void) group_readable;
+#endif
+
/* Success! */
log_info(LD_GENERAL, "Generated auth cookie file in '%s'.", escaped(fname));
*cookie_is_set_out = 1;
diff --git a/src/or/config.h b/src/or/config.h
index bf386134b8..8a1919c2ed 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -97,7 +97,7 @@ uint32_t get_effective_bwburst(const or_options_t *options);
char *get_transport_bindaddr_from_config(const char *transport);
int init_cookie_authentication(const char *fname, const char *header,
- int cookie_len,
+ int cookie_len, int group_readable,
uint8_t **cookie_out, int *cookie_is_set_out);
or_options_t *options_new(void);
diff --git a/src/or/control.c b/src/or/control.c
index c0f9a355b2..a920ac835e 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4666,6 +4666,7 @@ init_control_cookie_authentication(int enabled)
fname = get_controller_cookie_file_name();
retval = init_cookie_authentication(fname, "", /* no header */
AUTHENTICATION_COOKIE_LEN,
+ get_options()->CookieAuthFileGroupReadable,
&authentication_cookie,
&authentication_cookie_is_set);
tor_free(fname);
diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c
index 0d28a9199a..9b550ee90e 100644
--- a/src/or/ext_orport.c
+++ b/src/or/ext_orport.c
@@ -143,6 +143,7 @@ init_ext_or_cookie_authentication(int is_enabled)
fname = get_ext_or_auth_cookie_file_name();
retval = init_cookie_authentication(fname, EXT_OR_PORT_AUTH_COOKIE_HEADER,
EXT_OR_PORT_AUTH_COOKIE_HEADER_LEN,
+ get_options()->ExtORPortCookieAuthFileGroupReadable,
&ext_or_auth_cookie,
&ext_or_auth_cookie_is_set);
tor_free(fname);
diff --git a/src/or/or.h b/src/or/or.h
index e106a745b2..3683607741 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3803,6 +3803,8 @@ typedef struct {
char *ExtORPortCookieAuthFile; /**< Filesystem location of Extended
* ORPort authentication cookie. */
int CookieAuthFileGroupReadable; /**< Boolean: Is the CookieAuthFile g+r? */
+ int ExtORPortCookieAuthFileGroupReadable; /**< Boolean: Is the
+ * ExtORPortCookieAuthFile g+r? */
int LeaveStreamsUnattached; /**< Boolean: Does Tor attach new streams to
* circuits itself (0), or does it expect a controller
* to cope? (1) */
diff --git a/src/or/relay.c b/src/or/relay.c
index e013925746..bb60469066 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -523,6 +523,7 @@ relay_header_unpack(relay_header_t *dest, const uint8_t *src)
static const char *
relay_command_to_string(uint8_t command)
{
+ static char buf[64];
switch (command) {
case RELAY_COMMAND_BEGIN: return "BEGIN";
case RELAY_COMMAND_DATA: return "DATA";
@@ -547,7 +548,12 @@ relay_command_to_string(uint8_t command)
case RELAY_COMMAND_RENDEZVOUS_ESTABLISHED:
return "RENDEZVOUS_ESTABLISHED";
case RELAY_COMMAND_INTRODUCE_ACK: return "INTRODUCE_ACK";
- default: return "(unrecognized)";
+ case RELAY_COMMAND_EXTEND2: return "EXTEND2";
+ case RELAY_COMMAND_EXTENDED2: return "EXTENDED2";
+ default:
+ tor_snprintf(buf, sizeof(buf), "Unrecognized relay command %u",
+ (unsigned)command);
+ return buf;
}
}
diff --git a/src/or/router.c b/src/or/router.c
index 4fcd4a5b89..87b6705d84 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1879,7 +1879,7 @@ router_rebuild_descriptor(int force)
family = smartlist_new();
ri->declared_family = smartlist_new();
smartlist_split_string(family, options->MyFamily, ",",
- SPLIT_SKIP_SPACE|SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+ SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK|SPLIT_STRIP_SPACE, 0);
SMARTLIST_FOREACH_BEGIN(family, char *, name) {
const node_t *member;
if (!strcasecmp(name, options->Nickname))
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index ede93fb43a..83ceea7ce6 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -325,6 +325,19 @@ state_lines_free(smartlist_t *entry_guard_lines)
smartlist_free(entry_guard_lines);
}
+/* Return a statically allocated string representing yesterday's date
+ * in ISO format. We use it so that state file items are not found to
+ * be outdated. */
+static const char *
+get_yesterday_date_str(void)
+{
+ static char buf[ISO_TIME_LEN+1];
+
+ time_t yesterday = time(NULL) - 24*60*60;
+ format_iso_time(buf, yesterday);
+ return buf;
+}
+
/* Tests entry_guards_parse_state(). It creates a fake Tor state with
a saved entry guard and makes sure that Tor can parse it and
creates the right entry node out of it.
@@ -342,7 +355,7 @@ test_entry_guards_parse_state_simple(void *arg)
const char *nickname = "hagbard";
const char *fpr = "B29D536DD1752D542E1FBB3C9CE4449D51298212";
const char *tor_version = "0.2.5.3-alpha-dev";
- const char *added_at = "2014-05-22 02:40:47";
+ const char *added_at = get_yesterday_date_str();
const char *unlisted_since = "2014-06-08 16:16:50";
(void) arg;
@@ -457,7 +470,7 @@ test_entry_guards_parse_state_pathbias(void *arg)
smartlist_add_asprintf(state_line, "EntryGuardAddedBy");
smartlist_add_asprintf(state_line,
"B29D536DD1752D542E1FBB3C9CE4449D51298212 0.2.5.3-alpha-dev "
- "2014-05-22 02:40:47");
+ "%s", get_yesterday_date_str());
smartlist_add(entry_state_lines, state_line);
state_line = smartlist_new();