X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=f47faefba0f1bc854f62629f6d144b9f9793d515;hb=cff27a258f3b3a97b5d2e309c264eceea41dff3a;hp=593cd0c29f705c67fcd815efee2b55f2097a6111;hpb=434e57ae5ee79b3d990c4d75358047bad641998b;p=tinc diff --git a/src/conf.c b/src/conf.c index 593cd0c2..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" @@ -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;