X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finvitation.c;h=a94460e86ea23fa15ddbfdd10349028b21ced84d;hb=00398a60ec317740bcec83c5a524c5a95ce7f1c2;hp=3f7f97647c7abef45637fa1114ff2e82e61ab604;hpb=5da0ebd421572230fbd213ca0749df6771f4cb10;p=tinc diff --git a/src/invitation.c b/src/invitation.c index 3f7f9764..a94460e8 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -340,12 +340,17 @@ int cmd_invite(int argc, char *argv[]) { } chmod(filename, 0600); ecdsa_write_pem_private_key(key, f); + fclose(f); + + if(connect_tincd(false)) + sendline(fd, "%d %d", CONTROL, REQ_RELOAD); } else { key = ecdsa_read_pem_private_key(f); + fclose(f); if(!key) fprintf(stderr, "Could not read private key from %s\n", filename); } - fclose(f); + free(filename); if(!key) return 1; @@ -399,8 +404,12 @@ int cmd_invite(int argc, char *argv[]) { char buf[1024]; while(fgets(buf, sizeof buf, tc)) { if((!strncasecmp(buf, "Mode", 4) && strchr(" \t=", buf[4])) - || (!strncasecmp(buf, "Broadcast", 9) && strchr(" \t=", buf[9]))) + || (!strncasecmp(buf, "Broadcast", 9) && strchr(" \t=", buf[9]))) { fputs(buf, f); + // Make sure there is a newline character. + if(!strchr(buf, '\n')) + fputc('\n', f); + } } fclose(tc); } @@ -818,7 +827,7 @@ int cmd_join(int argc, char *argv[]) { } // Make sure confbase exists and is accessible. - if(strcmp(confdir, confbase) && mkdir(confdir, 0755) && errno != EEXIST) { + if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) { fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno)); return 1; }