From b98d9787fdde54f33dcdb376e1e018cd418aff8d Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 27 Oct 2001 15:19:13 +0000 Subject: [PATCH] Various small fixes to make tinc runnable again. --- src/conf.c | 15 +++++++++------ src/connection.c | 8 ++++++-- src/net.c | 13 ++++++++----- src/process.c | 5 ++++- src/tincd.c | 3 ++- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/conf.c b/src/conf.c index bd546c6b..c4fe101e 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.45 2001/10/27 12:13:17 guus Exp $ + $Id: conf.c,v 1.9.4.46 2001/10/27 15:19:13 guus Exp $ */ #include "config.h" @@ -126,11 +126,14 @@ cp cfg.line = 0; found = avl_search_closest_greater(config_tree, &cfg); + + if(!found) + return NULL; - if(!strcmp(found->variable, variable)) - return found; - else + if(strcmp(found->variable, variable)) return NULL; + + return found; } config_t *lookup_config_next(avl_tree_t *config_tree, config_t *cfg) @@ -253,12 +256,12 @@ cp /* Teach newbies what subnets are... */ - if((subnet->net.ipv4.address & subnet->net.ipv4.mask) != subnet->net.ipv4.address) + if((ip->address & ip->mask) != ip->address) { syslog(LOG_ERR, _("Network address and subnet mask for configuration variable %s in %s line %d"), cfg->value, cfg->file, cfg->line); free(ip); - return -1; + return 0; } subnet = new_subnet(); diff --git a/src/connection.c b/src/connection.c index a86faa9c..ccc41252 100644 --- a/src/connection.c +++ b/src/connection.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: connection.c,v 1.1.2.20 2001/10/27 12:13:17 guus Exp $ + $Id: connection.c,v 1.1.2.21 2001/10/27 15:19:13 guus Exp $ */ #include "config.h" @@ -62,8 +62,12 @@ cp connection_t *new_connection(void) { + connection_t *c; +cp + c = (connection_t *)xmalloc_and_zero(sizeof(connection_t)); + init_configuration(&c->config_tree); cp - return (connection_t *)xmalloc_and_zero(sizeof(connection_t)); + return c; } void free_connection(connection_t *c) diff --git a/src/net.c b/src/net.c index fe9eed78..50f4acb4 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.138 2001/10/27 13:13:35 guus Exp $ + $Id: net.c,v 1.35.4.139 2001/10/27 15:19:13 guus Exp $ */ #include "config.h" @@ -666,9 +666,11 @@ cp return -1; } */ - if(!get_config_port(lookup_config(myself->connection->config_tree, "Port"), &myself->connection->port)) + if(!get_config_port(lookup_config(myself->connection->config_tree, "Port"), &myself->port)) myself->port = 655; + myself->connection->port = myself->port; + /* Read in all the subnets specified in the host configuration file */ cfg = lookup_config(myself->connection->config_tree, "Subnet"); @@ -705,7 +707,7 @@ cp if(myself->options & OPTION_TCPONLY) myself->options |= OPTION_INDIRECT; - if(get_config_string(lookup_config(myself->connection->config_tree, "Mode"), &mode)) + if(get_config_string(lookup_config(config_tree, "Mode"), &mode)) { if(!strcasecmp(mode, "router")) routing_mode = RMODE_ROUTER; @@ -746,7 +748,7 @@ cp myself->key = (char *)xmalloc(myself->keylength); RAND_pseudo_bytes(myself->key, myself->keylength); - if(!get_config_int(lookup_config(myself->connection->config_tree, "KeyExpire"), &keylifetime)) + if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime)) keylifetime = 3600; keyexpires = time(NULL) + keylifetime; @@ -771,8 +773,9 @@ int setup_network_connections(void) cp init_connections(); init_subnets(); + init_nodes(); - if(get_config_int(lookup_config(myself->connection->config_tree, "PingTimeout"), &timeout)) + if(get_config_int(lookup_config(config_tree, "PingTimeout"), &timeout)) { if(timeout < 1) { diff --git a/src/process.c b/src/process.c index d971a0f2..86153b5a 100644 --- a/src/process.c +++ b/src/process.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: process.c,v 1.1.2.27 2001/10/27 13:13:35 guus Exp $ + $Id: process.c,v 1.1.2.28 2001/10/27 15:19:13 guus Exp $ */ #include "config.h" @@ -437,6 +437,9 @@ setup_signals(void) sigaction(i, &act, NULL); } + if(!do_detach) + sighandlers[3].handler = SIG_DFL; + /* Then, for each known signal that we want to catch, assign a handler to the signal, with error checking this time. */ for(i = 0; sighandlers[i].signal; i++) diff --git a/src/tincd.c b/src/tincd.c index b790d7a1..2943d0bf 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.53 2001/10/27 12:13:17 guus Exp $ + $Id: tincd.c,v 1.10.4.54 2001/10/27 15:19:13 guus Exp $ */ #include "config.h" @@ -319,6 +319,7 @@ main(int argc, char **argv, char **envp) g_argv = argv; make_names(); + init_configuration(&config_tree); /* Slllluuuuuuurrrrp! */ cp -- 2.39.5