1 /* $OpenBSD: init.c,v 1.18 2001/12/10 03:34:51 ho Exp $ */ 2 /* $EOM: init.c,v 1.25 2000/03/30 14:27:24 ho Exp $ */ 3 4 /* 5 * Copyright (c) 1998, 1999, 2000 Niklas Hallqvist. All rights reserved. 6 * Copyright (c) 2000 Angelos D. Keromytis. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Ericsson Radio Systems. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 /* 35 * This code was written under funding by Ericsson Radio Systems. 36 */ 37 38 /* XXX This file could easily be built dynamically instead. */ 39 40 #include "sysdep.h" 41 42 #include "app.h" 43 #include "cert.h" 44 #include "conf.h" 45 #include "connection.h" 46 #include "doi.h" 47 #include "exchange.h" 48 #include "init.h" 49 #include "ipsec.h" 50 #include "isakmp_doi.h" 51 #include "libcrypto.h" 52 #include "log.h" 53 #include "math_group.h" 54 #include "sa.h" 55 #include "timer.h" 56 #include "transport.h" 57 #include "udp.h" 58 #include "ui.h" 59 #include "util.h" 60 61 #ifdef USE_POLICY 62 #include "policy.h" 63 #endif 64 65 void 66 init (void) 67 { 68 log_init (); 69 app_init (); 70 doi_init (); 71 exchange_init (); 72 group_init (); 73 ipsec_init (); 74 isakmp_doi_init (); 75 libcrypto_init (); 76 77 tzset (); 78 79 timer_init (); 80 81 /* The following group are depending on timer_init having run. */ 82 conf_init (); 83 connection_init (); 84 85 #ifdef USE_POLICY 86 /* policy_init depends on conf_init having run. */ 87 policy_init (); 88 #endif 89 90 /* Depends on conf_init and policy_init having run */ 91 cert_init (); 92 93 sa_init (); 94 transport_init (); 95 udp_init (); 96 ui_init (); 97 } 98 99 /* Reinitialize, either after a SIGHUP reception or by FIFO UI cmd. */ 100 void 101 reinit (void) 102 { 103 log_print ("reinitializing daemon"); 104 105 /* 106 * XXX Remove all(/some?) pending exchange timers? - they may not be 107 * possible to complete after we've re-read the config file. 108 * User-initiated SIGHUP's maybe "authorizes" a wait until 109 * next connection-check. 110 * XXX This means we discard exchange->last_msg, is this really ok? 111 */ 112 113 /* Reinitialize PRNG if we are in deterministic mode. */ 114 if (regrand) 115 srandom (seed); 116 117 /* Reread config file. */ 118 conf_reinit (); 119 120 /* Try again to link in libcrypto (good if we started without /usr). */ 121 libcrypto_init (); 122 123 /* Set timezone */ 124 tzset (); 125 126 #ifdef USE_POLICY 127 /* Reread the policies. */ 128 policy_init (); 129 #endif 130 131 /* Reinitialize certificates */ 132 cert_init (); 133 134 /* Reinitialize our connection list. */ 135 connection_reinit (); 136 137 /* 138 * Rescan interfaces. 139 */ 140 transport_reinit (); 141 142 /* 143 * XXX "These" (non-existant) reinitializations should not be done. 144 * cookie_reinit (); 145 * ui_reinit (); 146 * sa_reinit (); 147 */ 148 } 149