X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=9f9df6f656e1aba603be92dd93eb12542df9bfb6;hb=e47fe48aed76bfd7d2cb957e402a8cdcb0c84759;hp=f41e0307b6abeed018ba207df1a8e81a79bef35d;hpb=76955a6c8b7a76d00ed401853c9d283e32d9ce1c;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index f41e0307..9f9df6f6 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -718,6 +718,13 @@ bool connect_tincd(bool verbose) { } fclose(f); + if ((pid == 0) || (kill(pid, 0) && (errno == ESRCH))) { + fprintf(stderr, "Could not find tincd running at pid %d\n", pid); + /* clean up the stale socket and pid file */ + unlink(pidfilename); + unlink(unixsocketname); + return false; + } #ifndef HAVE_MINGW struct sockaddr_un sa; @@ -1384,7 +1391,7 @@ static int cmd_pid(int argc, char *argv[]) { return 1; } - if(!connect_tincd(true) && !pid) + if(!connect_tincd(true) || !pid) return 1; printf("%d\n", pid); @@ -2517,6 +2524,7 @@ static int cmd_verify(int argc, char *argv[]) { } *newline++ = '\0'; + size_t skip = newline - data; char signer[MAX_STRING_SIZE] = ""; char sig[MAX_STRING_SIZE] = ""; @@ -2543,6 +2551,8 @@ static int cmd_verify(int argc, char *argv[]) { memcpy(data + len, trailer, trailer_len); free(trailer); + newline = data + skip; + char fname[PATH_MAX]; snprintf(fname, sizeof fname, "%s" SLASH "hosts" SLASH "%s", confbase, node); FILE *fp = fopen(fname, "r");