Various small fixes to make tinc runnable again.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Oct 2001 15:19:13 +0000 (15:19 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Oct 2001 15:19:13 +0000 (15:19 +0000)
src/conf.c
src/connection.c
src/net.c
src/process.c
src/tincd.c

index bd546c6bd4fc2e1da26c8aebe537f99d5f327c9c..c4fe101e0231f94e2f3a14a0fe14a20a3f585cb1 100644 (file)
@@ -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();
index a86faa9c6d5aeef9f779d96e3af6c3d6105eaf7d..ccc41252d35960e8a5343ef3aceff404b0da9195 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: 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)
index fe9eed7846f40ddce15295f0af64c87a5aab9400..50f4acb4f44cc46fe78003541d7b6da798becec1 100644 (file)
--- 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)
         {
index d971a0f23b2eb9d6f2798f2c5e7f6e369f2c7f4e..86153b5ac9ce46225c0047242fb71aad2b223b09 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: 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++)
index b790d7a14075fee88e28f8ae1105bfc3356ec667..2943d0bfc60276f7f5082a43a03c327496374fe4 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.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