X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Ftincctl.c;h=b2e6e82172e2a08c49f270699ff5980d0361a100;hb=a7556a9d2c943a6317d2dab66d9f742997f0d47a;hp=a7f6185f0716b93164763854b43f8c5c774cffae;hpb=2696ad2cca73aee13e38f740d5530dc33e4a92e6;p=meshlink diff --git a/src/tincctl.c b/src/tincctl.c index a7f6185f..b2e6e821 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -568,9 +568,26 @@ int main(int argc, char *argv[], char *envp[]) { } if(!strcasecmp(argv[optind], "start")) { - argv[optind] = NULL; - execve(SBINDIR "/tincd", argv, envp); - fprintf(stderr, "Could not start tincd: %s", strerror(errno)); + int i, j; + char *c; + char *slash = strrchr(argv[0], '/'); +#ifdef HAVE_MINGW + if ((c = strrchr(argv[0], '\\')) > slash) + slash = c; +#endif + if (slash++) { + c = xmalloc((slash - argv[0]) + sizeof("tincd")); + sprintf(c, "%.*stincd", slash - argv[0], argv[0]); + } + else + c = "tincd"; + argv[0] = c; + for(i = j = 1; argv[i]; ++i) + if (i != optind && strcmp(argv[i], "--") != 0) + argv[j++] = argv[i]; + argv[j] = NULL; + execve(c, argv, envp); + fprintf(stderr, "Could not start %s: %s\n", c, strerror(errno)); return 1; }