summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2015-04-17 22:40:08 +0000
committerAndrea Shepard <andrea@torproject.org>2015-04-17 22:40:08 +0000
commitbc8b9a28a43909c4abbb98c48c05ed495a24a4cb (patch)
tree0a4a3796ffd87fefcd2f69fc1d4c8dfd606d82bb /src/or/config.c
parent42cee727fa281fff4e27f98544e5bca36259fbaf (diff)
downloadtor-bc8b9a28a43909c4abbb98c48c05ed495a24a4cb.tar.gz
tor-bc8b9a28a43909c4abbb98c48c05ed495a24a4cb.zip
Add default DirAuthority lines to output of getinfo_helper_config(config/defaults) if not already present
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/or/config.c b/src/or/config.c
index c6a8c72a88..3646b9628c 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -6969,15 +6969,42 @@ getinfo_helper_config(control_connection_t *conn,
smartlist_free(sl);
} else if (!strcmp(question, "config/defaults")) {
smartlist_t *sl = smartlist_new();
- int i;
+ int i, dirauth_lines_seen = 0;
for (i = 0; option_vars_[i].name; ++i) {
const config_var_t *var = &option_vars_[i];
if (var->initvalue != NULL) {
- char *val = esc_for_log(var->initvalue);
- smartlist_add_asprintf(sl, "%s %s\n",var->name,val);
- tor_free(val);
+ if (strcmp(option_vars_[i].name, "DirAuthority") == 0) {
+ /*
+ * Count dirauth lines we have a default for; we'll use the
+ * count later to decide whether to add the defaults manually
+ */
+ ++dirauth_lines_seen;
+ }
+ char *val = esc_for_log(var->initvalue);
+ smartlist_add_asprintf(sl, "%s %s\n",var->name,val);
+ tor_free(val);
}
}
+
+ if (dirauth_lines_seen == 0) {
+ /*
+ * We didn't see any directory authorities with default values,
+ * so add the list of default authorities manually.
+ */
+ const char **i;
+
+ /*
+ * default_authorities is defined earlier in this file and
+ * is a const char ** NULL-terminated array of dirauth config
+ * lines.
+ */
+ for (i = default_authorities; *i != NULL; ++i) {
+ char *val = esc_for_log(*i);
+ smartlist_add_asprintf(sl, "DirAuthority %s\n", val);
+ tor_free(val);
+ }
+ }
+
*answer = smartlist_join_strings(sl, "", 0, NULL);
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
smartlist_free(sl);