- program_name = argv[0];
-
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
-
- /* Do some intl stuff right now */
-
- unknown = _("unknown");
-
- environment = envp;
- parse_options(argc, argv, envp);
-
- if(show_version)
- {
- printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE, VERSION, __DATE__, __TIME__, PROT_CURRENT);
- printf(_("Copyright (C) 1998-2001 Ivo Timmermans, Guus Sliepen and others.\n"
- "See the AUTHORS file for a complete list.\n\n"
- "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
- "and you are welcome to redistribute it under certain conditions;\n"
- "see the file COPYING for details.\n"));
-
- return 0;
- }
-
- if(show_help)
- usage(0);
-
- if(geteuid())
- {
- fprintf(stderr, _("You must be root to run this program.\n"));
- return 1;
- }
-
- openlog("tinc", LOG_PERROR, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
-
- g_argv = argv;
-
- make_names();
-
- /* Slllluuuuuuurrrrp! */
-cp
- RAND_load_file("/dev/urandom", 1024);
-cp
- if(generate_keys)
- {
- read_server_config();
- exit(keygen(generate_keys));
- }
-
- if(kill_tincd)
- exit(kill_other());
-
- if(read_server_config())
- exit(1);
-cp
- if(detach())
- exit(0);
-cp
- if(debug_lvl >= DEBUG_ERROR)
- ERR_load_crypto_strings();
-
- for(;;)
- {
- if(!setup_network_connections())
- {
- main_loop();
- cleanup_and_exit(1);
- }
-
- syslog(LOG_ERR, _("Unrecoverable error"));
- cp_trace();
-
- if(do_detach)
- {
- syslog(LOG_NOTICE, _("Restarting in %d seconds!"), MAXTIMEOUT);
- sleep(MAXTIMEOUT);
- }
- else
- {
- syslog(LOG_ERR, _("Not restarting."));
- exit(1);
- }
- }
+ program_name = argv[0];
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ environment = envp;
+ parse_options(argc, argv, envp);
+
+ if(show_version) {
+ printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE,
+ VERSION, __DATE__, __TIME__, PROT_CURRENT);
+ printf(_("Copyright (C) 1998-2002 Ivo Timmermans, Guus Sliepen and others.\n"
+ "See the AUTHORS file for a complete list.\n\n"
+ "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
+ "and you are welcome to redistribute it under certain conditions;\n"
+ "see the file COPYING for details.\n"));
+
+ return 0;
+ }
+
+ if(show_help)
+ usage(0);
+
+#ifndef LOG_PERROR
+ openlog("tinc", LOG_CONS, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
+#else
+ openlog("tinc", LOG_PERROR, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
+#endif
+
+ /* Lock all pages into memory if requested */
+
+ if(do_mlock)
+#ifdef HAVE_MLOCKALL
+ if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
+ syslog(LOG_ERR, _("System call `%s' failed: %s"), "mlockall",
+ strerror(errno));
+#else
+ {
+ syslog(LOG_ERR, _("mlockall() not supported on this platform!"));
+#endif
+ return -1;
+ }
+
+ g_argv = argv;
+
+ make_names();
+ init_configuration(&config_tree);
+
+ /* Slllluuuuuuurrrrp! */
+
+ RAND_load_file("/dev/urandom", 1024);
+
+#ifdef HAVE_OPENSSL_ADD_ALL_ALGORITHMS_NOCONF
+ OPENSSL_add_all_algorithms_noconf();
+#else
+#ifdef HAVE_OPENSSL_ADD_ALL_ALGORITHMS
+ OpenSSL_add_all_algorithms();
+#else
+#ifdef HAVE_SSLEAY_ADD_ALL_ALGORITHMS
+ SSLeay_add_all_algorithms();
+#else
+#error No add_all_algorithms function available!
+#endif
+#endif
+#endif
+
+ if(generate_keys) {
+ read_server_config();
+ exit(keygen(generate_keys));
+ }
+
+ if(kill_tincd)
+ exit(kill_other(kill_tincd));
+
+ if(read_server_config())
+ exit(1);
+
+ if(detach())
+ exit(0);
+
+ for(;;) {
+ if(!setup_network_connections()) {
+ main_loop();
+ cleanup_and_exit(1);
+ }
+
+ syslog(LOG_ERR, _("Unrecoverable error"));
+ cp_trace();
+
+ if(do_detach) {
+ syslog(LOG_NOTICE, _("Restarting in %d seconds!"), maxtimeout);
+ sleep(maxtimeout);
+ } else {
+ syslog(LOG_ERR, _("Not restarting."));
+ exit(1);
+ }
+ }