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