X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finvitation.c;h=30d100d98e43ed9d131c0e8264841be0cd1b31c0;hb=1a52f8093fc2e894860aee82e4a20885099a7130;hp=411af2bf4b9b6d51e7072600cb866ae67972db97;hpb=1af8ca58b86f5956d6acd9f63083a84666647ef0;p=tinc diff --git a/src/invitation.c b/src/invitation.c index 411af2bf..30d100d9 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -836,8 +836,12 @@ make_names: fprintf(stderr, "Ignoring unknown variable '%s' in invitation.\n", l); continue; } else if(!(variables[i].type & VAR_SAFE)) { - fprintf(stderr, "Ignoring unsafe variable '%s' in invitation.\n", l); - continue; + if(force) { + fprintf(stderr, "Warning: unsafe variable '%s' in invitation.\n", l); + } else { + fprintf(stderr, "Ignoring unsafe variable '%s' in invitation.\n", l); + continue; + } } // Copy the safe variable to the right config file @@ -983,7 +987,12 @@ ask_netname: char filename2[PATH_MAX]; snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up.invitation", confbase); + +#ifdef HAVE_MINGW + snprintf(filename2, sizeof(filename2), "%s" SLASH "tinc-up.bat", confbase); +#else snprintf(filename2, sizeof(filename2), "%s" SLASH "tinc-up", confbase); +#endif if(valid_tinc_up) { if(tty) { @@ -1067,7 +1076,7 @@ static bool invitation_send(void *handle, uint8_t type, const void *vdata, size_ while(len) { int result = send(sock, data, len, 0); - if(result == -1 && errno == EINTR) { + if(result == -1 && sockwouldblock(sockerrno)) { continue; } else if(result <= 0) { return false; @@ -1315,11 +1324,21 @@ next: while((len = recv(sock, line, sizeof(line), 0))) { if(len < 0) { - if(errno == EINTR) { + if(sockwouldblock(sockerrno)) { continue; } - fprintf(stderr, "Error reading data from %s port %s: %s\n", address, port, strerror(errno)); +#if HAVE_MINGW + + // If socket has been shut down, recv() on Windows returns -1 and sets sockerrno + // to WSAESHUTDOWN, while on UNIX-like operating systems recv() returns 0, so we + // have to do an explicit check here. + if(sockshutdown(sockerrno)) { + break; + } + +#endif + fprintf(stderr, "Error reading data from %s port %s: %s\n", address, port, sockstrerror(sockerrno)); return 1; }