X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=8a3309556c3ef32c6c137593b289b0f4170a1e2b;hb=3c7003893fe2f82023d0d4f54b488bb7a16d0007;hp=6725b8b2b4ecd62d1c0802c286c5545f472b16fe;hpb=eb01fd96258e5f99be0e4930eac04e5487a108a0;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 6725b8b2..8a330955 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -62,10 +62,18 @@ static struct WSAData wsa_state; static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, + {"debug", optional_argument, NULL, 0}, + {"no-detach", no_argument, NULL, 0}, + {"mlock", no_argument, NULL, 0}, {"net", required_argument, NULL, 'n'}, {"help", no_argument, NULL, 1}, {"version", no_argument, NULL, 2}, {"pidfile", required_argument, NULL, 5}, + {"logfile", required_argument, NULL, 0}, + {"bypass-security", no_argument, NULL, 0}, + {"chroot", no_argument, NULL, 0}, + {"user", required_argument, NULL, 0}, + {"option", required_argument, NULL, 0}, {NULL, 0, NULL, 0} }; @@ -98,7 +106,7 @@ static void usage(bool status) { " [set] VARIABLE VALUE - set VARIABLE to VALUE\n" " add VARIABLE VALUE - add VARIABLE with the given VALUE\n" " del VARIABLE [VALUE] - remove VARIABLE [only ones with watching VALUE]\n" - " start Start tincd.\n" + " start [tincd options] Start tincd.\n" " stop Stop tincd.\n" " restart Restart tincd.\n" " reload Partially reload configuration of running tincd.\n" @@ -130,7 +138,7 @@ static bool parse_options(int argc, char **argv) { int r; int option_index = 0; - while((r = getopt_long(argc, argv, "c:n:", long_options, &option_index)) != EOF) { + while((r = getopt_long(argc, argv, "c:n:Dd::Lo:RU:", long_options, &option_index)) != EOF) { switch (r) { case 0: /* long option */ break; @@ -655,6 +663,9 @@ static bool connect_tincd() { static int cmd_start(int argc, char *argv[]) { int i, j; char *c; + + argc += optind; + argv -= optind; char *slash = strrchr(argv[0], '/'); #ifdef HAVE_MINGW @@ -723,6 +734,9 @@ static int cmd_dump(int argc, char *argv[]) { return 1; } + if(!connect_tincd()) + return 1; + bool do_graph = false; if(!strcasecmp(argv[1], "nodes")) @@ -743,9 +757,6 @@ static int cmd_dump(int argc, char *argv[]) { return 1; } - if(!connect_tincd()) - return 1; - if(do_graph) printf("digraph {\n"); @@ -1163,6 +1174,12 @@ static int cmd_config(int argc, char *argv[]) { return 1; } + // Silently try notifying a running tincd of changes. + fclose(stderr); + + if(connect_tincd()) + sendline(fd, "%d %d", CONTROL, REQ_RELOAD); + return 0; } @@ -1319,7 +1336,17 @@ static int cmd_edit(int argc, char *argv[]) { char *command; xasprintf(&command, "\"%s\" \"%s\"", editor, filename); - return system(command); + int result = system(command); + if(result) + return result; + + // Silently try notifying a running tincd of changes. + fclose(stderr); + + if(connect_tincd()) + sendline(fd, "%d %d", CONTROL, REQ_RELOAD); + + return 0; } static const struct {