gpgconf: Before --launch check that the config file is fine.
authorWerner Koch <wk@gnupg.org>
Thu, 16 May 2019 10:24:08 +0000 (12:24 +0200)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Thu, 22 Aug 2019 19:11:59 +0000 (20:11 +0100)
* tools/gpgconf-comp.c (gc_component_launch): Check the conf file.
* tools/gpgconf.c (gpgconf_failure): Call log_flush.
--
GnuPG-bug-id: 4497
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 3a28706cfd960ff84dda9a22aa2f160b4c2efbb5)

Gbp-Pq: Topic from-2.2.16
Gbp-Pq: Name gpgconf-Before-launch-check-that-the-config-file-is-fine.patch

tools/gpgconf-comp.c
tools/gpgconf.c

index adecfdee3e459c36d9b645aacd9dffd35fc2d1df..7f7440b8ad42fdc4864c427adba7fe2e67c763d9 100644 (file)
@@ -1297,8 +1297,17 @@ gc_component_launch (int component)
   if (!(component == GC_COMPONENT_GPG_AGENT
         || component == GC_COMPONENT_DIRMNGR))
     {
-      es_fputs (_("Component not suitable for launching"), es_stderr);
-      es_putc ('\n', es_stderr);
+      log_error ("%s\n", _("Component not suitable for launching"));
+      gpgconf_failure (0);
+    }
+
+  if (gc_component_check_options (component, NULL, NULL))
+    {
+      log_error (_("Configuration file of component %s is broken\n"),
+                 gc_component[component].name);
+      if (!opt.quiet)
+        log_info (_("Note: Use the command \"%s%s\" to get details.\n"),
+                  "gpgconf --check-options ", gc_component[component].name);
       gpgconf_failure (0);
     }
 
@@ -1709,8 +1718,9 @@ collect_error_output (estream_t fp, const char *tag)
 }
 
 
-/* Check the options of a single component.  Returns 0 if everything
-   is OK.  */
+/* Check the options of a single component.  If CONF_FILE is NULL the
+ * standard config file is used.  If OUT is not NULL the output is
+ * written to that stream.  Returns 0 if everything is OK.  */
 int
 gc_component_check_options (int component, estream_t out, const char *conf_file)
 {
index 59085d8b5b44c59ca18d3fc7fb789ccd12c62253..bca6efbf79a3907b5033bf6c15bc1d59819cbba2 100644 (file)
@@ -881,6 +881,7 @@ main (int argc, char **argv)
 void
 gpgconf_failure (gpg_error_t err)
 {
+  log_flush ();
   if (!err)
     err = gpg_error (GPG_ERR_GENERAL);
   gpgconf_write_status