X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=f47faefba0f1bc854f62629f6d144b9f9793d515;hb=3fba80174dbe29bcfe0d121a2a1d2e61be5ee57b;hp=bf8183f7d9b8e1fe4eb10f8f4d870f0e2bb4b735;hpb=ce8775000ab38229a78ecf3dc26bab008ca0f332;p=tinc diff --git a/src/conf.c b/src/conf.c index bf8183f7..f47faefb 100644 --- a/src/conf.c +++ b/src/conf.c @@ -26,6 +26,7 @@ #include "splay_tree.h" #include "connection.h" #include "conf.h" +#include "list.h" #include "logger.h" #include "netutl.h" /* for str2address */ #include "protocol.h" @@ -188,7 +189,7 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) { } bool get_config_subnet(const config_t *cfg, subnet_t ** result) { - subnet_t subnet = {0}; + subnet_t subnet = {NULL}; if(!cfg) return false; @@ -368,7 +369,7 @@ void read_config_options(splay_tree_t *config_tree, const char *prefix) { } } -bool read_server_config() { +bool read_server_config(void) { char *fname; bool x; @@ -399,6 +400,24 @@ bool read_connection_config(connection_t *c) { return x; } +bool append_config_file(const char *name, const char *key, const char *value) { + char *fname; + xasprintf(&fname, "%s/hosts/%s", confbase, name); + + FILE *fp = fopen(fname, "a"); + + if(!fp) { + logger(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; +} + bool disable_old_keys(FILE *f) { char buf[100]; long pos;