+ execve(SBINDIR "/tincd", argv, envp);
+ fprintf(stderr, "Could not start tincd: %s", strerror(errno));
+ return 1;
+ }
+
+ /*
+ * Now handle commands that do involve connecting to a running tinc daemon.
+ * Authenticate the server by ensuring the parent directory can be
+ * traversed only by root. Note this is not totally race-free unless all
+ * ancestors are writable only by trusted users, which we don't verify.
+ */
+
+#ifdef HAVE_MINGW
+ if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) {
+ fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError()));
+ return 1;
+ }
+
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof addr);
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htonl(0x7f000001);
+ addr.sin_port = htons(55555);
+
+ fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if(fd < 0) {
+ fprintf(stderr, "Cannot create TCP socket: %s\n", sockstrerror(sockerrno));
+ return 1;
+ }
+
+ unsigned long arg = 0;
+
+ if(ioctlsocket(fd, FIONBIO, &arg) != 0) {
+ fprintf(stderr, "ioctlsocket failed: %s", sockstrerror(sockerrno));
+ }
+#else
+ struct sockaddr_un addr;
+ struct stat statbuf;
+ char *lastslash = strrchr(controlsocketname, '/');
+ if(lastslash != NULL) {
+ /* control socket is not in cwd; stat its parent */
+ *lastslash = 0;
+ result = stat(controlsocketname, &statbuf);
+ *lastslash = '/';
+ } else
+ result = stat(".", &statbuf);
+
+ if(result < 0) {
+ fprintf(stderr, "Unable to check control socket directory permissions: %s\n", strerror(errno));