From cad26b343dba0ee1047a0053256e2b9845f90743 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 9 Nov 2004 07:20:21 +0000 Subject: [PATCH] once normalized, DataDirectory is always defined svn:r2734 --- src/or/config.c | 18 ++++++------------ src/or/dirserv.c | 8 +++----- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index cebff82d39..d2a6a66172 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1013,13 +1013,6 @@ options_validate(or_options_t *options) if (normalize_log_options(options)) return -1; - - if (options->DataDirectory && - check_private_dir(options->DataDirectory, CPD_CHECK != 0)) { - log_fn(LOG_WARN, "Can't create directory %s", options->DataDirectory); - result = -1; - } - /* Special case if no options are given. */ if (!options->Logs) { options->Logs = config_line_prepend(NULL, "Log", "notice-err stdout"); @@ -1237,10 +1230,7 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val) { return -1; } - if ((old->DataDirectory && - (!new_val->DataDirectory || - strcmp(old->DataDirectory,new_val->DataDirectory)!=0)) || - (!old->DataDirectory && new_val->DataDirectory)) { + if (strcmp(old->DataDirectory,new_val->DataDirectory)!=0) { log_fn(LOG_WARN,"During reload, changing DataDirectory (%s->%s) is not allowed. Failing.", old->DataDirectory, new_val->DataDirectory); return -1; } @@ -1879,13 +1869,17 @@ normalize_data_directory(or_options_t *options) { static int validate_data_directory(or_options_t *options) { - if(normalize_data_directory(options) < 0) + if (normalize_data_directory(options) < 0) return -1; tor_assert(options->DataDirectory); if (strlen(options->DataDirectory) > (512-128)) { log_fn(LOG_ERR, "DataDirectory is too long."); return -1; } + if (check_private_dir(options->DataDirectory, CPD_CHECK != 0)) { + log_fn(LOG_WARN, "Can't create directory %s", options->DataDirectory); + return -1; + } return 0; } diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 2e6508b056..c0fc76c391 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -711,11 +711,9 @@ void dirserv_set_cached_directory(const char *directory, time_t when) log_fn(LOG_WARN,"Error compressing cached directory"); } cached_directory_published = when; - if(get_options()->DataDirectory) { - tor_snprintf(filename,sizeof(filename),"%s/cached-directory", get_options()->DataDirectory); - if(write_str_to_file(filename,cached_directory,0) < 0) { - log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring."); - } + tor_snprintf(filename,sizeof(filename),"%s/cached-directory", get_options()->DataDirectory); + if(write_str_to_file(filename,cached_directory,0) < 0) { + log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring."); } } }