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