[or-cvs] r16998: {tor} If we have correct permissions on $datadir, we complain to s (in tor/trunk: . src/or)
arma at seul.org
arma at seul.org
Mon Sep 29 10:09:06 UTC 2008
Author: arma
Date: 2008-09-29 06:09:05 -0400 (Mon, 29 Sep 2008)
New Revision: 16998
Modified:
tor/trunk/ChangeLog
tor/trunk/src/or/config.c
Log:
If we have correct permissions on $datadir, we complain to stdout
and fail to start. But dangerous permissions on
$datadir/cached-status/ would cause us to open a log and complain
there. Now complain to stdout and fail to start in both cases. Fixes
bug 820, reported by seeess.
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2008-09-29 09:36:42 UTC (rev 16997)
+++ tor/trunk/ChangeLog 2008-09-29 10:09:05 UTC (rev 16998)
@@ -99,6 +99,11 @@
circuit, then it could establish the last hop by using the existing
connection. Bugfix on 0.1.2.2-alpha, exposed when we made testing
circuits no longer use entry guards in 0.2.1.3-alpha.
+ - If we have correct permissions on $datadir, we complain to stdout
+ and fail to start. But dangerous permissions on
+ $datadir/cached-status/ would cause us to open a log and complain
+ there. Now complain to stdout and fail to start in both cases. Fixes
+ bug 820, reported by seeess.
o Code simplifications and refactoring:
- Revise the connection_new functions so that a more typesafe variant
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2008-09-29 09:36:42 UTC (rev 16997)
+++ tor/trunk/src/or/config.c 2008-09-29 10:09:05 UTC (rev 16998)
@@ -1108,6 +1108,22 @@
/* No need to roll back, since you can't change the value. */
}
+ if (directory_caches_v2_dir_info(options)) {
+ size_t len = strlen(options->DataDirectory)+32;
+ char *fn = tor_malloc(len);
+ tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
+ options->DataDirectory);
+ if (check_private_dir(fn, running_tor ? CPD_CREATE : CPD_CHECK) < 0) {
+ char buf[1024];
+ int tmp = tor_snprintf(buf, sizeof(buf),
+ "Couldn't access/create private data directory \"%s\"", fn);
+ *msg = tor_strdup(tmp >= 0 ? buf : "internal error");
+ tor_free(fn);
+ goto done;
+ }
+ tor_free(fn);
+ }
+
/* Bail out at this point if we're not going to be a client or server:
* we don't run Tor itself. */
if (!running_tor)
@@ -1203,8 +1219,6 @@
options_act(or_options_t *old_options)
{
config_line_t *cl;
- char *fn;
- size_t len;
or_options_t *options = get_options();
int running_tor = options->command == CMD_RUN_TOR;
char *msg;
@@ -1240,20 +1254,6 @@
return -1;
}
- if (running_tor && directory_caches_v2_dir_info(options)) {
- len = strlen(options->DataDirectory)+32;
- fn = tor_malloc(len);
- tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
- options->DataDirectory);
- if (check_private_dir(fn, CPD_CREATE) != 0) {
- log_warn(LD_CONFIG,
- "Couldn't access/create private data directory \"%s\"", fn);
- tor_free(fn);
- return -1;
- }
- tor_free(fn);
- }
-
/* Load state */
if (! global_state && running_tor) {
if (or_state_load())
More information about the tor-commits
mailing list