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