mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
some fixes so far
svn:r2880
This commit is contained in:
parent
ea97cb9c64
commit
47993ae6fb
@ -187,7 +187,7 @@ static int write_configuration_file(const char *fname, or_options_t *options);
|
|||||||
|
|
||||||
/** Command-line and config-file options. */
|
/** Command-line and config-file options. */
|
||||||
static or_options_t *global_options=NULL;
|
static or_options_t *global_options=NULL;
|
||||||
/** Name of ost recently read torrc file. */
|
/** Name of most recently read torrc file. */
|
||||||
static char *config_fname = NULL;
|
static char *config_fname = NULL;
|
||||||
|
|
||||||
/** Return the currently configured options. */
|
/** Return the currently configured options. */
|
||||||
@ -325,7 +325,7 @@ options_act(void) {
|
|||||||
smin = config_dump_options(options, 1);
|
smin = config_dump_options(options, 1);
|
||||||
smax = config_dump_options(options, 0);
|
smax = config_dump_options(options, 0);
|
||||||
log_fn(LOG_DEBUG, "These are our options:\n%s",smax);
|
log_fn(LOG_DEBUG, "These are our options:\n%s",smax);
|
||||||
log_fn(LOG_DEBUGS, "We changed these options:\n%s",smin);
|
log_fn(LOG_DEBUG, "We changed these options:\n%s",smin);
|
||||||
tor_free(smin);
|
tor_free(smin);
|
||||||
tor_free(smax);
|
tor_free(smax);
|
||||||
}
|
}
|
||||||
@ -2081,16 +2081,25 @@ static int
|
|||||||
write_configuration_file(const char *fname, or_options_t *options)
|
write_configuration_file(const char *fname, or_options_t *options)
|
||||||
{
|
{
|
||||||
char fn_tmp[1024];
|
char fn_tmp[1024];
|
||||||
char *new_val=NULL, *new_conf=NULL;
|
char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
|
||||||
int rename_old = 0, r;
|
int rename_old = 0, r;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (fname && file_status(fname) == FN_FILE) {
|
if (fname) {
|
||||||
char *old_val = read_file_to_str(fname, 0);
|
switch (file_status(fname)) {
|
||||||
if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
|
case FN_FILE:
|
||||||
rename_old = 1;
|
old_val = read_file_to_str(fname, 0);
|
||||||
|
if (strcmpstart(old_val, GENERATED_FILE_PREFIX)) {
|
||||||
|
rename_old = 1;
|
||||||
|
}
|
||||||
|
tor_free(old_val);
|
||||||
|
break;
|
||||||
|
case FN_NOENT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_fn(LOG_WARN,"Config file %s is not a file? Failing.", fname);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
tor_free(old_val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(new_conf = config_dump_options(options, 1))) {
|
if (!(new_conf = config_dump_options(options, 1))) {
|
||||||
@ -2109,7 +2118,7 @@ write_configuration_file(const char *fname, or_options_t *options)
|
|||||||
log_fn(LOG_WARN, "Filename too long");
|
log_fn(LOG_WARN, "Filename too long");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (file_status(fn_tmp) != FN_FILE)
|
if (file_status(fn_tmp) == FN_NOENT)
|
||||||
break;
|
break;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -373,11 +373,10 @@ handle_control_saveconf(connection_t *conn, uint16_t len,
|
|||||||
const char *body)
|
const char *body)
|
||||||
{
|
{
|
||||||
if (save_current_config()<0) {
|
if (save_current_config()<0) {
|
||||||
send_control_done(conn);
|
|
||||||
} else {
|
|
||||||
send_control_error(conn, ERR_INTERNAL,
|
send_control_error(conn, ERR_INTERNAL,
|
||||||
"Unable to write configuration to disk.");
|
"Unable to write configuration to disk.");
|
||||||
}
|
}
|
||||||
|
send_control_done(conn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,32 +140,33 @@ directory_post_to_dirservers(uint8_t purpose, const char *payload,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Start a connection to a random running directory server, using connection
|
/** Start a connection to a random running directory server, using
|
||||||
* purpose 'purpose' requesting 'payload' (length 'payload_len'). The purpose
|
* connection purpose 'purpose' requesting 'resource'. The purpose
|
||||||
* should be one of 'DIR_PURPOSE_FETCH_DIR' or 'DIR_PURPOSE_FETCH_RENDDESC' or
|
* should be one of 'DIR_PURPOSE_FETCH_DIR',
|
||||||
* 'DIR_PURPOSE_FETCH_RUNNING_LIST.'
|
* 'DIR_PURPOSE_FETCH_RENDDESC', 'DIR_PURPOSE_FETCH_RUNNING_LIST.'
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
directory_get_from_dirserver(uint8_t purpose, const char *resource)
|
directory_get_from_dirserver(uint8_t purpose, const char *resource)
|
||||||
{
|
{
|
||||||
routerinfo_t *r = NULL;
|
routerinfo_t *r = NULL;
|
||||||
trusted_dir_server_t *ds = NULL;
|
trusted_dir_server_t *ds = NULL;
|
||||||
|
int fascistfirewall = get_options()->FascistFirewall;
|
||||||
|
|
||||||
if (purpose == DIR_PURPOSE_FETCH_DIR) {
|
if (purpose == DIR_PURPOSE_FETCH_DIR) {
|
||||||
if (advertised_server_mode()) {
|
if (advertised_server_mode()) {
|
||||||
/* only ask authdirservers, and don't ask myself */
|
/* only ask authdirservers, and don't ask myself */
|
||||||
ds = router_pick_trusteddirserver(1, get_options()->FascistFirewall);
|
ds = router_pick_trusteddirserver(1, fascistfirewall);
|
||||||
} else {
|
} else {
|
||||||
/* anybody with a non-zero dirport will do */
|
/* anybody with a non-zero dirport will do */
|
||||||
r = router_pick_directory_server(1, get_options()->FascistFirewall);
|
r = router_pick_directory_server(1, fascistfirewall);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
log_fn(LOG_INFO, "No router found for directory; falling back to dirserver list");
|
log_fn(LOG_INFO, "No router found for directory; falling back to dirserver list");
|
||||||
ds = router_pick_trusteddirserver(1, get_options()->FascistFirewall);
|
ds = router_pick_trusteddirserver(1, fascistfirewall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
} else if (purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
||||||
/* right now, running-routers isn't cached, so ask a trusted directory */
|
/* right now, running-routers isn't cached, so ask a trusted directory */
|
||||||
ds = router_pick_trusteddirserver(0, get_options()->FascistFirewall);
|
ds = router_pick_trusteddirserver(0, fascistfirewall);
|
||||||
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
|
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
|
||||||
/* only ask authdirservers, any of them will do */
|
/* only ask authdirservers, any of them will do */
|
||||||
/* Never use fascistfirewall; we're going via Tor. */
|
/* Never use fascistfirewall; we're going via Tor. */
|
||||||
|
Loading…
Reference in New Issue
Block a user