- if(security_init())
- return 1;
-
- if(setup_network_connections())
- cleanup_and_exit(1);
-
- main_loop();
-
- cleanup_and_exit(1);
- return 1;
-}
-
-RETSIGTYPE
-sigterm_handler(int a)
-{
- if(debug_lvl > 0)
- syslog(LOG_NOTICE, "Got TERM signal");
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigquit_handler(int a)
-{
- if(debug_lvl > 0)
- syslog(LOG_NOTICE, "Got QUIT signal");
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigsegv_square(int a)
-{
- syslog(LOG_NOTICE, "Got another SEGV signal: not restarting");
- exit(0);
-}
-
-RETSIGTYPE
-sigsegv_handler(int a)
-{
- if(cp_file)
- syslog(LOG_NOTICE, "Got SEGV signal after %s line %d. Trying to re-execute.",
- cp_file, cp_line);
- else
- syslog(LOG_NOTICE, "Got SEGV signal; trying to re-execute.");
-
- signal(SIGSEGV, sigsegv_square);
-
- close_network_connections();
- remove_pid(pidfilename);
- execvp(g_argv[0], g_argv);
-}
-
-RETSIGTYPE
-sighup_handler(int a)
-{
- if(debug_lvl > 0)
- syslog(LOG_NOTICE, "Got HUP signal");
- close_network_connections();
- setup_network_connections();
- /* FIXME: read config-file and re-establish network connections */
-}
-
-RETSIGTYPE
-sigint_handler(int a)
-{
- if(debug_lvl > 0)
- syslog(LOG_NOTICE, "Got INT signal");
- cleanup_and_exit(0);
-}
-
-RETSIGTYPE
-sigusr1_handler(int a)
-{
- dump_conn_list();
-}
-
-RETSIGTYPE
-sigusr2_handler(int a)
-{
- if(debug_lvl > 1)
- syslog(LOG_NOTICE, "Forcing new keys");
- regenerate_keys();
-}
-
-RETSIGTYPE
-sighuh(int a)
-{
- if(cp_file)
- syslog(LOG_NOTICE, "Got unexpected signal (%d) after %s line %d.",
- a, cp_file, cp_line);
- else
- syslog(LOG_NOTICE, "Got unexpected signal (%d).", a);
-}
+ 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();