From 24874d0806bac5d75663ea9de67a71171bfc97b6 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 30 Jun 2000 11:45:16 +0000 Subject: [PATCH] - Removed segfault bug in conf.c (must have been there for ages!) - Made main_loop() signal proof - #defined MAXTIMEOUT (15 minutes) - If something really really bad happens, close all connections, wait for MAXTIMEOUT seconds, and then restart tinc --- po/nl.po | 149 +++++++++++++++++++++++++--------------------------- src/conf.c | 20 ++++--- src/conf.h | 7 ++- src/net.c | 35 ++++++------ src/tincd.c | 18 ++++--- 5 files changed, 116 insertions(+), 113 deletions(-) diff --git a/po/nl.po b/po/nl.po index 3ac74f76..b432fe19 100644 --- a/po/nl.po +++ b/po/nl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: tinc 1.0pre3\n" -"POT-Creation-Date: 2000-06-29 21:32+0200\n" +"POT-Creation-Date: 2000-06-30 13:23+0200\n" "PO-Revision-Date: 2000-05-31 20:14+02:00\n" "Last-Translator: Ivo Timmermans \n" "Language-Team: Dutch \n" @@ -14,22 +14,22 @@ msgstr "" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" -#: src/conf.c:171 +#: src/conf.c:175 #, c-format msgid "%s: %d: Invalid variable name `%s'.\n" msgstr "%s: %d: Ongeldige variabelenaam `%s'.\n" -#: src/conf.c:178 +#: src/conf.c:182 #, c-format msgid "%s: %d: No value given for `%s'.\n" msgstr "%s: %d: Geen waarde gegeven voor `%s'.\n" -#: src/conf.c:186 +#: src/conf.c:190 #, c-format msgid "%s: %d: Invalid value `%s' for variable `%s'.\n" msgstr "%s: %d: Ongeldige waarde `%s' voor variabele `%s'.\n" -#: src/conf.c:208 +#: src/conf.c:214 #, c-format msgid "Could not open %s: %s\n" msgstr "Kon %s niet openen: %s\n" @@ -240,14 +240,15 @@ msgstr "Kon geen socket maken voor inkomend vpn verkeer" msgid "Ready: listening on port %hd" msgstr "Gereed: luisterend op poort %hd" -#: src/net.c:642 +#: src/net.c:641 #, c-format msgid "Still failed to connect to other, will retry in %d seconds" msgstr "Wederom niet verbonden met de ander, nieuwe poging over %d seconden" -#: src/net.c:680 -msgid "Trying to re-establish outgoing connection in 5 minutes" -msgstr "Poging tot herstellen van uitgaande verbinding over 5 minuten" +#: src/net.c:679 +#, c-format +msgid "Trying to re-establish outgoing connection in %d seconds" +msgstr "Poging tot herstellen van uitgaande verbinding over %d seconden" #: src/net.c:717 msgid "Terminating" @@ -268,7 +269,7 @@ msgstr "Aanmaak UDP socket mislukte: %m" msgid "Connecting to %s port %d failed: %m" msgstr "Verbinding naar %s poort %d mislukt: %m" -#: src/net.c:754 src/net.c:841 src/net.c:1037 +#: src/net.c:754 src/net.c:840 src/net.c:1036 #, c-format msgid "This is a bug: %s:%d: %d:%m" msgstr "Dit is een programmeerfout: %s:%d: %d:%m" @@ -278,119 +279,111 @@ msgstr "Dit is een programmeerfout: %s:%d: %d:%m" msgid "Error: getpeername: %m" msgstr "Fout: getpeername: %m" -#: src/net.c:782 -msgid "unknown" -msgstr "onbekend" - -#: src/net.c:792 +#: src/net.c:791 #, c-format msgid "Connection from %s port %d" msgstr "Verbinding van %s poort %d" -#: src/net.c:846 +#: src/net.c:845 #, c-format msgid "Incoming data socket error: %s" msgstr "Fout op socket voor inkomend verkeer: %s" -#: src/net.c:854 +#: src/net.c:853 #, c-format msgid "Receiving packet from %s failed: %m" msgstr "Ontvangst pakket van %s mislukt: %m" -#: src/net.c:868 +#: src/net.c:867 #, c-format msgid "Got packet from %s (%s) with unknown origin %d.%d.%d.%d?" msgstr "Kreeg pakket van %s (%s) met onbekende herkomst %d.%d.%d.%d?" -#: src/net.c:902 +#: src/net.c:901 #, c-format msgid "Closing connection with %s (%s)" msgstr "Beëindigen verbinding met %s (%s)" -#: src/net.c:946 +#: src/net.c:945 msgid "Trying to re-establish outgoing connection in 5 seconds" msgstr "Poging tot herstellen van uitgaande verbinding over 5 seconden" -#: src/net.c:976 +#: src/net.c:975 #, c-format msgid "%s (%s) didn't respond to PING" msgstr "%s (%s) antwoordde niet op ping" -#: src/net.c:1007 +#: src/net.c:1006 #, c-format msgid "Accepting a new connection failed: %m" msgstr "Aanname van nieuwe verbinding is mislukt: %m" -#: src/net.c:1015 +#: src/net.c:1014 msgid "Closed attempted connection" msgstr "Aangenomen verbinding verbroken" -#: src/net.c:1042 +#: src/net.c:1041 #, c-format msgid "Metadata socket error: %s" msgstr "Fout op socket voor metaverkeer: %s" -#: src/net.c:1048 +#: src/net.c:1047 msgid "Metadata read buffer overflow!" msgstr "Metadata ontvangstbuffer overloop!" -#: src/net.c:1058 +#: src/net.c:1057 #, c-format msgid "Metadata socket read error: %m" msgstr "Fout op socket voor metaverkeer tijdens lezen: %m" -#: src/net.c:1082 +#: src/net.c:1081 #, c-format msgid "Got request from %s (%s): %s" msgstr "Ontving verzoek van %s (%s): %s" -#: src/net.c:1088 +#: src/net.c:1087 #, c-format msgid "Unknown request from %s (%s)" msgstr "Onbekend verzoek van %s (%s)" -#: src/net.c:1095 +#: src/net.c:1094 #, c-format msgid "Error while processing request from %s (%s)" msgstr "Fout tijdens afhandelen van verzoek van %s (%s)" -#: src/net.c:1102 +#: src/net.c:1101 #, c-format msgid "Bogus data received from %s (%s)" msgstr "Onzinnige data ontvangen van %s (%s)" -#: src/net.c:1147 +#: src/net.c:1146 #, c-format msgid "Outgoing data socket error for %s (%s): %s" msgstr "Fout op socket voor uitgaand verkeer voor %s (%s): %s" -#: src/net.c:1183 +#: src/net.c:1182 #, c-format msgid "Error while reading from tapdevice: %m" msgstr "Fout tijdens lezen van tap-apparaatbestand tijdens lezen: %m" -#: src/net.c:1193 +#: src/net.c:1192 #, c-format msgid "Non-IP ethernet frame %04x from " msgstr "Niet-IP ethernet pakket %04x van " -#: src/net.c:1201 +#: src/net.c:1200 msgid "Dropping short packet" msgstr "Te kort pakket genegeerd" -#: src/net.c:1240 +#: src/net.c:1239 #, c-format msgid "Error while waiting for input: %m" msgstr "Fout tijdens wachten op invoer: %m" #: src/net.c:1251 -msgid "Unable to reread configuration file, exitting" +msgid "Unable to reread configuration file, exiting" msgstr "Fout tijdens herlezen configuratie bestand, beëindigen" -#: src/net.c:1256 -msgid "Unable to restart, exitting" -msgstr "Kon niet herstarten, beëindigen" - #: src/netutl.c:222 #, c-format msgid "Error looking up `%s': %s\n" @@ -513,7 +506,7 @@ msgstr "De ander gebruikt een niet-compatibel protocol versie %d" #: src/protocol.c:425 #, c-format msgid "Uplink %s (%s) is already in our connection list" -msgstr "" +msgstr "%s (%s) staat al in onze verbindingslijst" #: src/protocol.c:455 #, c-format @@ -719,12 +712,12 @@ msgstr "Kreeg KEY_CHANGED herkomst %d.%d.%d.%d van %s (%s), die niet bestaat?" msgid "Got KEY_CHANGED origin %s from %s (%s)" msgstr "Kreeg KEY_CHANGED herkomst %s van %s (%s)" -#: src/tincd.c:98 +#: src/tincd.c:95 #, c-format msgid "Try `%s --help' for more information.\n" msgstr "Probeer `%s --help' voor meer informatie.\n" -#: src/tincd.c:101 +#: src/tincd.c:98 #, c-format msgid "" "Usage: %s [option]...\n" @@ -733,7 +726,7 @@ msgstr "" "Gebruik: %s [optie]...\n" "\n" -#: src/tincd.c:102 +#: src/tincd.c:99 msgid "" " -c, --config=FILE Read configuration options from FILE.\n" " -D, --no-detach Don't fork and detach.\n" @@ -749,7 +742,7 @@ msgstr "" " -n, --net=NETNAAM Verbind met net NETNAAM.\n" " -t, --timeout=TIMEOUT Seconden wachten op timeout.\n" -#: src/tincd.c:108 +#: src/tincd.c:105 msgid "" " --help Display this help and exit.\n" " --version Output version information and exit.\n" @@ -759,69 +752,69 @@ msgstr "" " --version Geef versie informatie en beëindig.\n" "\n" -#: src/tincd.c:110 +#: src/tincd.c:107 msgid "Report bugs to tinc@nl.linux.org.\n" msgstr "" "Meld fouten in het programma aan tinc@nl.linux.org;\n" "meld fouten in de vertaling aan vertaling@nl.linux.org.\n" -#: src/tincd.c:148 +#: src/tincd.c:145 #, c-format msgid "Invalid timeout value `%s'.\n" msgstr "Ongeldige timeout waarde `%s'.\n" -#: src/tincd.c:162 +#: src/tincd.c:159 #, c-format -msgid "Memory exhausted (last is %s:%d) (couldn't allocate %d bytes), exiting" +msgid "Memory exhausted (last is %s:%d) (couldn't allocate %d bytes), exiting." msgstr "" -"Geheugen is vol (laatste %s:%d) (kon geen %d bytes vrijmaken), beëindigen" +"Geheugen is vol (laatste %s:%d) (kon geen %d bytes vrijmaken), beëindigen." -#: src/tincd.c:217 +#: src/tincd.c:214 #, c-format msgid "tincd %s (%s %s) starting, debug level %d" -msgstr "tincd %s (%s %s) gestart, debugniveau %d." +msgstr "tincd %s (%s %s) gestart, debugniveau %d" -#: src/tincd.c:220 +#: src/tincd.c:217 #, c-format msgid "tincd %s starting" msgstr "tincd %s gestart" -#: src/tincd.c:235 +#: src/tincd.c:232 #, c-format msgid "Total bytes written: tap %d, socket %d; bytes read: tap %d, socket %d" msgstr "" "Totaal aantal bytes geschreven: tap %d, socket %d; bytes gelezen: top %d, " "socket %d." -#: src/tincd.c:253 +#: src/tincd.c:250 #, c-format msgid "A tincd is already running for net `%s' with pid %d.\n" msgstr "Een tincd voor net `%s' draait al met procesnummer %d.\n" -#: src/tincd.c:256 +#: src/tincd.c:253 #, c-format msgid "A tincd is already running with pid %d.\n" msgstr "Een tincd draait al met procesnummer %d.\n" -#: src/tincd.c:277 +#: src/tincd.c:274 #, c-format msgid "No other tincd is running for net `%s'.\n" msgstr "Geen andere tincd gevonden voor net `%s'.\n" -#: src/tincd.c:279 +#: src/tincd.c:276 msgid "No other tincd is running.\n" msgstr "Geen andere tincd gevonden.\n" -#: src/tincd.c:286 +#: src/tincd.c:283 msgid "Removing stale lock file.\n" msgstr "Ongebruikt vergrendelingsbestand verwijderd.\n" -#: src/tincd.c:342 +#: src/tincd.c:339 #, c-format msgid "%s version %s\n" msgstr "%s versie %s\n" -#: src/tincd.c:343 +#: src/tincd.c:340 msgid "" "Copyright (C) 1998,1999,2000 Ivo Timmermans and others,\n" "see the AUTHORS file for a complete list.\n" @@ -840,60 +833,62 @@ msgstr "" "zie het bestand COPYING voor details.\n" "\n" -#: src/tincd.c:348 +#: src/tincd.c:345 msgid "" "This product includes software developed by Eric Young (eay@mincom.oz.au)\n" msgstr "" "Dit produkt bevat programmatuur ontwikkeld door Eric Young " "(eay@mincom.oz.au)\n" -#: src/tincd.c:358 +#: src/tincd.c:355 msgid "You must be root to run this program. Sorry.\n" msgstr "" "Je moet systeembeheerder zijn om dit programma te kunnen draaien. Sorry.\n" -#: src/tincd.c:393 +#: src/tincd.c:385 +#, c-format +msgid "Unrecoverable error, restarting in %d seconds!" +msgstr "Onherstelbare fout, herstart in %d seconden!" + +#: src/tincd.c:394 msgid "Got TERM signal" msgstr "Kreeg TERM signaal" -#: src/tincd.c:401 +#: src/tincd.c:402 msgid "Got QUIT signal" msgstr "Kreeg QUIT signaal" -#: src/tincd.c:408 +#: src/tincd.c:409 msgid "Got another SEGV signal: not restarting" msgstr "Kreeg nog een SEGV signaal: niet herstarten" -#: src/tincd.c:416 +#: src/tincd.c:417 #, c-format msgid "Got SEGV signal after %s line %d, trying to re-execute" msgstr "Kreeg SEGV signaal na %s regel %d, probeer opnieuw opstarten" -#: src/tincd.c:419 +#: src/tincd.c:420 msgid "Got SEGV signal, trying to re-execute" msgstr "Kreeg SEGV signaal, probeer opnieuw opstarten" -#: src/tincd.c:431 +#: src/tincd.c:432 msgid "Got HUP signal, rereading configuration and restarting" msgstr "Kreeg HUP signaal, herlezen configuratie en herstarten" -#: src/tincd.c:439 -msgid "Got INT signal, exitting" +#: src/tincd.c:440 +msgid "Got INT signal, exiting" msgstr "Kreeg INT signaal, beëindigen" -#: src/tincd.c:453 +#: src/tincd.c:454 msgid "Got USR2 signal, forcing new key generation" msgstr "Kreeg USR2 signaal, nieuwe sleutels geforceerd" -#: src/tincd.c:461 +#: src/tincd.c:462 #, c-format msgid "Got unexpected signal %d after %s line %d" msgstr "Kreeg onverwacht signaal %d na %s regel %d" -#: src/tincd.c:464 +#: src/tincd.c:465 #, c-format msgid "Got unexpected signal %d" msgstr "Kreeg onverwacht signaal %d" - -#~ msgid "Got HUP signal" -#~ msgstr "Kreeg HUP signaal" diff --git a/src/conf.c b/src/conf.c index 0a72a371..5d6437ff 100644 --- a/src/conf.c +++ b/src/conf.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.c,v 1.9.4.4 2000/06/29 19:47:02 guus Exp $ + $Id: conf.c,v 1.9.4.5 2000/06/30 11:45:14 guus Exp $ */ @@ -109,6 +109,8 @@ cp p->data.val = 0; } + p->argtype = argtype; + if(p->data.val) { if(*cfg) @@ -195,6 +197,7 @@ cp config = cfg; } cp + return 0; } /* @@ -203,6 +206,7 @@ cp int read_config_file(const char *fname) { + int err; FILE *fp; cp if((fp = fopen (fname, "r")) == NULL) @@ -211,12 +215,10 @@ cp return 1; } - if(readconfig(fname, fp)) - return -1; - + err = readconfig(fname, fp); fclose (fp); cp - return 0; + return err; } /* @@ -260,11 +262,13 @@ void clear_config() { config_t *p, *next; cp - for(p = config; p; p = next) + for(p = config; p != NULL; p = next) { next = p->next; - if(p->data.ptr) - free(p->data.ptr); + if(p->data.ptr && (p->argtype == TYPE_NAME)) + { + free(p->data.ptr); + } free(p); } config = NULL; diff --git a/src/conf.h b/src/conf.h index 57a02f5d..1d758595 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,12 +17,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.h,v 1.6.4.4 2000/06/29 19:47:03 guus Exp $ + $Id: conf.h,v 1.6.4.5 2000/06/30 11:45:14 guus Exp $ */ #ifndef __TINC_CONF_H__ #define __TINC_CONF_H__ +#define MAXTIMEOUT 900 /* Maximum timeout value for retries. Should this be a configuration option? */ + typedef struct ip_mask_t { unsigned long ip; unsigned long mask; @@ -46,12 +48,13 @@ typedef enum which_t { keyexpire, vpnmask, resolve_dns, - indirectdata + indirectdata, } which_t; typedef struct config_t { struct config_t *next; which_t which; + int argtype; data_t data; } config_t; diff --git a/src/net.c b/src/net.c index a1757c5b..efd30e6f 100644 --- a/src/net.c +++ b/src/net.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: net.c,v 1.35.4.15 2000/06/29 19:47:03 guus Exp $ + $Id: net.c,v 1.35.4.16 2000/06/30 11:45:14 guus Exp $ */ #include "config.h" @@ -636,11 +636,11 @@ cp signal(SIGALRM, sigalrm_handler); upstreamindex = 0; seconds_till_retry += 5; - if(seconds_till_retry>300) /* Don't wait more than 5 minutes. */ - seconds_till_retry = 300; - alarm(seconds_till_retry); + if(seconds_till_retry > MAXTIMEOUT) /* Don't wait more than MAXTIMEOUT seconds. */ + seconds_till_retry = MAXTIMEOUT; syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"), seconds_till_retry); + alarm(seconds_till_retry); cp } @@ -675,9 +675,9 @@ cp signal(SIGALRM, sigalrm_handler); upstreamindex = 0; - seconds_till_retry = 300; + seconds_till_retry = MAXTIMEOUT; + syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in %d seconds"), seconds_till_retry); alarm(seconds_till_retry); - syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 minutes")); cp return 0; } @@ -779,7 +779,6 @@ cp return NULL; } - p->vpn_hostname = _("unknown"); p->real_ip = ntohl(ci.sin_addr.s_addr); p->real_hostname = hostlookup(ci.sin_addr.s_addr); p->meta_socket = sfd; @@ -1244,19 +1243,15 @@ cp if(sighup) { + sighup = 0; close_network_connections(); clear_config(); if(read_config_file(configfilename)) { - syslog(LOG_ERR, _("Unable to reread configuration file, exitting")); + syslog(LOG_ERR, _("Unable to reread configuration file, exiting")); exit(0); } - if(setup_network_connections()) - { - syslog(LOG_ERR, _("Unable to restart, exitting")); - exit(0); - } - sighup = 0; + setup_network_connections(); continue; } @@ -1265,14 +1260,16 @@ cp { check_dead_connections(); last_ping_check = time(NULL); - continue; } - check_network_activity(&fset); + if(r > 0) + { + check_network_activity(&fset); - /* local tap data */ - if(FD_ISSET(tap_fd, &fset)) - handle_tap_input(); + /* local tap data */ + if(FD_ISSET(tap_fd, &fset)) + handle_tap_input(); + } } cp } diff --git a/src/tincd.c b/src/tincd.c index cecf95ed..f63540aa 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.5 2000/06/29 19:47:04 guus Exp $ + $Id: tincd.c,v 1.10.4.6 2000/06/30 11:45:16 guus Exp $ */ #include "config.h" @@ -374,13 +374,17 @@ main(int argc, char **argv, char **envp) if(security_init()) return 1; - if(setup_network_connections()) - cleanup_and_exit(1); + for(;;) + { + setup_network_connections(); + + main_loop(); - main_loop(); + cleanup_and_exit(1); - cleanup_and_exit(1); - return 1; + syslog(LOG_ERR, _("Unrecoverable error, restarting in %d seconds!"), MAXTIMEOUT); + sleep(MAXTIMEOUT); + } } RETSIGTYPE @@ -433,7 +437,7 @@ RETSIGTYPE sigint_handler(int a) { if(debug_lvl > 0) - syslog(LOG_NOTICE, _("Got INT signal, exitting")); + syslog(LOG_NOTICE, _("Got INT signal, exiting")); cleanup_and_exit(0); } -- 2.39.5