aboutsummaryrefslogtreecommitdiffstats
path: root/common/w32-reg.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2022-08-02 10:25:23 +0000
committerWerner Koch <[email protected]>2022-08-02 12:35:38 +0000
commitea7aba6e605d0469fc5c9cf38bafa7eb46e69c22 (patch)
tree6e7beffb96420905a51b478ed4d0b131cc4da654 /common/w32-reg.c
parenttests: Install links for tpm2daemon (diff)
downloadgnupg-ea7aba6e605d0469fc5c9cf38bafa7eb46e69c22.tar.gz
gnupg-ea7aba6e605d0469fc5c9cf38bafa7eb46e69c22.zip
gpgconf: Improve registry dumping.
* common/w32-reg.c (read_w32_reg_string): Add arg r_hklm_fallback and change all callers. (show_configs): Indicate whether the HKLM fallback was used. * tools/gpgconf.c (show_other_registry_entries): Fix the Outlook Addin Registry key. Indicate whether the HKLM fallback was used. -- Note that this is backport from 2.2. The new support there for REG_DWORD needs to be implemented in libgpg-error, though.
Diffstat (limited to 'common/w32-reg.c')
-rw-r--r--common/w32-reg.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/common/w32-reg.c b/common/w32-reg.c
index 94049a283..9af7d2d28 100644
--- a/common/w32-reg.c
+++ b/common/w32-reg.c
@@ -71,14 +71,19 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
*
* Note that the first backslash and the first colon act as delimiters.
*
- * Returns a malloced string or NULL if not found.
+ * Returns a malloced string or NULL if not found. If R_HKLM_FALLBACK
+ * is not NULL, no class was given, and the result came from HKLM,
+ * true is stored there.
*/
char *
-read_w32_reg_string (const char *key_arg)
+read_w32_reg_string (const char *key_arg, int *r_hklm_fallback)
{
char *key;
char *p1, *p2;
- char *result;
+ char *result, *result2;
+
+ if (r_hklm_fallback)
+ *r_hklm_fallback = 0;
if (!key_arg)
return NULL;
@@ -101,6 +106,15 @@ read_w32_reg_string (const char *key_arg)
*p2++ = 0;
result = gpgrt_w32_reg_query_string (*key? key : NULL, p1, p2);
+ if (result && !*key && r_hklm_fallback)
+ {
+ /* No key given - see whether the result came from HKCU or HKLM. */
+ result2 = gpgrt_w32_reg_query_string ("HKCU", p1, p2);
+ if (result2)
+ xfree (result2);
+ else
+ *r_hklm_fallback = 1;
+ }
xfree (key);
return result;
}