X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=b8155cbd7aed59e6cf3a555490d70ec486f933ec;hb=c45a3fd7319d03bd147448a017f5aaed3b46fdfe;hp=afe19cd2da1b856c526d29a38ea6ed5713e568a6;hpb=a0fbaf0889fda3788943baec80671ecc870a2925;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index afe19cd2..b8155cbd 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -41,6 +41,7 @@ #include "subnet.h" #include "keys.h" #include "random.h" +#include "sandbox.h" #include "pidfile.h" #include "console.h" @@ -119,6 +120,9 @@ static void version(void) { #endif #ifndef DISABLE_LEGACY " legacy_protocol" +#endif +#ifdef HAVE_SANDBOX + " sandbox" #endif "\n\n" "Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n" @@ -1515,7 +1519,10 @@ static int cmd_pcap(int argc, char *argv[]) { static void sigint_handler(int sig) { (void)sig; - fprintf(stderr, "\n"); + if(write(2, "\n", 1) < 0) { + // nothing we can do + } + shutdown(fd, SHUT_RDWR); } #endif @@ -1695,6 +1702,7 @@ const var_t variables[] = { {"ProcessPriority", VAR_SERVER}, {"Proxy", VAR_SERVER}, {"ReplayWindow", VAR_SERVER | VAR_SAFE}, + {"Sandbox", VAR_SERVER}, {"ScriptsExtension", VAR_SERVER}, {"ScriptsInterpreter", VAR_SERVER}, {"StrictSubnets", VAR_SERVER | VAR_SAFE}, @@ -1926,16 +1934,18 @@ static int cmd_config(int argc, char *argv[]) { char filename[PATH_MAX]; if(node) { - if((size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node) >= sizeof(filename)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node); - free(node); - return 1; - } + size_t wrote = (size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node); if(node != line) { free(node); node = NULL; } + + if(wrote >= sizeof(filename)) { + fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node); + return 1; + } + } else { snprintf(filename, sizeof(filename), "%s", tinc_conf); } @@ -2535,7 +2545,7 @@ static int cmd_export_all(int argc, char *argv[]) { if(first) { first = false; } else { - printf("#---------------------------------------------------------------#\n"); + printf("\n#---------------------------------------------------------------#\n"); } result |= export(ent->d_name, stdout); @@ -3350,6 +3360,9 @@ int main(int argc, char *argv[]) { crypto_init(); prng_init(); + sandbox_set_level(SANDBOX_NORMAL); + sandbox_enter(); + int result = run_command(argc, argv); random_exit();