X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finvitation.c;h=0dfd9eacf32f2cae5ab9a3a45256f74551af3c72;hb=af81c436d6e11a53803747af7cc8ecfd449ccd4c;hp=9a082e3f7a855a1a2e5c2d11c698dbe05b9c69d4;hpb=060ab1cd7cdf750a0477f2a8b6193d28849877e8;p=tinc diff --git a/src/invitation.c b/src/invitation.c index 9a082e3f..0dfd9eac 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -252,8 +252,8 @@ int cmd_invite(int argc, char *argv[]) { } // If a daemon is running, ensure no other nodes know about this name - bool found = false; if(connect_tincd(false)) { + bool found = false; sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); while(recvline(fd, line, sizeof line)) { @@ -607,6 +607,17 @@ make_names: return false; } + snprintf(filename, sizeof filename, "%s" SLASH "invitation-data", confbase); + FILE *finv = fopen(filename, "w"); + if(!finv || fwrite(data, datalen, 1, finv) != 1) { + fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); + fclose(fh); + fclose(f); + fclose(finv); + return false; + } + fclose(finv); + snprintf(filename, sizeof filename, "%s" SLASH "tinc-up.invitation", confbase); FILE *fup = fopen(filename, "w"); if(!fup) { @@ -686,7 +697,7 @@ make_names: } // Copy the safe variable to the right config file - fprintf(variables[i].type & VAR_HOST ? fh : f, "%s = %s\n", l, value); + fprintf((variables[i].type & VAR_HOST) ? fh : f, "%s = %s\n", l, value); } fclose(f);