X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Ftincd.c;h=4c494f5c608db3dd43bc43601452b2a8b6be8011;hp=75482357b3d2fdff5c2752da6a03118ed01d3b4c;hb=4ad1e382d6f10acf94ce59d85b80925cee7553a6;hpb=8fa9bc017d89b53798903df3fa98311067d4de90 diff --git a/src/tincd.c b/src/tincd.c index 75482357..4c494f5c 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c,v 1.10.4.19 2000/10/29 09:19:27 guus Exp $ + $Id: tincd.c,v 1.10.4.24 2000/11/03 22:31:55 zarq Exp $ */ #include "config.h" @@ -33,6 +33,7 @@ #include #include #include +#include #include #ifdef HAVE_SYS_IOCTL_H @@ -73,6 +74,8 @@ char *identname; /* program name for syslog */ char *pidfilename; /* pid file location */ static pid_t ppid; /* pid of non-detached part */ char **g_argv; /* a copy of the cmdline arguments */ +char **environment; /* A pointer to the environment on + startup */ void cleanup_and_exit(int); int detach(void); @@ -89,7 +92,7 @@ static struct option const long_options[] = { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, { "no-detach", no_argument, &do_detach, 0 }, - { "keygen", optional_argument, NULL, 'K'}, + { "generate-keys", optional_argument, NULL, 'K'}, { NULL, 0, NULL, 0 } }; @@ -101,14 +104,14 @@ usage(int status) else { printf(_("Usage: %s [option]...\n\n"), program_name); - printf(_(" -c, --config=DIR Read configuration options from DIR.\n" - " -D, --no-detach Don't fork and detach.\n" - " -d Increase debug level.\n" - " -k, --kill Attempt to kill a running tincd and exit.\n" - " -n, --net=NETNAME Connect to net NETNAME.\n")); - printf(_(" -K, --keygen[=BITS] Generate public/private RSA keypair.\n" - " --help Display this help and exit.\n" - " --version Output version information and exit.\n\n")); + printf(_(" -c, --config=DIR Read configuration options from DIR.\n" + " -D, --no-detach Don't fork and detach.\n" + " -d Increase debug level.\n" + " -k, --kill Attempt to kill a running tincd and exit.\n" + " -n, --net=NETNAME Connect to net NETNAME.\n")); + printf(_(" -K, --generate-keys[=BITS] Generate public/private RSA keypair.\n" + " --help Display this help and exit.\n" + " --version Output version information and exit.\n\n")); printf(_("Report bugs to tinc@nl.linux.org.\n")); } exit(status); @@ -204,9 +207,6 @@ int keygen(int bits) { RSA *rsa_key; - fprintf(stderr, _("Seeding the PRNG: please press some keys or move\nthe mouse if this program seems to have halted...\n")); - RAND_load_file("/dev/random", 1024); /* OpenSSL PRNG state apparently uses 1024 bytes, but it seems pretty sufficient anyway :) */ - fprintf(stderr, _("Generating %d bits keys:\n"), bits); rsa_key = RSA_generate_key(bits, 0xFFFF, indicator, NULL); if(!rsa_key) @@ -395,6 +395,7 @@ main(int argc, char **argv, char **envp) unknown = _("unknown"); + environment = envp; parse_options(argc, argv, envp); if(show_version) @@ -422,6 +423,10 @@ main(int argc, char **argv, char **envp) make_names(); + /* Slllluuuuuuurrrrp! */ + + RAND_load_file("/dev/urandom", 1024); + if(generate_keys) exit(keygen(generate_keys)); @@ -436,10 +441,9 @@ main(int argc, char **argv, char **envp) if(detach()) exit(0); -/* FIXME: wt* is this suppose to do? - if(security_init()) - return 1; -*/ + if(debug_lvl >= DEBUG_ERROR) + ERR_load_crypto_strings(); + for(;;) { if(!setup_network_connections()) @@ -536,11 +540,6 @@ RETSIGTYPE sigusr2_handler(int a) { dump_subnet_list(); -/* FIXME: reprogram this. - if(debug_lvl > DEBUG_NOTHING) - syslog(LOG_NOTICE, _("Got USR2 signal, forcing new key generation")); - regenerate_keys(); -*/ } RETSIGTYPE