once normalized, DataDirectory is always defined

svn:r2734
This commit is contained in:
Roger Dingledine 2004-11-09 07:20:21 +00:00
parent 180e0a9326
commit cad26b343d
2 changed files with 9 additions and 17 deletions

View File

@ -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;
}

View File

@ -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.");
}
}
}