X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=0bbee092411df4366f543dc800913dcbaed63d43;hb=30ef2a981e1d62692b3a2363e0b3a0e8711d9604;hp=30ac5852e85b8f970be2d2002d1c51dd6bc1743b;hpb=f4010694b3b16453e5e6298c208910264e326978;p=tinc diff --git a/src/conf.c b/src/conf.c index 30ac5852..0bbee092 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; @@ -399,6 +400,24 @@ bool read_connection_config(connection_t *c) { return x; } +bool append_connection_config(const connection_t *c, const char *key, const char *value) { + char *fname; + xasprintf(&fname, "%s/hosts/%s", confbase, c->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;