clients shouldn't create datadir until we have something to put there

svn:r2092
This commit is contained in:
Roger Dingledine 2004-07-22 00:13:42 +00:00
parent 3c2c8ed42b
commit 6c56f34aaf
3 changed files with 12 additions and 6 deletions

View File

@ -945,10 +945,13 @@ const char *get_data_directory(or_options_t *options) {
const char *d; const char *d;
if (options->DataDirectory) if (options->DataDirectory)
d = options->DataDirectory; d = options->DataDirectory;
else else if (server_mode())
d = "~/.tor"; d = "~/.tor";
else
d = NULL; /* XXX008 don't create datadir until we have something
we'll be putting in it */
if (strncmp(d,"~/",2)==0) { if (d && strncmp(d,"~/",2)==0) {
char *fn = expand_filename(d); char *fn = expand_filename(d);
tor_free(options->DataDirectory); tor_free(options->DataDirectory);
options->DataDirectory = fn; options->DataDirectory = fn;

View File

@ -673,9 +673,11 @@ size_t dirserv_get_directory(const char **directory)
exit(0); exit(0);
} }
free(new_directory); free(new_directory);
sprintf(filename,"%s/cached-directory", get_data_directory(&options)); if(get_data_directory(&options)) {
if(write_str_to_file(filename,the_directory) < 0) { sprintf(filename,"%s/cached-directory", get_data_directory(&options));
log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring."); if(write_str_to_file(filename,the_directory) < 0) {
log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
}
} }
} else { } else {
log(LOG_INFO,"Directory still clean, reusing."); log(LOG_INFO,"Directory still clean, reusing.");

View File

@ -667,7 +667,8 @@ static int init_from_config(int argc, char **argv) {
} }
/* Ensure data directory is private; create if possible. */ /* Ensure data directory is private; create if possible. */
if (check_private_dir(get_data_directory(&options), 1) != 0) { if (get_data_directory(&options) &&
check_private_dir(get_data_directory(&options), 1) != 0) {
log_fn(LOG_ERR, "Couldn't access/create private data directory %s", log_fn(LOG_ERR, "Couldn't access/create private data directory %s",
get_data_directory(&options)); get_data_directory(&options));
return -1; return -1;