Call make_names() before doing anything else.
[tinc] / src / tincd.c
index 2aa16dd..7e28bcb 100644 (file)
@@ -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.65 2002/09/15 14:55:54 guus Exp $
+    $Id: tincd.c,v 1.10.4.68 2003/06/11 19:07:56 guus Exp $
 */
 
 #include "config.h"
@@ -50,6 +50,8 @@
 #include <openssl/pem.h>
 #include <openssl/evp.h>
 
+#include <lzo1x.h>
+
 #include <utils.h>
 #include <xalloc.h>
 
 #include "system.h"
 
 /* The name this program was run with. */
-char *program_name;
+char *program_name = NULL;
 
 /* If nonzero, display usage information and exit. */
-int show_help;
+int show_help = 0;
 
 /* If nonzero, print the version on standard output and exit.  */
-int show_version;
+int show_version = 0;
 
 /* If nonzero, it will attempt to kill a running tincd and exit. */
 int kill_tincd = 0;
@@ -83,8 +85,8 @@ int bypass_security = 0;
 /* If nonzero, disable swapping for this process. */
 int do_mlock = 0;
 
-char *identname;                               /* program name for syslog */
-char *pidfilename;                             /* pid file location */
+char *identname = NULL;                                /* program name for syslog */
+char *pidfilename = NULL;                      /* pid file location */
 char **g_argv;                                 /* a copy of the cmdline arguments */
 char **environment;                            /* A pointer to the environment on
                                                                   startup */
@@ -345,6 +347,7 @@ int main(int argc, char **argv, char **envp)
 
        environment = envp;
        parse_options(argc, argv, envp);
+       make_names();
 
        if(show_version) {
                printf(_("%s version %s (built %s %s, protocol %d)\n"), PACKAGE,
@@ -361,6 +364,9 @@ int main(int argc, char **argv, char **envp)
        if(show_help)
                usage(0);
 
+       if(kill_tincd)
+               exit(kill_other(kill_tincd));
+
 #ifndef LOG_PERROR
        openlog("tinc", LOG_CONS, LOG_DAEMON);  /* Catch all syslog() calls issued before detaching */
 #else
@@ -383,17 +389,24 @@ int main(int argc, char **argv, char **envp)
 
        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
-       OpenSSL_add_all_algorithms();
+#error No add_all_algorithms function available!
+#endif
+#endif
 #endif
 
        if(generate_keys) {
@@ -401,15 +414,17 @@ int main(int argc, char **argv, char **envp)
                exit(keygen(generate_keys));
        }
 
-       if(kill_tincd)
-               exit(kill_other(kill_tincd));
-
        if(read_server_config())
                exit(1);
 
+       if(lzo_init() != LZO_E_OK) {
+               syslog(LOG_ERR, _("Error initializing LZO compressor!"));
+               exit(1);
+       }
+
        if(detach())
                exit(0);
-
+               
        for(;;) {
                if(!setup_network_connections()) {
                        main_loop();