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