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