+bool read_server_config(void) {
+ char *fname;
+ bool x;
+
+ read_config_options(config_tree, NULL);
+
+ xasprintf(&fname, "%s" SLASH "tinc.conf", confbase);
+ x = read_config_file(config_tree, fname);
+
+ if(!x)
+ logger(DEBUG_ALWAYS, LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno));
+
+ free(fname);
+
+ return x;
+}
+
+bool read_host_config(splay_tree_t *config_tree, const char *name) {
+ char *fname;
+ bool x;
+
+ read_config_options(config_tree, name);
+
+ xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+ x = read_config_file(config_tree, fname);
+ free(fname);
+
+ return x;
+}
+
+bool append_config_file(const char *name, const char *key, const char *value) {
+ char *fname;
+ xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, name);
+
+ FILE *fp = fopen(fname, "a");
+
+ if(!fp) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno));
+ } else {
+ fprintf(fp, "\n# The following line was automatically added by tinc\n%s = %s\n", key, value);
+ fclose(fp);
+ }
+
+ free(fname);
+
+ return fp != NULL;
+}