From 7211ecc4121fb0e44719615a094a6ac3f03e42fd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 17 Sep 2026 16:46:51 +0200 Subject: gpgconf: Print more info from VERSION if found. * tools/gpgconf.c (show_version_gnupg): Print more info. --- tools/gpgconf.c | 69 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 48b3ea336..588cd8d58 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -1387,19 +1387,18 @@ w32_get_file_integrity_level (const char *path) static void show_version_gnupg (estream_t fp, const char *prefix) { - char *fname, *p, *p0; + char *fname, *p; size_t n; estream_t verfp; char *line = NULL; size_t line_len = 0; ssize_t length; + int in_build = 0; - p = gnupg_myproc_self (); - es_fprintf (fp, "%s%sGnuPG %s (%s)\n%s%s\n%s%s\n", prefix, *prefix?"":"* ", + es_fprintf (fp, "%s%sGnuPG %s (%s)\n%sOS: %s\n", + prefix, *prefix?"":"* ", gpgrt_strusage (13), BUILD_COMMITID, - prefix, gpgrt_strusage (17), - prefix, p); - xfree (p); + prefix, gpgrt_strusage (17)); /* Always show the GnuPG VS-Desktop version. */ if (prefix) @@ -1418,8 +1417,10 @@ show_version_gnupg (estream_t fp, const char *prefix) else { int lnr = 0; + char *p_version = NULL; + char *p_cidinst = NULL; + char *p_cidcfg = NULL; - p0 = NULL; while ((length = es_read_line (verfp, &line, &line_len, NULL))>0) { lnr++; @@ -1428,27 +1429,51 @@ show_version_gnupg (estream_t fp, const char *prefix) { /* Old file format where we look only at the * first line. */ - p0 = line; - break; - } - else if (!strncmp (line, "version=", 8)) - { - p0 = line + 8; + p_version = line; break; } + else if (!strncmp (line, "[Build]", 7)) + in_build = 1; + else if ( *line == '[') + in_build = 0; + else if (!p_version && !strncmp (line, "version=", 8)) + p_version = xstrdup (line + 8); + else if (in_build && !p_cidinst + && !strncmp (line, "cidInstaller=", 13)) + p_cidinst = xstrdup(line + 13); + else if (in_build && !p_cidcfg + && !strncmp (line, "cidConfig=", 10)) + p_cidcfg = xstrdup (line + 10); } if (length < 0 || es_ferror (verfp)) es_fprintf (fp, "%s[VERSION file read error]\n", prefix); - else if (p0) + else if (p_version) { - for (p=p0; *p; p++) - if (*p < ' ' || *p > '~' || *p == '[') - *p = '?'; - es_fprintf (fp, "%s%s\n", prefix, p0); + es_fprintf (fp, "%sPackage: ", prefix); + es_write_sanitized (fp, p_version, strlen (p_version), + "[]", NULL); + es_fputc ('\n', fp); + if (p_cidinst && *p_cidinst) + { + es_fprintf (fp, "%scidPkg: ", prefix); + es_write_sanitized (fp, p_cidinst, strlen (p_cidinst), + "[]", NULL); + es_fputc ('\n', fp); + } + if (p_cidcfg && *p_cidcfg) + { + es_fprintf (fp, "%scidCfg: ", prefix); + es_write_sanitized (fp, p_cidcfg, strlen (p_cidcfg), + "[]", NULL); + es_fputc ('\n', fp); + } } else es_fprintf (fp, "%s[VERSION file is empty]\n", prefix); + xfree (p_version); + xfree (p_cidinst); + xfree (p_cidcfg); es_fclose (verfp); } } @@ -1456,6 +1481,10 @@ show_version_gnupg (estream_t fp, const char *prefix) } xfree (line); + p = gnupg_myproc_self (); + es_fprintf (fp, "%sSelf: %s\n", prefix, p); + xfree (p); + #ifdef HAVE_W32_SYSTEM { OSVERSIONINFO osvi = { sizeof (osvi) }; @@ -2028,8 +2057,8 @@ show_configs (estream_t outfp) es_fprintf (outfp, "* General information\n"); es_fprintf (outfp, "** Versions\n"); show_version_gnupg (outfp, " "); - es_fprintf (outfp, " Libgcrypt %s\n", gcry_check_version (NULL)); - es_fprintf (outfp, " GpgRT %s\n", gpg_error_check_version (NULL)); + es_fprintf (outfp, " Libgcrypt: %s\n", gcry_check_version (NULL)); + es_fprintf (outfp, " GpgRT: %s\n", gpg_error_check_version (NULL)); es_fprintf (outfp, "\n\n"); es_fprintf (outfp, "** Directories\n"); -- cgit