mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Make check_private_dir trimodal (check/create/ignore), not bimodal (create/ignore).
svn:r2733
This commit is contained in:
@@ -241,9 +241,8 @@ options_act(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/*XXX in options_validate, we should check if this is going to fail */
|
||||
/* Ensure data directory is private; create if possible. */
|
||||
if (check_private_dir(options->DataDirectory, 1) != 0) {
|
||||
if (check_private_dir(options->DataDirectory, CPD_CREATE) != 0) {
|
||||
log_fn(LOG_ERR, "Couldn't access/create private data directory %s",
|
||||
options->DataDirectory);
|
||||
return -1;
|
||||
@@ -1014,6 +1013,13 @@ 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");
|
||||
|
||||
@@ -295,7 +295,7 @@ int rend_service_load_keys(void)
|
||||
log_fn(LOG_INFO, "Loading hidden-service keys from '%s'", s->directory);
|
||||
|
||||
/* Check/create directory */
|
||||
if (check_private_dir(s->directory, 1) < 0)
|
||||
if (check_private_dir(s->directory, CPD_CREATE) < 0)
|
||||
return -1;
|
||||
|
||||
/* Load key */
|
||||
|
||||
@@ -259,12 +259,12 @@ int init_keys(void) {
|
||||
}
|
||||
/* Make sure DataDirectory exists, and is private. */
|
||||
datadir = options->DataDirectory;
|
||||
if (check_private_dir(datadir, 1)) {
|
||||
if (check_private_dir(datadir, CPD_CREATE)) {
|
||||
return -1;
|
||||
}
|
||||
/* Check the key directory. */
|
||||
tor_snprintf(keydir,sizeof(keydir),"%s/keys", datadir);
|
||||
if (check_private_dir(keydir, 1)) {
|
||||
if (check_private_dir(keydir, CPD_CREATE)) {
|
||||
return -1;
|
||||
}
|
||||
cp = keydir + strlen(keydir); /* End of string. */
|
||||
|
||||
Reference in New Issue
Block a user