since 0.1.2.2-alpha, and all the servers seem to be using the new
eventdns code.
+ o Minor bufixes (portability):
+ - Even though windows is equally happy with / and \ as path separators,
+ try to use \ consistently on windows and / consistently on unix: it
+ makes the log messages nicer.
+
Changes in version 0.1.2.10-rc - 2007-03-07
o Major bugfixes (Windows):
}
tor_assert(home);
/* Remove trailing slash. */
- if (strlen(home)>1 && !strcmpend(home,"/")) {
+ if (strlen(home)>1 && !strcmpend(home,PATH_SEPARATOR)) {
home[strlen(home)-1] = '\0';
}
/* Plus one for /, plus one for NUL.
* Round up to 16 in case we can't do math. */
len = strlen(home)+strlen(rest)+16;
result = tor_malloc(len);
- tor_snprintf(result,len,"%s/%s",home,rest?rest:"");
+ tor_snprintf(result,len,"%s"PATH_SEPARATOR"%s",home,rest?rest:"");
tor_free(home);
return result;
} else {
if (running_tor) {
len = strlen(options->DataDirectory)+32;
fn = tor_malloc(len);
- tor_snprintf(fn, len, "%s/cached-status", options->DataDirectory);
+ tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
+ options->DataDirectory);
if (check_private_dir(fn, CPD_CREATE) != 0) {
log_err(LD_CONFIG,
"Couldn't access/create private data directory \"%s\"", fn);
* want. */
log_warn(LD_CONFIG,
"Default DataDirectory is \"~/.tor\". This expands to "
- "\"%s\", which is probably not what you want. Using \"%s/tor\" "
- "instead", fn, LOCALSTATEDIR);
+ "\"%s\", which is probably not what you want. Using "
+ "\"%s"PATH_SEPARATOR"tor\" instead", fn, LOCALSTATEDIR);
tor_free(fn);
- fn = tor_strdup(LOCALSTATEDIR"/tor");
-
+ fn = tor_strdup(LOCALSTATEDIR PATH_SEPARATOR "tor");
}
tor_free(options->DataDirectory);
options->DataDirectory = fn;
or_options_t *options = get_options();
size_t len = strlen(options->DataDirectory) + 16;
fname = tor_malloc(len);
- tor_snprintf(fname, len, "%s/state", options->DataDirectory);
+ tor_snprintf(fname, len, "%s"PATH_SEPARATOR"state", options->DataDirectory);
return fname;
}
return 0;
}
- tor_snprintf(fname, sizeof(fname), "%s/control_auth_cookie",
+ tor_snprintf(fname, sizeof(fname), "%s"PATH_SEPARATOR"control_auth_cookie",
get_options()->DataDirectory);
crypto_rand(authentication_cookie, AUTHENTICATION_COOKIE_LEN);
authentication_cookie_is_set = 1;
U64_PRINTF_ARG(ROUND_UP(n_bytes_written_in_interval)),
(unsigned long)n_seconds_active_in_interval,
(unsigned long)expected);
- tor_snprintf(fname, sizeof(fname), "%s/bw_accounting",
+ tor_snprintf(fname, sizeof(fname), "%s"PATH_SEPARATOR"bw_accounting",
get_options()->DataDirectory);
if (!get_options()->AvoidDiskWrites || (last_recorded + 3600 < now)) {
r = write_str_to_file(fname, buf, 0);
router_rebuild_descriptor(1);
descriptor = router_get_my_descriptor();
if (descriptor) {
- tor_snprintf(keydir,sizeof(keydir),"%s/router.desc",
+ tor_snprintf(keydir,sizeof(keydir),"%s"PATH_SEPARATOR"router.desc",
options->DataDirectory);
log_info(LD_OR,"Saving descriptor to \"%s\"...",keydir);
if (write_str_to_file(keydir, descriptor, 0)) {
/* Load key */
if (strlcpy(fname,s->directory,sizeof(fname)) >= sizeof(fname) ||
- strlcat(fname,"/private_key",sizeof(fname)) >= sizeof(fname)) {
+ strlcat(fname,PATH_SEPARATOR"private_key",sizeof(fname))
+ >= sizeof(fname)) {
log_warn(LD_CONFIG, "Directory name too long to store key file: \"%s\".",
s->directory);
return -1;
return -1;
}
if (strlcpy(fname,s->directory,sizeof(fname)) >= sizeof(fname) ||
- strlcat(fname,"/hostname",sizeof(fname)) >= sizeof(fname)) {
+ strlcat(fname,PATH_SEPARATOR"hostname",sizeof(fname))
+ >= sizeof(fname)) {
log_warn(LD_CONFIG, "Directory name too long to store hostname file:"
" \"%s\".", s->directory);
return -1;
or_state_t *state = get_or_state();
time_t now;
tor_snprintf(fname,sizeof(fname),
- "%s/keys/secret_onion_key",get_options()->DataDirectory);
+ "%s"PATH_SEPARATOR"keys"PATH_SEPARATOR"secret_onion_key",
+ get_options()->DataDirectory);
tor_snprintf(fname_prev,sizeof(fname_prev),
- "%s/keys/secret_onion_key.old",get_options()->DataDirectory);
+ "%s"PATH_SEPARATOR"keys"PATH_SEPARATOR"secret_onion_key.old",
+ get_options()->DataDirectory);
if (!(prkey = crypto_new_pk_env())) {
log_err(LD_GENERAL,"Error constructing rotated onion key");
goto error;
return -1;
}
/* Check the key directory. */
- tor_snprintf(keydir,sizeof(keydir),"%s/keys", datadir);
+ tor_snprintf(keydir,sizeof(keydir),"%s"PATH_SEPARATOR"keys", datadir);
if (check_private_dir(keydir, CPD_CREATE)) {
return -1;
}
/* 1. Read identity key. Make it if none is found. */
- tor_snprintf(keydir,sizeof(keydir),"%s/keys/secret_id_key",datadir);
+ tor_snprintf(keydir,sizeof(keydir),
+ "%s"PATH_SEPARATOR"keys"PATH_SEPARATOR"secret_id_key",datadir);
log_info(LD_GENERAL,"Reading/making identity key \"%s\"...",keydir);
prkey = init_key_from_file(keydir);
if (!prkey) return -1;
set_identity_key(prkey);
/* 2. Read onion key. Make it if none is found. */
- tor_snprintf(keydir,sizeof(keydir),"%s/keys/secret_onion_key",datadir);
+ tor_snprintf(keydir,sizeof(keydir),
+ "%s"PATH_SEPARATOR"keys"PATH_SEPARATOR"secret_onion_key",datadir);
log_info(LD_GENERAL,"Reading/making onion key \"%s\"...",keydir);
prkey = init_key_from_file(keydir);
if (!prkey) return -1;
or_state_mark_dirty(state, options->AvoidDiskWrites ? time(NULL)+3600 : 0);
}
- tor_snprintf(keydir,sizeof(keydir),"%s/keys/secret_onion_key.old",datadir);
+ tor_snprintf(keydir,sizeof(keydir),
+ "%s"PATH_SEPARATOR"keys"PATH_SEPARATOR"secret_onion_key.old",datadir);
if (file_status(keydir) == FN_FILE) {
prkey = init_key_from_file(keydir);
if (prkey)
}
/* 5. Dump fingerprint to 'fingerprint' */
- tor_snprintf(keydir,sizeof(keydir),"%s/fingerprint", datadir);
+ tor_snprintf(keydir,sizeof(keydir),"%s"PATH_SEPARATOR"fingerprint", datadir);
log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir);
if (crypto_pk_get_fingerprint(get_identity_key(), fingerprint, 1)<0) {
log_err(LD_GENERAL,"Error computing fingerprint");
if (!networkstatus_list)
networkstatus_list = smartlist_create();
- tor_snprintf(filename,sizeof(filename),"%s/cached-status",
+ tor_snprintf(filename,sizeof(filename),"%s"PATH_SEPARATOR"cached-status",
get_options()->DataDirectory);
entries = tor_listdir(filename);
SMARTLIST_FOREACH(entries, const char *, fn, {
"Skipping cached-status file with unexpected name \"%s\"",fn);
continue;
}
- tor_snprintf(filename,sizeof(filename),"%s/cached-status/%s",
+ tor_snprintf(filename,sizeof(filename),
+ "%s"PATH_SEPARATOR"cached-status"PATH_SEPARATOR"%s",
get_options()->DataDirectory, fn);
s = read_file_to_str(filename, 0, &st);
if (s) {
const char *body = signed_descriptor_get_body(desc);
size_t len = desc->signed_descriptor_len;
- tor_snprintf(fname, fname_len, "%s/cached-routers.new",
+ tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"cached-routers.new",
options->DataDirectory);
tor_assert(len == strlen(body));
fname_len = strlen(options->DataDirectory)+32;
fname = tor_malloc(fname_len);
fname_tmp = tor_malloc(fname_len);
- tor_snprintf(fname, fname_len, "%s/cached-routers", options->DataDirectory);
- tor_snprintf(fname_tmp, fname_len, "%s/cached-routers.tmp",
+ tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"cached-routers",
+ options->DataDirectory);
+ tor_snprintf(fname_tmp, fname_len, "%s"PATH_SEPARATOR"cached-routers.tmp",
options->DataDirectory);
chunk_list = smartlist_create();
});
}
- tor_snprintf(fname, fname_len, "%s/cached-routers.new",
+ tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"cached-routers.new",
options->DataDirectory);
write_str_to_file(fname, "", 1);
router_journal_len = router_store_len = 0;
- tor_snprintf(fname, fname_len, "%s/cached-routers", options->DataDirectory);
+ tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"cached-routers",
+ options->DataDirectory);
if (routerlist->mmap_descriptors) /* get rid of it first */
tor_munmap_file(routerlist->mmap_descriptors);
SAVED_IN_CACHE, NULL);
}
- tor_snprintf(fname, fname_len, "%s/cached-routers.new",
+ tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"cached-routers.new",
options->DataDirectory);
if (file_status(fname) == FN_FILE)
contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, NULL);
char fp[HEX_DIGEST_LEN+1];
char *fn = tor_malloc(len+1);
base16_encode(fp, HEX_DIGEST_LEN+1, identity_digest, DIGEST_LEN);
- tor_snprintf(fn, len, "%s/cached-status/%s",datadir,fp);
+ tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status"PATH_SEPARATOR"%s",
+ datadir,fp);
return fn;
}