diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-09 05:26:49 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-09 05:26:49 +0000 |
commit | 2677395aaf402ab9fd7af40331ea266aeb5f87db (patch) | |
tree | 112941774471e64b1ce1d6e996498c8109ff5d46 /src | |
parent | a5903b737aab93882096df1f93bba83bb5e92164 (diff) | |
download | tor-2677395aaf402ab9fd7af40331ea266aeb5f87db.tar tor-2677395aaf402ab9fd7af40331ea266aeb5f87db.tar.gz |
Normalize DataDirectory in options_validate, making SIGHUP survivable.
svn:r2722
Diffstat (limited to 'src')
-rw-r--r-- | src/or/config.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/or/config.c b/src/or/config.c index b9d55a480..fe3dfc434 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -958,6 +958,11 @@ options_validate(or_options_t *options) result = -1; } + if (validate_data_directory(options)<0) { + log(LOG_WARN, "Invalid DataDirectory"); + result = -1; + } + if (options->Nickname == NULL) { if (server_mode(options)) { if (!(options->Nickname = get_default_nickname())) @@ -1205,7 +1210,7 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val) { (!new_val->DataDirectory || strcmp(old->DataDirectory,new_val->DataDirectory)!=0)) || (!old->DataDirectory && new_val->DataDirectory)) { - log_fn(LOG_WARN,"During reload, changing DataDirectory is not allowed. Failing."); + log_fn(LOG_WARN,"During reload, changing DataDirectory (%s->%s) is not allowed. Failing.", old->DataDirectory, new_val->DataDirectory); return -1; } @@ -1818,12 +1823,14 @@ parse_dir_server_line(const char *line, int validate_only) const char * get_data_directory(void) { + return get_options()->DataDirectory; +} + +static int +validate_data_directory(or_options_t *options) { const char *d; - or_options_t *options = get_options(); - if (options->DataDirectory) { - d = options->DataDirectory; - } else { + if (!options->DataDirectory) { #ifdef MS_WINDOWS char *p; p = tor_malloc(MAX_PATH); @@ -1832,19 +1839,20 @@ get_data_directory(void) return p; #else d = "~/.tor"; -#endif } +#endif - if (d && strncmp(d,"~/",2) == 0) { - char *fn = expand_filename(d); - if (!fn) { - log_fn(LOG_ERR,"Failed to expand filename '%s'. Exiting.", d); - exit(1); - } - tor_free(options->DataDirectory); - options->DataDirectory = fn; - } - return options->DataDirectory; + if (d && strncmp(d,"~/",2) == 0) { + char *fn = expand_filename(d); + if (!fn) { + log_fn(LOG_ERR,"Failed to expand filename '%s'. Exiting.", d); + exit(1); + } + tor_free(options->DataDirectory); + options->DataDirectory = fn; + } + + return 0; } /* |