Fix compilation when OpenSSL has no ENGINE support
[tinc] / src / tincd.c
1 /*
2     tincd.c -- the main file for tincd
3     Copyright (C) 1998-2005 Ivo Timmermans
4                   2000-2018 Guus Sliepen <guus@tinc-vpn.org>
5                   2008      Max Rijevski <maksuf@gmail.com>
6                   2009      Michael Tokarev <mjt@tls.msk.ru>
7                   2010      Julien Muchembled <jm@jmuchemb.eu>
8                   2010      Timothy Redaelli <timothy@redaelli.eu>
9
10     This program is free software; you can redistribute it and/or modify
11     it under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU General Public License for more details.
19
20     You should have received a copy of the GNU General Public License along
21     with this program; if not, write to the Free Software Foundation, Inc.,
22     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24
25 #include "system.h"
26
27 /* Darwin (MacOS/X) needs the following definition... */
28 #ifndef _P1003_1B_VISIBLE
29 #define _P1003_1B_VISIBLE
30 #endif
31
32 #ifdef HAVE_SYS_MMAN_H
33 #include <sys/mman.h>
34 #endif
35
36 #include <openssl/rand.h>
37 #include <openssl/rsa.h>
38 #include <openssl/pem.h>
39 #include <openssl/evp.h>
40 #ifndef OPENSSL_NO_ENGINE
41 #include <openssl/engine.h>
42 #endif
43
44 #ifdef HAVE_LZO
45 #include LZO1X_H
46 #endif
47
48 #ifndef HAVE_MINGW
49 #include <pwd.h>
50 #include <grp.h>
51 #include <time.h>
52 #endif
53
54 #ifdef HAVE_GETOPT_LONG
55 #include <getopt.h>
56 #else
57 #include "getopt.h"
58 #endif
59
60 #include "pidfile.h"
61
62 #include "conf.h"
63 #include "device.h"
64 #include "logger.h"
65 #include "net.h"
66 #include "netutl.h"
67 #include "process.h"
68 #include "protocol.h"
69 #include "utils.h"
70 #include "xalloc.h"
71
72 /* The name this program was run with. */
73 char *program_name = NULL;
74
75 /* If nonzero, display usage information and exit. */
76 bool show_help = false;
77
78 /* If nonzero, print the version on standard output and exit.  */
79 bool show_version = false;
80
81 /* If nonzero, it will attempt to kill a running tincd and exit. */
82 int kill_tincd = 0;
83
84 /* If nonzero, generate public/private keypair for this host/net. */
85 int generate_keys = 0;
86
87 /* If nonzero, use null ciphers and skip all key exchanges. */
88 bool bypass_security = false;
89
90 /* If nonzero, disable swapping for this process. */
91 bool do_mlock = false;
92
93 /* If nonzero, chroot to netdir after startup. */
94 static bool do_chroot = false;
95
96 /* If !NULL, do setuid to given user after startup */
97 static const char *switchuser = NULL;
98
99 /* If nonzero, write log entries to a separate file. */
100 bool use_logfile = false;
101
102 char *identname = NULL;                         /* program name for syslog */
103 char *pidfilename = NULL;                       /* pid file location */
104 char *logfilename = NULL;                       /* log file location */
105 char **g_argv;                                  /* a copy of the cmdline arguments */
106
107 static int status = 1;
108
109 static struct option const long_options[] = {
110         {"config", required_argument, NULL, 'c'},
111         {"kill", optional_argument, NULL, 'k'},
112         {"net", required_argument, NULL, 'n'},
113         {"help", no_argument, NULL, 1},
114         {"version", no_argument, NULL, 2},
115         {"no-detach", no_argument, NULL, 'D'},
116         {"generate-keys", optional_argument, NULL, 'K'},
117         {"debug", optional_argument, NULL, 'd'},
118         {"bypass-security", no_argument, NULL, 3},
119         {"mlock", no_argument, NULL, 'L'},
120         {"chroot", no_argument, NULL, 'R'},
121         {"user", required_argument, NULL, 'U'},
122         {"logfile", optional_argument, NULL, 4},
123         {"pidfile", required_argument, NULL, 5},
124         {"option", required_argument, NULL, 'o'},
125         {NULL, 0, NULL, 0}
126 };
127
128 #ifdef HAVE_MINGW
129 static struct WSAData wsa_state;
130 CRITICAL_SECTION mutex;
131 int main2(int argc, char **argv);
132 #endif
133
134 static void usage(bool status) {
135         if(status)
136                 fprintf(stderr, "Try `%s --help\' for more information.\n",
137                         program_name);
138         else {
139                 printf("Usage: %s [option]...\n\n", program_name);
140                 printf("  -c, --config=DIR               Read configuration options from DIR.\n"
141                        "  -D, --no-detach                Don't fork and detach.\n"
142                        "  -d, --debug[=LEVEL]            Increase debug level or set it to LEVEL.\n"
143                        "  -k, --kill[=SIGNAL]            Attempt to kill a running tincd and exit.\n"
144                        "  -n, --net=NETNAME              Connect to net NETNAME.\n"
145                        "  -K, --generate-keys[=BITS]     Generate public/private RSA keypair.\n"
146                        "  -L, --mlock                    Lock tinc into main memory.\n"
147                        "      --logfile[=FILENAME]       Write log entries to a logfile.\n"
148                        "      --pidfile=FILENAME         Write PID to FILENAME.\n"
149                        "  -o, --option=[HOST.]KEY=VALUE  Set global/host configuration value.\n"
150                        "  -R, --chroot                   chroot to NET dir at startup.\n"
151                        "  -U, --user=USER                setuid to given USER at startup.\n"
152                        "      --help                     Display this help and exit.\n"
153                        "      --version                  Output version information and exit.\n\n");
154                 printf("Report bugs to tinc@tinc-vpn.org.\n");
155         }
156 }
157
158 static bool parse_options(int argc, char **argv) {
159         config_t *cfg;
160         int r;
161         int option_index = 0;
162         int lineno = 0;
163
164         cmdline_conf = list_alloc((list_action_t)free_config);
165
166         while((r = getopt_long(argc, argv, "c:DLd::k::n:o:K::RU:", long_options, &option_index)) != EOF) {
167                 switch(r) {
168                 case 0:                         /* long option */
169                         break;
170
171                 case 'c':                               /* config file */
172                         if(confbase) {
173                                 fprintf(stderr, "Only one configuration directory can be given.\n");
174                                 usage(true);
175                                 return false;
176                         }
177
178                         confbase = xstrdup(optarg);
179                         break;
180
181                 case 'D':                               /* no detach */
182                         do_detach = false;
183                         break;
184
185                 case 'L':                               /* no detach */
186 #ifndef HAVE_MLOCKALL
187                         logger(LOG_ERR, "%s not supported on this platform", "mlockall()");
188                         return false;
189 #else
190                         do_mlock = true;
191                         break;
192 #endif
193
194                 case 'd':                               /* increase debug level */
195                         if(!optarg && optind < argc && *argv[optind] != '-') {
196                                 optarg = argv[optind++];
197                         }
198
199                         if(optarg) {
200                                 debug_level = atoi(optarg);
201                         } else {
202                                 debug_level++;
203                         }
204
205                         break;
206
207                 case 'k':                               /* kill old tincds */
208 #ifndef HAVE_MINGW
209                         if(!optarg && optind < argc && *argv[optind] != '-') {
210                                 optarg = argv[optind++];
211                         }
212
213                         if(optarg) {
214                                 if(!strcasecmp(optarg, "HUP")) {
215                                         kill_tincd = SIGHUP;
216                                 } else if(!strcasecmp(optarg, "TERM")) {
217                                         kill_tincd = SIGTERM;
218                                 } else if(!strcasecmp(optarg, "KILL")) {
219                                         kill_tincd = SIGKILL;
220                                 } else if(!strcasecmp(optarg, "USR1")) {
221                                         kill_tincd = SIGUSR1;
222                                 } else if(!strcasecmp(optarg, "USR2")) {
223                                         kill_tincd = SIGUSR2;
224                                 } else if(!strcasecmp(optarg, "WINCH")) {
225                                         kill_tincd = SIGWINCH;
226                                 } else if(!strcasecmp(optarg, "INT")) {
227                                         kill_tincd = SIGINT;
228                                 } else if(!strcasecmp(optarg, "ALRM")) {
229                                         kill_tincd = SIGALRM;
230                                 } else if(!strcasecmp(optarg, "ABRT")) {
231                                         kill_tincd = SIGABRT;
232                                 } else {
233                                         kill_tincd = atoi(optarg);
234
235                                         if(!kill_tincd) {
236                                                 fprintf(stderr, "Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n",
237                                                         optarg);
238                                                 usage(true);
239                                                 return false;
240                                         }
241                                 }
242                         } else {
243                                 kill_tincd = SIGTERM;
244                         }
245
246 #else
247                         kill_tincd = 1;
248 #endif
249                         break;
250
251                 case 'n':                               /* net name given */
252
253                         /* netname "." is special: a "top-level name" */
254                         if(netname) {
255                                 fprintf(stderr, "Only one netname can be given.\n");
256                                 usage(true);
257                                 return false;
258                         }
259
260                         if(optarg && strcmp(optarg, ".")) {
261                                 netname = xstrdup(optarg);
262                         }
263
264                         break;
265
266                 case 'o':                               /* option */
267                         cfg = parse_config_line(optarg, NULL, ++lineno);
268
269                         if(!cfg) {
270                                 return false;
271                         }
272
273                         list_insert_tail(cmdline_conf, cfg);
274                         break;
275
276                 case 'K':                               /* generate public/private keypair */
277                         if(!optarg && optind < argc && *argv[optind] != '-') {
278                                 optarg = argv[optind++];
279                         }
280
281                         if(optarg) {
282                                 generate_keys = atoi(optarg);
283
284                                 if(generate_keys < 512) {
285                                         fprintf(stderr, "Invalid argument `%s'; BITS must be a number equal to or greater than 512.\n",
286                                                 optarg);
287                                         usage(true);
288                                         return false;
289                                 }
290
291                                 generate_keys &= ~7;    /* Round it to bytes */
292                         } else {
293                                 generate_keys = 2048;
294                         }
295
296                         break;
297
298                 case 'R':                               /* chroot to NETNAME dir */
299                         do_chroot = true;
300                         break;
301
302                 case 'U':                               /* setuid to USER */
303                         switchuser = optarg;
304                         break;
305
306                 case 1:                                 /* show help */
307                         show_help = true;
308                         break;
309
310                 case 2:                                 /* show version */
311                         show_version = true;
312                         break;
313
314                 case 3:                                 /* bypass security */
315                         bypass_security = true;
316                         break;
317
318                 case 4:                                 /* write log entries to a file */
319                         use_logfile = true;
320
321                         if(!optarg && optind < argc && *argv[optind] != '-') {
322                                 optarg = argv[optind++];
323                         }
324
325                         if(optarg) {
326                                 if(logfilename) {
327                                         fprintf(stderr, "Only one logfile can be given.\n");
328                                         usage(true);
329                                         return false;
330                                 }
331
332                                 logfilename = xstrdup(optarg);
333                         }
334
335                         break;
336
337                 case 5:                                 /* write PID to a file */
338                         if(pidfilename) {
339                                 fprintf(stderr, "Only one pidfile can be given.\n");
340                                 usage(true);
341                                 return false;
342                         }
343
344                         pidfilename = xstrdup(optarg);
345                         break;
346
347                 case '?':
348                         usage(true);
349                         return false;
350
351                 default:
352                         break;
353                 }
354         }
355
356         if(optind < argc) {
357                 fprintf(stderr, "%s: unrecognized argument '%s'\n", argv[0], argv[optind]);
358                 usage(true);
359                 return false;
360         }
361
362         return true;
363 }
364
365 /* This function prettyprints the key generation process */
366
367 static int indicator(int a, int b, BN_GENCB *cb) {
368         (void)cb;
369
370         switch(a) {
371         case 0:
372                 fprintf(stderr, ".");
373                 break;
374
375         case 1:
376                 fprintf(stderr, "+");
377                 break;
378
379         case 2:
380                 fprintf(stderr, "-");
381                 break;
382
383         case 3:
384                 switch(b) {
385                 case 0:
386                         fprintf(stderr, " p\n");
387                         break;
388
389                 case 1:
390                         fprintf(stderr, " q\n");
391                         break;
392
393                 default:
394                         fprintf(stderr, "?");
395                 }
396
397                 break;
398
399         default:
400                 fprintf(stderr, "?");
401         }
402
403         return 1;
404 }
405
406 #ifndef HAVE_BN_GENCB_NEW
407 BN_GENCB *BN_GENCB_new(void) {
408         return xmalloc_and_zero(sizeof(BN_GENCB));
409 }
410
411 void BN_GENCB_free(BN_GENCB *cb) {
412         free(cb);
413 }
414 #endif
415
416 /*
417   Generate a public/private RSA keypair, and ask for a file to store
418   them in.
419 */
420 static bool keygen(int bits) {
421         BIGNUM *e = NULL;
422         RSA *rsa_key;
423         FILE *f;
424         char filename[PATH_MAX];
425         BN_GENCB *cb;
426         int result;
427
428         fprintf(stderr, "Generating %d bits keys:\n", bits);
429
430         cb = BN_GENCB_new();
431
432         if(!cb) {
433                 abort();
434         }
435
436         BN_GENCB_set(cb, indicator, NULL);
437
438         rsa_key = RSA_new();
439
440         if(BN_hex2bn(&e, "10001") == 0) {
441                 abort();
442         }
443
444         if(!rsa_key || !e) {
445                 abort();
446         }
447
448         result = RSA_generate_key_ex(rsa_key, bits, e, cb);
449
450         BN_free(e);
451         BN_GENCB_free(cb);
452
453         if(!result) {
454                 fprintf(stderr, "Error during key generation!\n");
455                 RSA_free(rsa_key);
456                 return false;
457         } else {
458                 fprintf(stderr, "Done.\n");
459         }
460
461         snprintf(filename, sizeof(filename), "%s/rsa_key.priv", confbase);
462         f = ask_and_open(filename, "private RSA key");
463
464         if(!f) {
465                 RSA_free(rsa_key);
466                 return false;
467         }
468
469 #ifdef HAVE_FCHMOD
470         /* Make it unreadable for others. */
471         fchmod(fileno(f), 0600);
472 #endif
473
474         fputc('\n', f);
475         PEM_write_RSAPrivateKey(f, rsa_key, NULL, NULL, 0, NULL, NULL);
476         fclose(f);
477
478         char *name = get_name();
479
480         if(name) {
481                 snprintf(filename, sizeof(filename), "%s/hosts/%s", confbase, name);
482                 free(name);
483         } else {
484                 snprintf(filename, sizeof(filename), "%s/rsa_key.pub", confbase);
485         }
486
487         f = ask_and_open(filename, "public RSA key");
488
489         if(!f) {
490                 RSA_free(rsa_key);
491                 return false;
492         }
493
494         fputc('\n', f);
495         PEM_write_RSAPublicKey(f, rsa_key);
496         fclose(f);
497
498         RSA_free(rsa_key);
499
500         return true;
501 }
502
503 /*
504   Set all files and paths according to netname
505 */
506 static void make_names(void) {
507 #ifdef HAVE_MINGW
508         HKEY key;
509         char installdir[1024] = "";
510         DWORD len = sizeof(installdir);
511 #endif
512
513         if(netname) {
514                 xasprintf(&identname, "tinc.%s", netname);
515         } else {
516                 identname = xstrdup("tinc");
517         }
518
519 #ifdef HAVE_MINGW
520
521         if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
522                 if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) {
523                         if(!confbase) {
524                                 if(netname) {
525                                         xasprintf(&confbase, "%s/%s", installdir, netname);
526                                 } else {
527                                         xasprintf(&confbase, "%s", installdir);
528                                 }
529                         }
530
531                         if(!logfilename) {
532                                 xasprintf(&logfilename, "%s/tinc.log", confbase);
533                         }
534                 }
535
536                 RegCloseKey(key);
537
538                 if(*installdir) {
539                         return;
540                 }
541         }
542
543 #endif
544
545         if(!pidfilename) {
546                 xasprintf(&pidfilename, RUNSTATEDIR "/%s.pid", identname);
547         }
548
549         if(!logfilename) {
550                 xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname);
551         }
552
553         if(netname) {
554                 if(!confbase) {
555                         xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
556                 } else {
557                         logger(LOG_INFO, "Both netname and configuration directory given, using the latter...");
558                 }
559         } else {
560                 if(!confbase) {
561                         xasprintf(&confbase, CONFDIR "/tinc");
562                 }
563         }
564 }
565
566 static void free_names() {
567         free(identname);
568         free(netname);
569         free(pidfilename);
570         free(logfilename);
571         free(confbase);
572 }
573
574 static bool drop_privs() {
575 #ifdef HAVE_MINGW
576
577         if(switchuser) {
578                 logger(LOG_ERR, "%s not supported on this platform", "-U");
579                 return false;
580         }
581
582         if(do_chroot) {
583                 logger(LOG_ERR, "%s not supported on this platform", "-R");
584                 return false;
585         }
586
587 #else
588         uid_t uid = 0;
589
590         if(switchuser) {
591                 struct passwd *pw = getpwnam(switchuser);
592
593                 if(!pw) {
594                         logger(LOG_ERR, "unknown user `%s'", switchuser);
595                         return false;
596                 }
597
598                 uid = pw->pw_uid;
599
600                 if(initgroups(switchuser, pw->pw_gid) != 0 ||
601                                 setgid(pw->pw_gid) != 0) {
602                         logger(LOG_ERR, "System call `%s' failed: %s",
603                                "initgroups", strerror(errno));
604                         return false;
605                 }
606
607 #ifndef ANDROID
608 // Not supported in android NDK
609                 endgrent();
610                 endpwent();
611 #endif
612         }
613
614         if(do_chroot) {
615                 tzset();        /* for proper timestamps in logs */
616
617                 if(chroot(confbase) != 0 || chdir("/") != 0) {
618                         logger(LOG_ERR, "System call `%s' failed: %s",
619                                "chroot", strerror(errno));
620                         return false;
621                 }
622
623                 free(confbase);
624                 confbase = xstrdup("");
625         }
626
627         if(switchuser)
628                 if(setuid(uid) != 0) {
629                         logger(LOG_ERR, "System call `%s' failed: %s",
630                                "setuid", strerror(errno));
631                         return false;
632                 }
633
634 #endif
635         return true;
636 }
637
638 #ifdef HAVE_MINGW
639 # define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level))
640 #else
641 # define NORMAL_PRIORITY_CLASS 0
642 # define BELOW_NORMAL_PRIORITY_CLASS 10
643 # define HIGH_PRIORITY_CLASS -10
644 # define setpriority(level) (setpriority(PRIO_PROCESS, 0, (level)))
645 #endif
646
647 int main(int argc, char **argv) {
648         program_name = argv[0];
649
650         if(!parse_options(argc, argv)) {
651                 return 1;
652         }
653
654         if(show_version) {
655                 printf("%s version %s\n", PACKAGE, VERSION);
656                 printf("Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n"
657                        "See the AUTHORS file for a complete list.\n\n"
658                        "tinc comes with ABSOLUTELY NO WARRANTY.  This is free software,\n"
659                        "and you are welcome to redistribute it under certain conditions;\n"
660                        "see the file COPYING for details.\n");
661
662                 return 0;
663         }
664
665         if(show_help) {
666                 usage(false);
667                 return 0;
668         }
669
670         make_names();
671
672         if(kill_tincd) {
673                 return !kill_other(kill_tincd);
674         }
675
676         openlogger("tinc", use_logfile ? LOGMODE_FILE : LOGMODE_STDERR);
677
678         g_argv = argv;
679
680         if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) {
681                 do_detach = false;
682         }
683
684 #ifdef HAVE_UNSETENV
685         unsetenv("LISTEN_PID");
686 #endif
687
688         init_configuration(&config_tree);
689
690 #ifndef OPENSSL_NO_ENGINE
691         ENGINE_load_builtin_engines();
692         ENGINE_register_all_complete();
693 #endif
694
695         OpenSSL_add_all_algorithms();
696
697         if(generate_keys) {
698                 read_server_config();
699                 return !keygen(generate_keys);
700         }
701
702         if(!read_server_config()) {
703                 return 1;
704         }
705
706 #ifdef HAVE_LZO
707
708         if(lzo_init() != LZO_E_OK) {
709                 logger(LOG_ERR, "Error initializing LZO compressor!");
710                 return 1;
711         }
712
713 #endif
714
715 #ifdef HAVE_MINGW
716
717         if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) {
718                 logger(LOG_ERR, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError()));
719                 return 1;
720         }
721
722         if(!do_detach || !init_service()) {
723                 return main2(argc, argv);
724         } else {
725                 return 1;
726         }
727 }
728
729 int main2(int argc, char **argv) {
730         InitializeCriticalSection(&mutex);
731         EnterCriticalSection(&mutex);
732 #endif
733         char *priority = NULL;
734
735         if(!detach()) {
736                 return 1;
737         }
738
739 #ifdef HAVE_MLOCKALL
740
741         /* Lock all pages into memory if requested.
742          * This has to be done after daemon()/fork() so it works for child.
743          * No need to do that in parent as it's very short-lived. */
744         if(do_mlock && mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
745                 logger(LOG_ERR, "System call `%s' failed: %s", "mlockall",
746                        strerror(errno));
747                 return 1;
748         }
749
750 #endif
751
752         /* Setup sockets and open device. */
753
754         if(!setup_network()) {
755                 goto end;
756         }
757
758         /* Initiate all outgoing connections. */
759
760         try_outgoing_connections();
761
762         /* Change process priority */
763
764         if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) {
765                 if(!strcasecmp(priority, "Normal")) {
766                         if(setpriority(NORMAL_PRIORITY_CLASS) != 0) {
767                                 logger(LOG_ERR, "System call `%s' failed: %s",
768                                        "setpriority", strerror(errno));
769                                 goto end;
770                         }
771                 } else if(!strcasecmp(priority, "Low")) {
772                         if(setpriority(BELOW_NORMAL_PRIORITY_CLASS) != 0) {
773                                 logger(LOG_ERR, "System call `%s' failed: %s",
774                                        "setpriority", strerror(errno));
775                                 goto end;
776                         }
777                 } else if(!strcasecmp(priority, "High")) {
778                         if(setpriority(HIGH_PRIORITY_CLASS) != 0) {
779                                 logger(LOG_ERR, "System call `%s' failed: %s",
780                                        "setpriority", strerror(errno));
781                                 goto end;
782                         }
783                 } else {
784                         logger(LOG_ERR, "Invalid priority `%s`!", priority);
785                         goto end;
786                 }
787         }
788
789         /* drop privileges */
790         if(!drop_privs()) {
791                 goto end;
792         }
793
794         /* Start main loop. It only exits when tinc is killed. */
795
796         status = main_loop();
797
798         /* Shutdown properly. */
799
800         ifdebug(CONNECTIONS)
801         devops.dump_stats();
802
803         close_network_connections();
804
805 end:
806         logger(LOG_NOTICE, "Terminating");
807
808 #ifndef HAVE_MINGW
809         remove_pid(pidfilename);
810 #endif
811
812         free(priority);
813
814         EVP_cleanup();
815         ERR_free_strings();
816 #ifndef OPENSSL_NO_ENGINE
817         ENGINE_cleanup();
818 #endif
819
820         exit_configuration(&config_tree);
821         list_delete_list(cmdline_conf);
822         free_names();
823
824         return status;
825 }