mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
once normalized, DataDirectory is always defined
svn:r2734
This commit is contained in:
parent
180e0a9326
commit
cad26b343d
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user