a9377cba7b508f6d33ae617ca532d4009433c24c
[strongswan.git] / src / pluto / plutomain.c
1 /* Pluto main program
2 * Copyright (C) 1997 Angelos D. Keromytis.
3 * Copyright (C) 1998-2001 D. Hugh Redelmeier.
4 * Copyright (C) 2009 Andreas Steffen - Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <ctype.h>
21 #include <errno.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <sys/un.h>
26 #include <fcntl.h>
27 #include <getopt.h>
28 #include <resolv.h>
29 #include <arpa/nameser.h> /* missing from <resolv.h> on old systems */
30 #include <sys/queue.h>
31 #include <sys/prctl.h>
32 #include <pwd.h>
33 #include <grp.h>
34
35 #ifdef CAPABILITIES
36 #include <sys/capability.h>
37 #endif /* CAPABILITIES */
38
39 #include <freeswan.h>
40
41 #include <library.h>
42 #include <debug.h>
43 #include <utils/enumerator.h>
44 #include <utils/optionsfrom.h>
45
46 #ifdef INTEGRITY_TEST
47 #include <fips/fips.h>
48 #include <fips/fips_signature.h>
49 #endif /* INTEGRITY_TEST */
50
51 #include <pfkeyv2.h>
52 #include <pfkey.h>
53
54 #include "constants.h"
55 #include "defs.h"
56 #include "id.h"
57 #include "ca.h"
58 #include "certs.h"
59 #include "ac.h"
60 #include "connections.h"
61 #include "foodgroups.h"
62 #include "packet.h"
63 #include "demux.h" /* needs packet.h */
64 #include "server.h"
65 #include "kernel.h"
66 #include "log.h"
67 #include "keys.h"
68 #include "adns.h" /* needs <resolv.h> */
69 #include "dnskey.h" /* needs keys.h and adns.h */
70 #include "state.h"
71 #include "ipsec_doi.h" /* needs demux.h and state.h */
72 #include "ocsp.h"
73 #include "crl.h"
74 #include "fetch.h"
75 #include "xauth.h"
76 #include "crypto.h"
77 #include "nat_traversal.h"
78 #include "virtual.h"
79 #include "timer.h"
80 #include "vendor.h"
81
82 static void usage(const char *mess)
83 {
84 if (mess != NULL && *mess != '\0')
85 fprintf(stderr, "%s\n", mess);
86 fprintf(stderr
87 , "Usage: pluto"
88 " [--help]"
89 " [--version]"
90 " [--optionsfrom <filename>]"
91 " \\\n\t"
92 "[--nofork]"
93 " [--stderrlog]"
94 " [--noklips]"
95 " [--nocrsend]"
96 " \\\n\t"
97 "[--strictcrlpolicy]"
98 " [--crlcheckinterval <interval>]"
99 " [--cachecrls]"
100 " [--uniqueids]"
101 " \\\n\t"
102 "[--interface <ifname>]"
103 " [--ikeport <port-number>]"
104 " \\\n\t"
105 "[--ctlbase <path>]"
106 " \\\n\t"
107 "[--perpeerlogbase <path>] [--perpeerlog]"
108 " \\\n\t"
109 "[--secretsfile <secrets-file>]"
110 " [--policygroupsdir <policygroups-dir>]"
111 " \\\n\t"
112 "[--adns <pathname>]"
113 "[--pkcs11module <path>]"
114 "[--pkcs11keepstate]"
115 "[--pkcs11initargs <string>]"
116 #ifdef DEBUG
117 " \\\n\t"
118 "[--debug-none]"
119 " [--debug-all]"
120 " \\\n\t"
121 "[--debug-raw]"
122 " [--debug-crypt]"
123 " [--debug-parsing]"
124 " [--debug-emitting]"
125 " \\\n\t"
126 "[--debug-control]"
127 " [--debug-lifecycle]"
128 " [--debug-klips]"
129 " [--debug-dns]"
130 " \\\n\t"
131 "[--debug-oppo]"
132 " [--debug-controlmore]"
133 " [--debug-private]"
134 " [--debug-natt]"
135 #endif
136 " \\\n\t"
137 "[--nat_traversal] [--keep_alive <delay_sec>]"
138 " \\\n\t"
139 "[--force_keepalive] [--disable_port_floating]"
140 " \\\n\t"
141 "[--virtual_private <network_list>]"
142 "\n"
143 "strongSwan "VERSION"\n");
144 exit_pluto(mess == NULL? 0 : 1);
145 }
146
147
148 /* lock file support
149 * - provides convenient way for scripts to find Pluto's pid
150 * - prevents multiple Plutos competing for the same port
151 * - same basename as unix domain control socket
152 * NOTE: will not take account of sharing LOCK_DIR with other systems.
153 */
154
155 static char pluto_lock[sizeof(ctl_addr.sun_path)] = DEFAULT_CTLBASE LOCK_SUFFIX;
156 static bool pluto_lock_created = FALSE;
157
158 /* create lockfile, or die in the attempt */
159 static int create_lock(void)
160 {
161 int fd = open(pluto_lock, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC
162 , S_IRUSR | S_IRGRP | S_IROTH);
163
164 if (fd < 0)
165 {
166 if (errno == EEXIST)
167 {
168 fprintf(stderr, "pluto: lock file \"%s\" already exists\n"
169 , pluto_lock);
170 exit_pluto(10);
171 }
172 else
173 {
174 fprintf(stderr
175 , "pluto: unable to create lock file \"%s\" (%d %s)\n"
176 , pluto_lock, errno, strerror(errno));
177 exit_pluto(1);
178 }
179 }
180 pluto_lock_created = TRUE;
181 return fd;
182 }
183
184 static bool fill_lock(int lockfd, pid_t pid)
185 {
186 char buf[30]; /* holds "<pid>\n" */
187 int len = snprintf(buf, sizeof(buf), "%u\n", (unsigned int) pid);
188 bool ok = len > 0 && write(lockfd, buf, len) == len;
189
190 close(lockfd);
191 return ok;
192 }
193
194 static void delete_lock(void)
195 {
196 if (pluto_lock_created)
197 {
198 delete_ctl_socket();
199 unlink(pluto_lock); /* is noting failure useful? */
200 }
201 }
202
203
204 /* by default pluto sends certificate requests to its peers */
205 bool no_cr_send = FALSE;
206
207 /* by default the CRL policy is lenient */
208 bool strict_crl_policy = FALSE;
209
210 /* by default CRLs are cached locally as files */
211 bool cache_crls = FALSE;
212
213 /* by default pluto does not check crls dynamically */
214 long crl_check_interval = 0;
215
216 /* path to the PKCS#11 module */
217 char *pkcs11_module_path = NULL;
218
219 /* by default pluto logs out after every smartcard use */
220 bool pkcs11_keep_state = FALSE;
221
222 /* by default pluto does not allow pkcs11 proxy access via whack */
223 bool pkcs11_proxy = FALSE;
224
225 /* argument string to pass to PKCS#11 module.
226 * Not used for compliant modules, just for NSS softoken
227 */
228 static const char *pkcs11_init_args = NULL;
229
230 /* options read by optionsfrom */
231 options_t *options;
232
233 /**
234 * Log loaded plugins
235 */
236 static void print_plugins()
237 {
238 char buf[BUF_LEN], *plugin;
239 int len = 0;
240 enumerator_t *enumerator;
241
242 buf[0] = '\0';
243 enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
244 while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin))
245 {
246 len += snprintf(&buf[len], BUF_LEN-len, "%s ", plugin);
247 }
248 enumerator->destroy(enumerator);
249 DBG1("loaded plugins: %s", buf);
250 }
251
252 int main(int argc, char **argv)
253 {
254 bool fork_desired = TRUE;
255 bool log_to_stderr_desired = FALSE;
256 bool nat_traversal = FALSE;
257 bool nat_t_spf = TRUE; /* support port floating */
258 unsigned int keep_alive = 0;
259 bool force_keepalive = FALSE;
260 char *virtual_private = NULL;
261 int lockfd;
262 #ifdef CAPABILITIES
263 cap_t caps;
264 int keep[] = { CAP_NET_ADMIN, CAP_NET_BIND_SERVICE };
265 #endif /* CAPABILITIES */
266
267 /* initialize library and optionsfrom */
268 if (!library_init(STRONGSWAN_CONF))
269 {
270 abort();
271 }
272 options = options_create();
273
274 /* handle arguments */
275 for (;;)
276 {
277 # define DBG_OFFSET 256
278 static const struct option long_opts[] = {
279 /* name, has_arg, flag, val */
280 { "help", no_argument, NULL, 'h' },
281 { "version", no_argument, NULL, 'v' },
282 { "optionsfrom", required_argument, NULL, '+' },
283 { "nofork", no_argument, NULL, 'd' },
284 { "stderrlog", no_argument, NULL, 'e' },
285 { "noklips", no_argument, NULL, 'n' },
286 { "nocrsend", no_argument, NULL, 'c' },
287 { "strictcrlpolicy", no_argument, NULL, 'r' },
288 { "crlcheckinterval", required_argument, NULL, 'x'},
289 { "cachecrls", no_argument, NULL, 'C' },
290 { "uniqueids", no_argument, NULL, 'u' },
291 { "interface", required_argument, NULL, 'i' },
292 { "ikeport", required_argument, NULL, 'p' },
293 { "ctlbase", required_argument, NULL, 'b' },
294 { "secretsfile", required_argument, NULL, 's' },
295 { "foodgroupsdir", required_argument, NULL, 'f' },
296 { "perpeerlogbase", required_argument, NULL, 'P' },
297 { "perpeerlog", no_argument, NULL, 'l' },
298 { "policygroupsdir", required_argument, NULL, 'f' },
299 #ifdef USE_LWRES
300 { "lwdnsq", required_argument, NULL, 'a' },
301 #else /* !USE_LWRES */
302 { "adns", required_argument, NULL, 'a' },
303 #endif /* !USE_LWRES */
304 { "pkcs11module", required_argument, NULL, 'm' },
305 { "pkcs11keepstate", no_argument, NULL, 'k' },
306 { "pkcs11initargs", required_argument, NULL, 'z' },
307 { "pkcs11proxy", no_argument, NULL, 'y' },
308 { "nat_traversal", no_argument, NULL, '1' },
309 { "keep_alive", required_argument, NULL, '2' },
310 { "force_keepalive", no_argument, NULL, '3' },
311 { "disable_port_floating", no_argument, NULL, '4' },
312 { "debug-natt", no_argument, NULL, '5' },
313 { "virtual_private", required_argument, NULL, '6' },
314 #ifdef DEBUG
315 { "debug-none", no_argument, NULL, 'N' },
316 { "debug-all", no_argument, NULL, 'A' },
317 { "debug-raw", no_argument, NULL, DBG_RAW + DBG_OFFSET },
318 { "debug-crypt", no_argument, NULL, DBG_CRYPT + DBG_OFFSET },
319 { "debug-parsing", no_argument, NULL, DBG_PARSING + DBG_OFFSET },
320 { "debug-emitting", no_argument, NULL, DBG_EMITTING + DBG_OFFSET },
321 { "debug-control", no_argument, NULL, DBG_CONTROL + DBG_OFFSET },
322 { "debug-lifecycle", no_argument, NULL, DBG_LIFECYCLE + DBG_OFFSET },
323 { "debug-klips", no_argument, NULL, DBG_KLIPS + DBG_OFFSET },
324 { "debug-dns", no_argument, NULL, DBG_DNS + DBG_OFFSET },
325 { "debug-oppo", no_argument, NULL, DBG_OPPO + DBG_OFFSET },
326 { "debug-controlmore", no_argument, NULL, DBG_CONTROLMORE + DBG_OFFSET },
327 { "debug-private", no_argument, NULL, DBG_PRIVATE + DBG_OFFSET },
328
329 { "impair-delay-adns-key-answer", no_argument, NULL, IMPAIR_DELAY_ADNS_KEY_ANSWER + DBG_OFFSET },
330 { "impair-delay-adns-txt-answer", no_argument, NULL, IMPAIR_DELAY_ADNS_TXT_ANSWER + DBG_OFFSET },
331 { "impair-bust-mi2", no_argument, NULL, IMPAIR_BUST_MI2 + DBG_OFFSET },
332 { "impair-bust-mr2", no_argument, NULL, IMPAIR_BUST_MR2 + DBG_OFFSET },
333 #endif
334 { 0,0,0,0 }
335 };
336 /* Note: we don't like the way short options get parsed
337 * by getopt_long, so we simply pass an empty string as
338 * the list. It could be "hvdenp:l:s:" "NARXPECK".
339 */
340 int c = getopt_long(argc, argv, "", long_opts, NULL);
341
342 /* Note: "breaking" from case terminates loop */
343 switch (c)
344 {
345 case EOF: /* end of flags */
346 break;
347
348 case 0: /* long option already handled */
349 continue;
350
351 case ':': /* diagnostic already printed by getopt_long */
352 case '?': /* diagnostic already printed by getopt_long */
353 usage("");
354 break; /* not actually reached */
355
356 case 'h': /* --help */
357 usage(NULL);
358 break; /* not actually reached */
359
360 case 'v': /* --version */
361 {
362 const char **sp = ipsec_copyright_notice();
363
364 printf("strongSwan "VERSION"%s\n", compile_time_interop_options);
365 for (; *sp != NULL; sp++)
366 puts(*sp);
367 }
368 exit_pluto(0);
369 break; /* not actually reached */
370
371 case '+': /* --optionsfrom <filename> */
372 if (!options->from(options, optarg, &argc, &argv, optind))
373 {
374 exit_pluto(1);
375 }
376 continue;
377
378 case 'd': /* --nofork*/
379 fork_desired = FALSE;
380 continue;
381
382 case 'e': /* --stderrlog */
383 log_to_stderr_desired = TRUE;
384 continue;
385
386 case 'n': /* --noklips */
387 no_klips = TRUE;
388 continue;
389
390 case 'c': /* --nocrsend */
391 no_cr_send = TRUE;
392 continue;
393
394 case 'r': /* --strictcrlpolicy */
395 strict_crl_policy = TRUE;
396 continue;
397
398 case 'x': /* --crlcheckinterval <time>*/
399 if (optarg == NULL || !isdigit(optarg[0]))
400 usage("missing interval time");
401
402 {
403 char *endptr;
404 long interval = strtol(optarg, &endptr, 0);
405
406 if (*endptr != '\0' || endptr == optarg
407 || interval <= 0)
408 usage("<interval-time> must be a positive number");
409 crl_check_interval = interval;
410 }
411 continue;
412
413 case 'C': /* --cachecrls */
414 cache_crls = TRUE;
415 continue;
416
417 case 'u': /* --uniqueids */
418 uniqueIDs = TRUE;
419 continue;
420
421 case 'i': /* --interface <ifname> */
422 if (!use_interface(optarg))
423 usage("too many --interface specifications");
424 continue;
425
426 case 'p': /* --port <portnumber> */
427 if (optarg == NULL || !isdigit(optarg[0]))
428 usage("missing port number");
429
430 {
431 char *endptr;
432 long port = strtol(optarg, &endptr, 0);
433
434 if (*endptr != '\0' || endptr == optarg
435 || port <= 0 || port > 0x10000)
436 usage("<port-number> must be a number between 1 and 65535");
437 pluto_port = port;
438 }
439 continue;
440
441 case 'b': /* --ctlbase <path> */
442 if (snprintf(ctl_addr.sun_path, sizeof(ctl_addr.sun_path)
443 , "%s%s", optarg, CTL_SUFFIX) == -1)
444 usage("<path>" CTL_SUFFIX " too long for sun_path");
445 if (snprintf(info_addr.sun_path, sizeof(info_addr.sun_path)
446 , "%s%s", optarg, INFO_SUFFIX) == -1)
447 usage("<path>" INFO_SUFFIX " too long for sun_path");
448 if (snprintf(pluto_lock, sizeof(pluto_lock)
449 , "%s%s", optarg, LOCK_SUFFIX) == -1)
450 usage("<path>" LOCK_SUFFIX " must fit");
451 continue;
452
453 case 's': /* --secretsfile <secrets-file> */
454 shared_secrets_file = optarg;
455 continue;
456
457 case 'f': /* --policygroupsdir <policygroups-dir> */
458 policygroups_dir = optarg;
459 continue;
460
461 case 'a': /* --adns <pathname> */
462 pluto_adns_option = optarg;
463 continue;
464
465 case 'm': /* --pkcs11module <pathname> */
466 pkcs11_module_path = optarg;
467 continue;
468
469 case 'k': /* --pkcs11keepstate */
470 pkcs11_keep_state = TRUE;
471 continue;
472
473 case 'y': /* --pkcs11proxy */
474 pkcs11_proxy = TRUE;
475 continue;
476
477 case 'z': /* --pkcs11initargs */
478 pkcs11_init_args = optarg;
479 continue;
480
481 #ifdef DEBUG
482 case 'N': /* --debug-none */
483 base_debugging = DBG_NONE;
484 continue;
485
486 case 'A': /* --debug-all */
487 base_debugging = DBG_ALL;
488 continue;
489 #endif
490
491 case 'P': /* --perpeerlogbase */
492 base_perpeer_logdir = optarg;
493 continue;
494
495 case 'l':
496 log_to_perpeer = TRUE;
497 continue;
498
499 case '1': /* --nat_traversal */
500 nat_traversal = TRUE;
501 continue;
502 case '2': /* --keep_alive */
503 keep_alive = atoi(optarg);
504 continue;
505 case '3': /* --force_keepalive */
506 force_keepalive = TRUE;
507 continue;
508 case '4': /* --disable_port_floating */
509 nat_t_spf = FALSE;
510 continue;
511 case '5': /* --debug-nat_t */
512 base_debugging |= DBG_NATT;
513 continue;
514 case '6': /* --virtual_private */
515 virtual_private = optarg;
516 continue;
517
518 default:
519 #ifdef DEBUG
520 if (c >= DBG_OFFSET)
521 {
522 base_debugging |= c - DBG_OFFSET;
523 continue;
524 }
525 # undef DBG_OFFSET
526 #endif
527 bad_case(c);
528 }
529 break;
530 }
531 if (optind != argc)
532 usage("unexpected argument");
533 reset_debugging();
534 lockfd = create_lock();
535
536 /* select between logging methods */
537
538 if (log_to_stderr_desired)
539 {
540 log_to_syslog = FALSE;
541 }
542 else
543 {
544 log_to_stderr = FALSE;
545 }
546
547 /* set the logging function of pfkey debugging */
548 #ifdef DEBUG
549 pfkey_debug_func = DBG_log;
550 #else
551 pfkey_debug_func = NULL;
552 #endif
553
554 /* create control socket.
555 * We must create it before the parent process returns so that
556 * there will be no race condition in using it. The easiest
557 * place to do this is before the daemon fork.
558 */
559 {
560 err_t ugh = init_ctl_socket();
561
562 if (ugh != NULL)
563 {
564 fprintf(stderr, "pluto: %s", ugh);
565 exit_pluto(1);
566 }
567 }
568
569 /* If not suppressed, do daemon fork */
570
571 if (fork_desired)
572 {
573 {
574 pid_t pid = fork();
575
576 if (pid < 0)
577 {
578 int e = errno;
579
580 fprintf(stderr, "pluto: fork failed (%d %s)\n",
581 errno, strerror(e));
582 exit_pluto(1);
583 }
584
585 if (pid != 0)
586 {
587 /* parent: die, after filling PID into lock file.
588 * must not use exit_pluto: lock would be removed!
589 */
590 exit(fill_lock(lockfd, pid)? 0 : 1);
591 }
592 }
593
594 if (setsid() < 0)
595 {
596 int e = errno;
597
598 fprintf(stderr, "setsid() failed in main(). Errno %d: %s\n",
599 errno, strerror(e));
600 exit_pluto(1);
601 }
602 }
603 else
604 {
605 /* no daemon fork: we have to fill in lock file */
606 (void) fill_lock(lockfd, getpid());
607 fprintf(stdout, "Pluto initialized\n");
608 fflush(stdout);
609 }
610
611 /* Close everything but ctl_fd and (if needed) stderr.
612 * There is some danger that a library that we don't know
613 * about is using some fd that we don't know about.
614 * I guess we'll soon find out.
615 */
616 {
617 int i;
618
619 for (i = getdtablesize() - 1; i >= 0; i--) /* Bad hack */
620 {
621 if ((!log_to_stderr || i != 2) && i != ctl_fd)
622 close(i);
623 }
624
625 /* make sure that stdin, stdout, stderr are reserved */
626 if (open("/dev/null", O_RDONLY) != 0)
627 abort();
628 if (dup2(0, 1) != 1)
629 abort();
630 if (!log_to_stderr && dup2(0, 2) != 2)
631 abort();
632 }
633
634 init_constants();
635 init_log("pluto");
636
637 /* Note: some scripts may look for this exact message -- don't change
638 * ipsec barf was one, but it no longer does.
639 */
640 plog("Starting IKEv1 pluto daemon (strongSwan "VERSION")%s",
641 compile_time_interop_options);
642
643 /* load plugins, further infrastructure may need it */
644 lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
645 lib->settings->get_str(lib->settings, "pluto.load", PLUGINS));
646 print_plugins();
647
648 #ifdef INTEGRITY_TEST
649 DBG1("integrity test of libstrongswan code");
650 if (fips_verify_hmac_signature(hmac_key, hmac_signature))
651 {
652 DBG1(" integrity test passed");
653 }
654 else
655 {
656 DBG1(" integrity test failed");
657 abort();
658 }
659 #endif /* INTEGRITY_TEST */
660
661 init_nat_traversal(nat_traversal, keep_alive, force_keepalive, nat_t_spf);
662 init_virtual_ip(virtual_private);
663 scx_init(pkcs11_module_path, pkcs11_init_args);
664 xauth_init();
665 init_secret();
666 init_states();
667 init_crypto();
668 init_demux();
669 init_kernel();
670 init_adns();
671 init_id();
672 init_fetch();
673
674 /* drop unneeded capabilities and change UID/GID */
675 prctl(PR_SET_KEEPCAPS, 1);
676
677 #ifdef IPSEC_GROUP
678 {
679 struct group group, *grp;
680 char buf[1024];
681
682 if (getgrnam_r(IPSEC_GROUP, &group, buf, sizeof(buf), &grp) != 0 ||
683 grp == NULL || setgid(grp->gr_gid) != 0)
684 {
685 plog("unable to change daemon group");
686 abort();
687 }
688 }
689 #endif
690 #ifdef IPSEC_USER
691 {
692 struct passwd passwd, *pwp;
693 char buf[1024];
694
695 if (getpwnam_r(IPSEC_USER, &passwd, buf, sizeof(buf), &pwp) != 0 ||
696 pwp == NULL || setuid(pwp->pw_uid) != 0)
697 {
698 plog("unable to change daemon user");
699 abort();
700 }
701 }
702 #endif
703
704 #ifdef CAPABILITIES
705 caps = cap_init();
706 cap_set_flag(caps, CAP_EFFECTIVE, 2, keep, CAP_SET);
707 cap_set_flag(caps, CAP_INHERITABLE, 2, keep, CAP_SET);
708 cap_set_flag(caps, CAP_PERMITTED, 2, keep, CAP_SET);
709 if (cap_set_proc(caps) != 0)
710 {
711 plog("unable to drop daemon capabilities");
712 abort();
713 }
714 cap_free(caps);
715 #endif /* CAPABILITIES */
716
717 /* loading X.509 CA certificates */
718 load_authcerts("CA cert", CA_CERT_PATH, AUTH_CA);
719 /* loading X.509 AA certificates */
720 load_authcerts("AA cert", AA_CERT_PATH, AUTH_AA);
721 /* loading X.509 OCSP certificates */
722 load_authcerts("OCSP cert", OCSP_CERT_PATH, AUTH_OCSP);
723 /* loading X.509 CRLs */
724 load_crls();
725 /* loading attribute certificates (experimental) */
726 load_acerts();
727
728 daily_log_event();
729 call_server();
730 return -1; /* Shouldn't ever reach this */
731 }
732
733 /* leave pluto, with status.
734 * Once child is launched, parent must not exit this way because
735 * the lock would be released.
736 *
737 * 0 OK
738 * 1 general discomfort
739 * 10 lock file exists
740 */
741 void exit_pluto(int status)
742 {
743 reset_globals(); /* needed because we may be called in odd state */
744 free_preshared_secrets();
745 free_remembered_public_keys();
746 delete_every_connection();
747 free_crl_fetch(); /* free chain of crl fetch requests */
748 free_ocsp_fetch(); /* free chain of ocsp fetch requests */
749 free_authcerts(); /* free chain of X.509 authority certificates */
750 free_crls(); /* free chain of X.509 CRLs */
751 free_acerts(); /* free chain of X.509 attribute certificates */
752 free_ca_infos(); /* free chain of X.509 CA information records */
753 free_ocsp(); /* free ocsp cache */
754 free_ifaces();
755 scx_finalize(); /* finalize and unload PKCS #11 module */
756 xauth_finalize(); /* finalize and unload XAUTH module */
757 stop_adns();
758 free_md_pool();
759 free_crypto();
760 free_id(); /* free myids */
761 free_events(); /* free remaining events */
762 free_vendorid(); /* free all vendor id records */
763 delete_lock();
764 options->destroy(options);
765 library_deinit();
766 close_log();
767 exit(status);
768 }
769
770 /*
771 * Local Variables:
772 * c-basic-offset:4
773 * c-style: pluto
774 * End:
775 */