X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=7b44881f3cf842c1a8295e6f2430c59741c2820d;hb=cc3c69c892b0dad9a6ece0a0f4ccd429a22fcbff;hp=1576ba86a3c6de6cb9bf70bc3929f527cccdf4d1;hpb=f5bb64b36ae0807cdd3f241f81a8e933065437f6;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 1576ba86..7b44881f 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1,6 +1,6 @@ /* tincctl.c -- Controlling a running tincd - Copyright (C) 2007-2012 Guus Sliepen + Copyright (C) 2007-2013 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 @@ -666,6 +666,26 @@ static bool connect_tincd(bool verbose) { } #endif +#ifndef HAVE_MINGW + struct sockaddr_un sa; + sa.sun_family = AF_UNIX; + strncpy(sa.sun_path, unixsocketname, sizeof sa.sun_path); + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(fd < 0) { + if(verbose) + fprintf(stderr, "Cannot create UNIX socket: %s\n", sockstrerror(sockerrno)); + return false; + } + + if(connect(fd, (struct sockaddr *)&sa, sizeof sa) < 0) { + if(verbose) + fprintf(stderr, "Cannot connect to UNIX socket %s: %s\n", unixsocketname, sockstrerror(sockerrno)); + close(fd); + fd = -1; + return false; + } +#else struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, @@ -706,6 +726,7 @@ static bool connect_tincd(bool verbose) { } freeaddrinfo(res); +#endif char data[4096]; int version;