diff options
author | Werner Koch <[email protected]> | 2022-08-03 07:26:44 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2022-08-03 07:26:44 +0000 |
commit | ebb736b2c310c8736d1165be9c8e2de413dd0ac6 (patch) | |
tree | c25e99a2eee3f8634525bf5b74b0db666238def2 | |
parent | gpg: Make symmetric + pubkey encryption de-vs compliant. (diff) | |
download | gnupg-ebb736b2c310c8736d1165be9c8e2de413dd0ac6.tar.gz gnupg-ebb736b2c310c8736d1165be9c8e2de413dd0ac6.zip |
gpgconf: Add config file for Windows Registry dumps.
* tools/gpgconf.c (show_registry_entries_from_file): New.
(show_configs): Call it.
* doc/examples/gpgconf.rnames: New.
* doc/Makefile.am (examples): Add it.
-rw-r--r-- | doc/Makefile.am | 3 | ||||
-rw-r--r-- | doc/examples/gpgconf.rnames | 12 | ||||
-rw-r--r-- | tools/gpgconf.c | 71 |
3 files changed, 85 insertions, 1 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index 8bb733374..aba09b9e4 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -24,6 +24,7 @@ include $(top_srcdir)/am/cmacros.am examples = examples/README examples/scd-event examples/trustlist.txt \ examples/VS-NfD.prf examples/Automatic.prf \ examples/debug.prf \ + examples/gpgconf.rnames examples/gpgconf.conf \ examples/systemd-user/README \ examples/systemd-user/dirmngr.service \ examples/systemd-user/dirmngr.socket \ @@ -32,7 +33,7 @@ examples = examples/README examples/scd-event examples/trustlist.txt \ examples/systemd-user/gpg-agent-ssh.socket \ examples/systemd-user/gpg-agent-browser.socket \ examples/systemd-user/gpg-agent-extra.socket \ - examples/gpgconf.conf examples/pwpattern.list + examples/pwpattern.list helpfiles = help.txt help.be.txt help.ca.txt help.cs.txt \ help.da.txt help.de.txt help.el.txt help.eo.txt \ diff --git a/doc/examples/gpgconf.rnames b/doc/examples/gpgconf.rnames new file mode 100644 index 000000000..0e837327f --- /dev/null +++ b/doc/examples/gpgconf.rnames @@ -0,0 +1,12 @@ +# gpgconf-rnames.lst +# Additional registry settings to be shown by "gpgconf -X". +# +# Example: HKCU\Software\GNU\GnuPG:FooBar +# +# HKCU := The class. Other supported classes are HKLM, HKCR, HKU, +# and HKCC. If no class is given and the string thus starts +# with a backslash HKCU with a fallback to HKLM is used. +# Software\GNU\GnuPG := The actual key. +# FooBar := The name of the item. if a name is not given the default +# value is used. +# diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 0fad39a4c..1b3f2beba 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -1393,8 +1393,78 @@ show_other_registry_entries (estream_t outfp) es_fprintf (outfp, "###\n"); xfree (namebuf); } + + +/* Print registry entries take from a configuration file. */ +static void +show_registry_entries_from_file (estream_t outfp) +{ + gpg_error_t err; + char *fname; + estream_t fp; + char *line = NULL; + size_t length_of_line = 0; + size_t maxlen; + ssize_t len; + char *value = NULL; + int from_hklm; + int any = 0; + + fname = make_filename (gnupg_datadir (), "gpgconf.rnames", NULL); + fp = es_fopen (fname, "r"); + if (!fp) + { + err = gpg_error_from_syserror (); + if (gpg_err_code (err) != GPG_ERR_ENOENT) + log_error ("error opening '%s': %s\n", fname, gpg_strerror (err)); + goto leave; + } + + maxlen = 2048; /* Set limit. */ + while ((len = es_read_line (fp, &line, &length_of_line, &maxlen)) > 0) + { + if (!maxlen) + { + err = gpg_error (GPG_ERR_LINE_TOO_LONG); + log_error ("error reading '%s': %s\n", fname, gpg_strerror (err)); + goto leave; + } + trim_spaces (line); + if (*line == '#') + continue; + + xfree (value); + value = read_w32_reg_string (line, &from_hklm); + if (!value) + continue; + + if (!any) + { + any = 1; + es_fprintf (outfp, "### Taken from gpgconf.rnames:\n"); + } + + es_fprintf (outfp, "### %s\n### ->%s<-%s\n", line, value, + from_hklm? " [hklm]":""); + + } + if (len < 0 || es_ferror (fp)) + { + err = gpg_error_from_syserror (); + log_error ("error reading '%s': %s\n", fname, gpg_strerror (err)); + } + + leave: + if (any) + es_fprintf (outfp, "###\n"); + xfree (value); + xfree (line); + es_fclose (fp); + xfree (fname); +} #endif /*HAVE_W32_SYSTEM*/ + /* Show all config files. */ static void show_configs (estream_t outfp) @@ -1492,6 +1562,7 @@ show_configs (estream_t outfp) if (!any) es_fprintf (outfp, "###\n"); show_other_registry_entries (outfp); + show_registry_entries_from_file (outfp); #endif /*HAVE_W32_SYSTEM*/ free_strlist (list); |