X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=a49654847f158d74c0cbafce1e9307a45c768122;hb=d1e01bc880a6970050e55f19bafe8eaf1f0b9be2;hp=f6e60fe6f263870935657c096279010ced04bc1b;hpb=5fca595b80f5d2a6629d74e89ca2ef46ba9ae292;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index f6e60fe6..a4965484 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -830,8 +830,16 @@ static int cmd_start(int argc, char *argv[]) { free(nargv); - int status = -1; - if(waitpid(pid, &status, 0) != pid || !WIFEXITED(status) || WEXITSTATUS(status)) { + int status = -1, result; +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif + result = waitpid(pid, &status, 0); +#ifdef SIGINT + signal(SIGINT, SIG_DFL); +#endif + + if(result != pid || !WIFEXITED(status) || WEXITSTATUS(status)) { fprintf(stderr, "Error starting %s\n", c); return 1; } @@ -1414,6 +1422,7 @@ static int cmd_config(int argc, char *argv[]) { /* Some simple checks. */ bool found = false; + bool warnonremove = false; for(int i = 0; variables[i].name; i++) { if(strcasecmp(variables[i].name, variable)) @@ -1452,6 +1461,16 @@ static int cmd_config(int argc, char *argv[]) { return 1; } + /* Change "add" into "set" for variables that do not allow multiple occurences. + Turn on warnings when it seems variables might be removed unintentionally. */ + + if(action == 1 && !(variables[i].type & VAR_MULTIPLE)) { + warnonremove = true; + action = 0; + } else if(action == 0 && (variables[i].type & VAR_MULTIPLE)) { + warnonremove = true; + } + break; } @@ -1534,9 +1553,14 @@ static int cmd_config(int argc, char *argv[]) { } // Set } else if(action == 0) { + // Warn if "set" was used for variables that can occur multiple times + if(warnonremove && strcasecmp(bvalue, value)) + fprintf(stderr, "Warning: removing %s = %s\n", variable, bvalue); + // Already set? Delete the rest... if(set) continue; + // Otherwise, replace. if(fprintf(tf, "%s = %s\n", variable, value) < 0) { fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno));