aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/config.c7
-rw-r--r--src/or/dirserv.c8
-rw-r--r--src/or/main.c3
3 files changed, 12 insertions, 6 deletions
diff --git a/src/or/config.c b/src/or/config.c
index dc2a1ec2b..6ce47263b 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -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;
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index cbdfb6b0a..5351c7493 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -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.");
diff --git a/src/or/main.c b/src/or/main.c
index 640edffe7..054097b7f 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -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;