X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=39a11d314a84aa849327c55e36b98ffc5abea106;hb=4314df644e22778a554ca1760941a2bfae08bce2;hp=4231cce39f09f42ffdefc8f239d1fe58453a82a5;hpb=51a0dc51451897cc0290d5040e42616dda9bdc8a;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 4231cce3..39a11d31 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1,6 +1,6 @@ /* tincctl.c -- Controlling a running tincd - Copyright (C) 2007-2015 Guus Sliepen + Copyright (C) 2007-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -89,7 +89,7 @@ static struct option const long_options[] = { static void version(void) { printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); - printf("Copyright (C) 1998-2015 Ivo Timmermans, Guus Sliepen and others.\n" + printf("Copyright (C) 1998-2016 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n" @@ -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; @@ -1433,7 +1440,7 @@ char *get_my_name(bool verbose) { return NULL; } -static ecdsa_t *get_pubkey(FILE *f) { +ecdsa_t *get_pubkey(FILE *f) { char buf[4096]; char *value; while(fgets(buf, sizeof buf, f)) { @@ -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");