mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
clients shouldn't create datadir until we have something to put there
svn:r2092
This commit is contained in:
parent
3c2c8ed42b
commit
6c56f34aaf
@ -945,10 +945,13 @@ const char *get_data_directory(or_options_t *options) {
|
||||
const char *d;
|
||||
if (options->DataDirectory)
|
||||
d = options->DataDirectory;
|
||||
else
|
||||
else if (server_mode())
|
||||
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);
|
||||
tor_free(options->DataDirectory);
|
||||
options->DataDirectory = fn;
|
||||
|
@ -673,9 +673,11 @@ size_t dirserv_get_directory(const char **directory)
|
||||
exit(0);
|
||||
}
|
||||
free(new_directory);
|
||||
sprintf(filename,"%s/cached-directory", get_data_directory(&options));
|
||||
if(write_str_to_file(filename,the_directory) < 0) {
|
||||
log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
|
||||
if(get_data_directory(&options)) {
|
||||
sprintf(filename,"%s/cached-directory", get_data_directory(&options));
|
||||
if(write_str_to_file(filename,the_directory) < 0) {
|
||||
log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log(LOG_INFO,"Directory still clean, reusing.");
|
||||
|
@ -667,7 +667,8 @@ static int init_from_config(int argc, char **argv) {
|
||||
}
|
||||
|
||||
/* 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",
|
||||
get_data_directory(&options));
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user