chiark / gitweb /
agent: Allow threads to interrupt main select loop with SIGCONT.
[gnupg2.git] / tools / gpgconf.c
1 /* gpgconf.c - Configuration utility for GnuPG
2  * Copyright (C) 2003, 2007, 2009, 2011 Free Software Foundation, Inc.
3  * Copyright (C) 2016 g10 Code GmbH.
4  *
5  * This file is part of GnuPG.
6  *
7  * GnuPG is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * GnuPG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <https://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22 #include <errno.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
27
28 #include "gpgconf.h"
29 #include "i18n.h"
30 #include "sysutils.h"
31 #include "../common/init.h"
32
33
34 /* Constants to identify the commands and options. */
35 enum cmd_and_opt_values
36   {
37     aNull = 0,
38     oDryRun     = 'n',
39     oOutput     = 'o',
40     oQuiet      = 'q',
41     oVerbose    = 'v',
42     oRuntime    = 'r',
43     oComponent  = 'c',
44     oNull       = '0',
45     oNoVerbose  = 500,
46     oHomedir,
47     oBuilddir,
48
49     aListComponents,
50     aCheckPrograms,
51     aListOptions,
52     aChangeOptions,
53     aCheckOptions,
54     aApplyDefaults,
55     aListConfig,
56     aCheckConfig,
57     aQuerySWDB,
58     aListDirs,
59     aLaunch,
60     aKill,
61     aCreateSocketDir,
62     aRemoveSocketDir,
63     aApplyProfile,
64     aReload
65   };
66
67
68 /* The list of commands and options. */
69 static ARGPARSE_OPTS opts[] =
70   {
71     { 300, NULL, 0, N_("@Commands:\n ") },
72
73     { aListComponents, "list-components", 256, N_("list all components") },
74     { aCheckPrograms, "check-programs", 256, N_("check all programs") },
75     { aListOptions, "list-options", 256, N_("|COMPONENT|list options") },
76     { aChangeOptions, "change-options", 256, N_("|COMPONENT|change options") },
77     { aCheckOptions, "check-options", 256, N_("|COMPONENT|check options") },
78     { aApplyDefaults, "apply-defaults", 256,
79       N_("apply global default values") },
80     { aApplyProfile, "apply-profile", 256,
81       N_("|FILE|update configuration files using FILE") },
82     { aListDirs, "list-dirs", 256,
83       N_("get the configuration directories for @GPGCONF@") },
84     { aListConfig,   "list-config", 256,
85       N_("list global configuration file") },
86     { aCheckConfig,   "check-config", 256,
87       N_("check global configuration file") },
88     { aQuerySWDB,     "query-swdb", 256,
89       N_("query the software version database") },
90     { aReload,        "reload", 256, N_("reload all or a given component")},
91     { aLaunch,        "launch", 256, N_("launch a given component")},
92     { aKill,          "kill", 256,   N_("kill a given component")},
93     { aCreateSocketDir, "create-socketdir", 256, "@"},
94     { aRemoveSocketDir, "remove-socketdir", 256, "@"},
95
96     { 301, NULL, 0, N_("@\nOptions:\n ") },
97
98     { oOutput, "output",    2, N_("use as output file") },
99     { oVerbose, "verbose",  0, N_("verbose") },
100     { oQuiet, "quiet",      0, N_("quiet") },
101     { oDryRun, "dry-run",   0, N_("do not make any changes") },
102     { oRuntime, "runtime",  0, N_("activate changes at runtime, if possible") },
103     /* hidden options */
104     { oHomedir, "homedir", 2, "@" },
105     { oBuilddir, "build-prefix", 2, "@" },
106     { oNull, "null", 0, "@" },
107     { oNoVerbose, "no-verbose",  0, "@"},
108     {0}
109   };
110
111
112 /* Print usage information and and provide strings for help. */
113 static const char *
114 my_strusage( int level )
115 {
116   const char *p;
117
118   switch (level)
119     {
120     case 11: p = "@GPGCONF@ (@GNUPG@)";
121       break;
122     case 13: p = VERSION; break;
123     case 17: p = PRINTABLE_OS_NAME; break;
124     case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break;
125
126     case 1:
127     case 40: p = _("Usage: @GPGCONF@ [options] (-h for help)");
128       break;
129     case 41:
130       p = _("Syntax: @GPGCONF@ [options]\n"
131             "Manage configuration options for tools of the @GNUPG@ system\n");
132       break;
133
134     default: p = NULL; break;
135     }
136   return p;
137 }
138
139
140 /* Return the fp for the output.  This is usually stdout unless
141    --output has been used.  In the latter case this function opens
142    that file.  */
143 static estream_t
144 get_outfp (estream_t *fp)
145 {
146   if (!*fp)
147     {
148       if (opt.outfile)
149         {
150           *fp = es_fopen (opt.outfile, "w");
151           if (!*fp)
152             gc_error (1, errno, "can not open '%s'", opt.outfile);
153         }
154       else
155         *fp = es_stdout;
156     }
157   return *fp;
158 }
159
160
161 static void
162 list_dirs (estream_t fp, char **names)
163 {
164   static struct {
165     const char *name;
166     const char *(*fnc)(void);
167     const char *extra;
168   } list[] = {
169     { "sysconfdir",         gnupg_sysconfdir, NULL },
170     { "bindir",             gnupg_bindir,     NULL },
171     { "libexecdir",         gnupg_libexecdir, NULL },
172     { "libdir",             gnupg_libdir,     NULL },
173     { "datadir",            gnupg_datadir,    NULL },
174     { "localedir",          gnupg_localedir,  NULL },
175     { "socketdir",          gnupg_socketdir,  NULL },
176     { "dirmngr-socket",     dirmngr_socket_name, NULL,},
177     { "agent-ssh-socket",   gnupg_socketdir,  GPG_AGENT_SSH_SOCK_NAME },
178     { "agent-extra-socket", gnupg_socketdir,  GPG_AGENT_EXTRA_SOCK_NAME },
179     { "agent-browser-socket",gnupg_socketdir, GPG_AGENT_BROWSER_SOCK_NAME },
180     { "agent-socket",       gnupg_socketdir,  GPG_AGENT_SOCK_NAME },
181     { "homedir",            gnupg_homedir,    NULL }
182   };
183   int idx, j;
184   char *tmp;
185   const char *s;
186
187
188   for (idx = 0; idx < DIM (list); idx++)
189     {
190       s = list[idx].fnc ();
191       if (list[idx].extra)
192         {
193           tmp = make_filename (s, list[idx].extra, NULL);
194           s = tmp;
195         }
196       else
197         tmp = NULL;
198       if (!names)
199         es_fprintf (fp, "%s:%s\n", list[idx].name, gc_percent_escape (s));
200       else
201         {
202           for (j=0; names[j]; j++)
203             if (!strcmp (names[j], list[idx].name))
204               {
205                 es_fputs (s, fp);
206                 es_putc (opt.null? '\0':'\n', fp);
207               }
208         }
209
210       xfree (tmp);
211     }
212 }
213
214
215
216 /* Check whether NAME is valid argument for query_swdb().  Valid names
217  * start with a letter and contain only alphanumeric characters or an
218  * underscore.  */
219 static int
220 valid_swdb_name_p (const char *name)
221 {
222   if (!name || !*name || !alphap (name))
223     return 0;
224
225   for (name++; *name; name++)
226     if (!alnump (name) && *name != '_')
227       return 0;
228
229   return 1;
230 }
231
232
233 /* Query the SWDB file.  If necessary and possible this functions asks
234  * the dirmngr to load an updated version of that file.  The caller
235  * needs to provide the NAME to query (e.g. "gnupg", "libgcrypt") and
236  * optional the currently installed version in CURRENT_VERSION.  The
237  * output written to OUT is a colon delimited line with these fields:
238  *
239  * name   :: The name of the package
240  * curvers:: The installed version if given.
241  * status :: This value tells the status of the software package
242  *           '-' :: No information available
243  *                  (error or CURRENT_VERSION not given)
244  *           '?' :: Unknown NAME
245  *           'u' :: Update available
246  *           'c' :: The version is Current
247  *           'n' :: The current version is already Newer than the
248  *                  available one.
249  * urgency :: If the value is greater than zero an urgent update is required.
250  * error   :: 0 on success or an gpg_err_code_t
251  *            Common codes seen:
252  *            GPG_ERR_TOO_OLD :: The SWDB file is to old to be used.
253  *            GPG_ERR_ENOENT  :: The SWDB file is not available.
254  *            GPG_ERR_BAD_SIGNATURE :: Currupted SWDB file.
255  * filedate:: Date of the swdb file (yyyymmddThhmmss)
256  * verified:: Date we checked the validity of the file (yyyyymmddThhmmss)
257  * version :: The version string from the swdb.
258  * reldate :: Release date of that version (yyyymmddThhmmss)
259  * size    :: Size of the package in bytes.
260  * hash    :: SHA-2 hash of the package.
261  *
262  */
263 static void
264 query_swdb (estream_t out, const char *name, const char *current_version)
265 {
266   gpg_error_t err;
267   const char *search_name;
268   char *fname = NULL;
269   estream_t fp = NULL;
270   char *line = NULL;
271   char *self_version = NULL;
272   size_t length_of_line = 0;
273   size_t  maxlen;
274   ssize_t len;
275   char *fields[2];
276   char *p;
277   gnupg_isotime_t filedate = {0};
278   gnupg_isotime_t verified = {0};
279   char *value_ver = NULL;
280   gnupg_isotime_t value_date = {0};
281   char *value_size = NULL;
282   char *value_sha2 = NULL;
283   unsigned long value_size_ul;
284   int status, i;
285
286
287   if (!valid_swdb_name_p (name))
288     {
289       log_error ("error in package name '%s': %s\n",
290                  name, gpg_strerror (GPG_ERR_INV_NAME));
291       goto leave;
292     }
293   if (!strcmp (name, "gnupg"))
294     search_name = "gnupg21";
295   else if (!strcmp (name, "gnupg1"))
296     search_name = "gnupg1";
297   else
298     search_name = name;
299
300   if (!current_version && !strcmp (name, "gnupg"))
301     {
302       /* Use our own version but string a possible beta string.  */
303       self_version = xstrdup (PACKAGE_VERSION);
304       p = strchr (self_version, '-');
305       if (p)
306         *p = 0;
307       current_version = self_version;
308     }
309
310   if (current_version && (strchr (current_version, ':')
311                           || compare_version_strings (current_version, NULL)))
312     {
313       log_error ("error in version string '%s': %s\n",
314                  current_version, gpg_strerror (GPG_ERR_INV_ARG));
315       goto leave;
316     }
317
318   fname = make_filename (gnupg_homedir (), "swdb.lst", NULL);
319   fp = es_fopen (fname, "r");
320   if (!fp)
321     {
322       err = gpg_error_from_syserror ();
323       es_fprintf (out, "%s:%s:-::%u:::::::\n",
324                   name,
325                   current_version? current_version : "",
326                   gpg_err_code (err));
327       if (gpg_err_code (err) != GPG_ERR_ENOENT)
328         log_error (_("error opening '%s': %s\n"), fname, gpg_strerror (err));
329       goto leave;
330     }
331
332   /* Note that the parser uses the first occurance of a matching
333    * values and ignores possible duplicated values.  */
334
335   maxlen = 2048; /* Set limit.  */
336   while ((len = es_read_line (fp, &line, &length_of_line, &maxlen)) > 0)
337     {
338       if (!maxlen)
339         {
340           err = gpg_error (GPG_ERR_LINE_TOO_LONG);
341           log_error (_("error reading '%s': %s\n"), fname, gpg_strerror (err));
342           goto leave;
343         }
344       /* Strip newline and carriage return, if present.  */
345       while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
346         line[--len] = '\0';
347
348       if (split_fields (line, fields, DIM (fields)) < DIM(fields))
349         continue; /* Skip empty lines and names w/o a value.  */
350       if (*fields[0] == '#')
351         continue; /* Skip comments.  */
352
353       /* Record the meta data.  */
354       if (!*filedate && !strcmp (fields[0], ".filedate"))
355         {
356           string2isotime (filedate, fields[1]);
357           continue;
358         }
359       if (!*verified && !strcmp (fields[0], ".verified"))
360         {
361           string2isotime (verified, fields[1]);
362           continue;
363         }
364
365       /* Tokenize the name.  */
366       p = strrchr (fields[0], '_');
367       if (!p)
368         continue; /* Name w/o an underscore.  */
369       *p++ = 0;
370
371       /* Wait for the requested name.  */
372       if (!strcmp (fields[0], search_name))
373         {
374           if (!strcmp (p, "ver") && !value_ver)
375             value_ver = xstrdup (fields[1]);
376           else if (!strcmp (p, "date") && !*value_date)
377             string2isotime (value_date, fields[1]);
378           else if (!strcmp (p, "size") && !value_size)
379             value_size = xstrdup (fields[1]);
380           else if (!strcmp (p, "sha2") && !value_sha2)
381             value_sha2 = xstrdup (fields[1]);
382         }
383     }
384   if (len < 0 || es_ferror (fp))
385     {
386       err = gpg_error_from_syserror ();
387       log_error (_("error reading '%s': %s\n"), fname, gpg_strerror (err));
388       goto leave;
389     }
390
391   if (!*filedate || !*verified)
392     {
393       err = gpg_error (GPG_ERR_INV_TIME);
394       es_fprintf (out, "%s:%s:-::%u:::::::\n",
395                   name,
396                   current_version? current_version : "",
397                   gpg_err_code (err));
398       goto leave;
399     }
400
401   if (!value_ver)
402     {
403       es_fprintf (out, "%s:%s:?:::::::::\n",
404                   name,
405                   current_version? current_version : "");
406       goto leave;
407     }
408
409   if (value_size)
410     {
411       gpg_err_set_errno (0);
412       value_size_ul = strtoul (value_size, &p, 10);
413       if (errno)
414         value_size_ul = 0;
415       else if (*p == 'k')
416         value_size_ul *= 1024;
417     }
418
419   err = 0;
420   status = '-';
421   if (compare_version_strings (value_ver, NULL))
422     err = gpg_error (GPG_ERR_INV_VALUE);
423   else if (!current_version)
424     ;
425   else if (!(i = compare_version_strings (value_ver, current_version)))
426     status = 'c';
427   else if (i > 0)
428     status = 'u';
429   else
430     status = 'n';
431
432   es_fprintf (out, "%s:%s:%c::%d:%s:%s:%s:%s:%lu:%s:\n",
433               name,
434               current_version? current_version : "",
435               status,
436               err,
437               filedate,
438               verified,
439               value_ver,
440               value_date,
441               value_size_ul,
442               value_sha2? value_sha2 : "");
443
444  leave:
445   xfree (value_ver);
446   xfree (value_size);
447   xfree (value_sha2);
448   xfree (line);
449   es_fclose (fp);
450   xfree (fname);
451   xfree (self_version);
452 }
453
454
455 /* gpgconf main. */
456 int
457 main (int argc, char **argv)
458 {
459   ARGPARSE_ARGS pargs;
460   const char *fname;
461   int no_more_options = 0;
462   enum cmd_and_opt_values cmd = 0;
463   estream_t outfp = NULL;
464
465   early_system_init ();
466   gnupg_reopen_std (GPGCONF_NAME);
467   set_strusage (my_strusage);
468   log_set_prefix (GPGCONF_NAME, GPGRT_LOG_WITH_PREFIX);
469
470   /* Make sure that our subsystems are ready.  */
471   i18n_init();
472   init_common_subsystems (&argc, &argv);
473
474   /* Parse the command line. */
475   pargs.argc  = &argc;
476   pargs.argv  = &argv;
477   pargs.flags =  1;  /* Do not remove the args.  */
478   while (!no_more_options && optfile_parse (NULL, NULL, NULL, &pargs, opts))
479     {
480       switch (pargs.r_opt)
481         {
482         case oOutput:    opt.outfile = pargs.r.ret_str; break;
483         case oQuiet:     opt.quiet = 1; break;
484         case oDryRun:    opt.dry_run = 1; break;
485         case oRuntime:
486           opt.runtime = 1;
487           break;
488         case oVerbose:   opt.verbose++; break;
489         case oNoVerbose: opt.verbose = 0; break;
490         case oHomedir:   gnupg_set_homedir (pargs.r.ret_str); break;
491         case oBuilddir:  gnupg_set_builddir (pargs.r.ret_str); break;
492         case oNull:      opt.null = 1; break;
493
494         case aListDirs:
495         case aListComponents:
496         case aCheckPrograms:
497         case aListOptions:
498         case aChangeOptions:
499         case aCheckOptions:
500         case aApplyDefaults:
501         case aApplyProfile:
502         case aListConfig:
503         case aCheckConfig:
504         case aQuerySWDB:
505         case aReload:
506         case aLaunch:
507         case aKill:
508         case aCreateSocketDir:
509         case aRemoveSocketDir:
510           cmd = pargs.r_opt;
511           break;
512
513         default: pargs.err = 2; break;
514         }
515     }
516
517   if (log_get_errorcount (0))
518     exit (2);
519
520   /* Print a warning if an argument looks like an option.  */
521   if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
522     {
523       int i;
524
525       for (i=0; i < argc; i++)
526         if (argv[i][0] == '-' && argv[i][1] == '-')
527           log_info (_("Note: '%s' is not considered an option\n"), argv[i]);
528     }
529
530   fname = argc ? *argv : NULL;
531
532   switch (cmd)
533     {
534     case aListComponents:
535     default:
536       /* List all components. */
537       gc_component_list_components (get_outfp (&outfp));
538       break;
539
540     case aCheckPrograms:
541       /* Check all programs. */
542       gc_check_programs (get_outfp (&outfp));
543       break;
544
545     case aListOptions:
546     case aChangeOptions:
547     case aCheckOptions:
548       if (!fname)
549         {
550           es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
551           es_putc ('\n', es_stderr);
552           es_fputs (_("Need one component argument"), es_stderr);
553           es_putc ('\n', es_stderr);
554           exit (2);
555         }
556       else
557         {
558           int idx = gc_component_find (fname);
559           if (idx < 0)
560             {
561               es_fputs (_("Component not found"), es_stderr);
562               es_putc ('\n', es_stderr);
563               exit (1);
564             }
565           if (cmd == aCheckOptions)
566             gc_component_check_options (idx, get_outfp (&outfp), NULL);
567           else
568             {
569               gc_component_retrieve_options (idx);
570               if (gc_process_gpgconf_conf (NULL, 1, 0, NULL))
571                 exit (1);
572               if (cmd == aListOptions)
573                 gc_component_list_options (idx, get_outfp (&outfp));
574               else if (cmd == aChangeOptions)
575                 gc_component_change_options (idx, es_stdin,
576                                              get_outfp (&outfp), 0);
577             }
578         }
579       break;
580
581     case aLaunch:
582     case aKill:
583       if (!fname)
584         {
585           es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
586           es_putc ('\n', es_stderr);
587           es_fputs (_("Need one component argument"), es_stderr);
588           es_putc ('\n', es_stderr);
589           exit (2);
590         }
591       else
592         {
593           /* Launch/Kill a given component.  */
594           int idx;
595
596           idx = gc_component_find (fname);
597           if (idx < 0)
598             {
599               es_fputs (_("Component not found"), es_stderr);
600               es_putc ('\n', es_stderr);
601               exit (1);
602             }
603           else if (cmd == aLaunch)
604             {
605               if (gc_component_launch (idx))
606                 exit (1);
607             }
608           else
609             {
610               /* We don't error out if the kill failed because this
611                  command should do nothing if the component is not
612                  running.  */
613               gc_component_kill (idx);
614             }
615         }
616       break;
617
618     case aReload:
619       if (!fname)
620         {
621           /* Reload all.  */
622           gc_component_reload (-1);
623         }
624       else
625         {
626           /* Reload given component.  */
627           int idx;
628
629           idx = gc_component_find (fname);
630           if (idx < 0)
631             {
632               es_fputs (_("Component not found"), es_stderr);
633               es_putc ('\n', es_stderr);
634               exit (1);
635             }
636           else
637             {
638               gc_component_reload (idx);
639             }
640         }
641       break;
642
643     case aListConfig:
644       if (gc_process_gpgconf_conf (fname, 0, 0, get_outfp (&outfp)))
645         exit (1);
646       break;
647
648     case aCheckConfig:
649       if (gc_process_gpgconf_conf (fname, 0, 0, NULL))
650         exit (1);
651       break;
652
653     case aApplyDefaults:
654       if (fname)
655         {
656           es_fprintf (es_stderr, _("usage: %s [options] "), GPGCONF_NAME);
657           es_putc ('\n', es_stderr);
658           es_fputs (_("No argument allowed"), es_stderr);
659           es_putc ('\n', es_stderr);
660           exit (2);
661         }
662       gc_component_retrieve_options (-1);
663       if (gc_process_gpgconf_conf (NULL, 1, 1, NULL))
664         exit (1);
665       break;
666
667     case aApplyProfile:
668       gc_component_retrieve_options (-1);
669       if (gc_apply_profile (fname))
670         exit (1);
671       break;
672
673     case aListDirs:
674       /* Show the system configuration directories for gpgconf.  */
675       get_outfp (&outfp);
676       list_dirs (outfp, argc? argv : NULL);
677       break;
678
679     case aQuerySWDB:
680       /* Query the software version database.  */
681       if (!fname || argc > 2)
682         {
683           es_fprintf (es_stderr, "usage: %s --query-swdb NAME [VERSION]\n",
684                       GPGCONF_NAME);
685           exit (2);
686         }
687       get_outfp (&outfp);
688       query_swdb (outfp, fname, argc > 1? argv[1] : NULL);
689       break;
690
691     case aCreateSocketDir:
692       {
693         char *socketdir;
694         unsigned int flags;
695
696         /* Make sure that the top /run/user/UID/gnupg dir has been
697          * created.  */
698         gnupg_socketdir ();
699
700         /* Check the /var/run dir.  */
701         socketdir = _gnupg_socketdir_internal (1, &flags);
702         if ((flags & 64) && !opt.dry_run)
703           {
704             /* No sub dir - create it. */
705             if (gnupg_mkdir (socketdir, "-rwx"))
706               gc_error (1, errno, "error creating '%s'", socketdir);
707             /* Try again.  */
708             xfree (socketdir);
709             socketdir = _gnupg_socketdir_internal (1, &flags);
710           }
711
712         /* Give some info.  */
713         if ( (flags & ~32) || opt.verbose || opt.dry_run)
714           {
715             log_info ("socketdir is '%s'\n", socketdir);
716             if ((flags &   1)) log_info ("\tgeneral error\n");
717             if ((flags &   2)) log_info ("\tno /run/user dir\n");
718             if ((flags &   4)) log_info ("\tbad permissions\n");
719             if ((flags &   8)) log_info ("\tbad permissions (subdir)\n");
720             if ((flags &  16)) log_info ("\tmkdir failed\n");
721             if ((flags &  32)) log_info ("\tnon-default homedir\n");
722             if ((flags &  64)) log_info ("\tno such subdir\n");
723             if ((flags & 128)) log_info ("\tusing homedir as fallback\n");
724           }
725
726         if ((flags & ~32) && !opt.dry_run)
727           gc_error (1, 0, "error creating socket directory");
728
729         xfree (socketdir);
730       }
731       break;
732
733     case aRemoveSocketDir:
734       {
735         char *socketdir;
736         unsigned int flags;
737
738         /* Check the /var/run dir.  */
739         socketdir = _gnupg_socketdir_internal (1, &flags);
740         if ((flags & 128))
741           log_info ("ignoring request to remove non /run/user socket dir\n");
742         else if (opt.dry_run)
743           ;
744         else if (rmdir (socketdir))
745           gc_error (1, errno, "error removing '%s'", socketdir);
746
747         xfree (socketdir);
748       }
749       break;
750
751     }
752
753   if (outfp != es_stdout)
754     if (es_fclose (outfp))
755       gc_error (1, errno, "error closing '%s'", opt.outfile);
756
757   return 0;
758 }