summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-11-04 15:46:24 +1100
committerteor <teor2345@gmail.com>2016-11-18 13:34:24 +1100
commit98057d274c8928ae14ed6adc2903fce4a9f87214 (patch)
treebc0629bd1e5199d2eaa6b6e4dd4f51591cdb804a /src
parent8a767ba7fbeedb3d8838ccfe57583203b783241d (diff)
downloadtor-98057d274c8928ae14ed6adc2903fce4a9f87214.tar.gz
tor-98057d274c8928ae14ed6adc2903fce4a9f87214.zip
Create HS directories in rend_config_services, then check before use
(We only create HS directories if we are acting on the config.) Log a BUG warning if the directories aren't present immediately before they are used, then fail.
Diffstat (limited to 'src')
-rw-r--r--src/or/rendservice.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 56dbacdaf7..15b7feb13c 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -466,7 +466,8 @@ rend_config_services(const or_options_t *options, int validate_only)
for (line = options->RendConfigLines; line; line = line->next) {
if (!strcasecmp(line->key, "HiddenServiceDir")) {
if (service) { /* register the one we just finished parsing */
- if (rend_service_check_private_dir(options, service, 0) < 0) {
+ if (rend_service_check_private_dir(options, service, !validate_only)
+ < 0) {
rend_service_free(service);
return -1;
}
@@ -681,7 +682,7 @@ rend_config_services(const or_options_t *options, int validate_only)
}
}
if (service) {
- if (rend_service_check_private_dir(options, service, 0) < 0) {
+ if (rend_service_check_private_dir(options, service, !validate_only) < 0) {
rend_service_free(service);
return -1;
}
@@ -1098,8 +1099,8 @@ poison_new_single_onion_hidden_service_dir(const rend_service_t *service)
return -1;
}
- /* Make sure the directory exists */
- if (rend_service_check_private_dir(get_options(), service, 1) < 0)
+ /* Make sure the directory was created in options_act */
+ if (BUG(rend_service_check_private_dir(get_options(), service, 0) < 0))
return -1;
poison_fname = rend_service_sos_poison_path(service);
@@ -1297,7 +1298,8 @@ rend_service_load_keys(rend_service_t *s)
char *fname = NULL;
char buf[128];
- if (rend_service_check_private_dir(get_options(), s, 1) < 0)
+ /* Make sure the directory was created in options_act */
+ if (BUG(rend_service_check_private_dir(get_options(), s, 0) < 0))
goto err;
/* Load key */