From 6698f7c390a5ae2f262e30560d9df59f9d5c418d Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Mon, 18 May 2009 16:25:10 +0400 Subject: [PATCH] Rename setup_network_connections() and split out try_outgoing_connections() In preparation of chroot/setuid operations, split out call to try_outgoing_connections() from setup_network_connections() (which was the last call in setup_network_connections()). This is because dropping privileges should be done in-between setup_network_connections() and try_outgoing_connections(). This patch renames setup_network_connections() to setup_network() and moves call to try_outgoing_connections() into main routine. No functional changes. --- src/net.h | 2 +- src/net_setup.c | 6 ++---- src/tincd.c | 7 +++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/net.h b/src/net.h index e07e6465..ef211796 100644 --- a/src/net.h +++ b/src/net.h @@ -132,7 +132,7 @@ extern int setup_vpn_in_socket(const sockaddr_t *); extern void send_packet(const struct node_t *, vpn_packet_t *); extern void receive_tcppacket(struct connection_t *, char *, int); extern void broadcast_packet(const struct node_t *, vpn_packet_t *); -extern bool setup_network_connections(void); +extern bool setup_network(void); extern void setup_outgoing_connection(struct outgoing_t *); extern void try_outgoing_connections(void); extern void close_network_connections(void); diff --git a/src/net_setup.c b/src/net_setup.c index 75267794..ec47558d 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -503,9 +503,9 @@ bool setup_myself(void) } /* - setup all initial network connections + initialize network */ -bool setup_network_connections(void) +bool setup_network(void) { cp(); @@ -536,8 +536,6 @@ bool setup_network_connections(void) if(!setup_myself()) return false; - try_outgoing_connections(); - return true; } diff --git a/src/tincd.c b/src/tincd.c index f909d9a0..6fa87853 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -500,13 +500,16 @@ int main2(int argc, char **argv) if(!detach()) return 1; - /* Setup sockets and open device. */ - if(!setup_network_connections()) + if(!setup_network()) goto end; + /* Initiate all outgoing connections. */ + + try_outgoing_connections(); + /* Start main loop. It only exits when tinc is killed. */ status = main_loop(); -- 2.20.1