X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincd.c;h=5f1447e612a3b919a9873614b339859be1e06092;hb=6bf3595a915111770b7a167c54ccbca86cfbec78;hp=1feab407283dda960e7fe22bc38534a6005d451a;hpb=1135669b3c6820f5473ea451a58865f552ba768f;p=tinc diff --git a/src/tincd.c b/src/tincd.c index 1feab407..5f1447e6 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -67,14 +67,18 @@ static bool show_version = false; /* If nonzero, use null ciphers and skip all key exchanges. */ bool bypass_security = false; +#ifdef HAVE_MLOCKALL /* If nonzero, disable swapping for this process. */ static bool do_mlock = false; +#endif +#ifndef HAVE_MINGW /* If nonzero, chroot to netdir after startup. */ static bool do_chroot = false; /* If !NULL, do setuid to given user after startup */ static const char *switchuser = NULL; +#endif /* If nonzero, write log entries to a separate file. */ bool use_logfile = false; @@ -163,7 +167,9 @@ static bool parse_options(int argc, char **argv) { break; #endif - case 'd': /* inc debug level */ + case 'd': /* increase debug level */ + if(!optarg && optind < argc && *argv[optind] != '-') + optarg = argv[optind++]; if(optarg) debug_level = atoi(optarg); else @@ -210,6 +216,8 @@ static bool parse_options(int argc, char **argv) { case 4: /* write log entries to a file */ use_logfile = true; + if(!optarg && optind < argc && *argv[optind] != '-') + optarg = argv[optind++]; if(optarg) logfilename = xstrdup(optarg); break; @@ -227,6 +235,12 @@ static bool parse_options(int argc, char **argv) { } } + if(optind < argc) { + fprintf(stderr, "%s: unrecognized argument '%s'\n", argv[0], argv[optind]); + usage(true); + return false; + } + if(!netname && (netname = getenv("NETNAME"))) netname = xstrdup(netname); @@ -342,7 +356,8 @@ int main(int argc, char **argv) { /* Slllluuuuuuurrrrp! */ - srand(time(NULL)); + gettimeofday(&now, NULL); + srand(now.tv_sec + now.tv_usec); crypto_init(); if(!read_server_config())