base: differentiate KRB5 and other configurations on Windows

When the "KRB5_CONFIG" is unset on Windows, the registry values
  HKLM\Software\Heimdal "config"
  HKCU\Software\Heimdal "config"
are used.   The migration of krb5_config to heimbase failed to
differentiate between KRB5_CONFIG, HX509_CONFIG, etc.   The above
registry values are only for the KRB5_CONFIG.

This change permits the envvar name to be searched for in the
registry.   For HX509_CONFIG the registry values
  HKLM\Software\Heimdal "HX509_CONFIG"
  HKCU\Software\Heimdal "HX509_CONFIG"
will be searched for configuration information.

Change-Id: I140945fa603d668d270eb5d740a11edc6fc121d7
This commit is contained in:
Jeffrey Altman
2020-06-28 10:32:38 -04:00
committed by Jeffrey Altman
parent 2a0b0c0237
commit ed24c41973

View File

@@ -209,16 +209,22 @@ add_file(char ***pfilenames, int *len, char *file)
#ifdef WIN32
static char *
get_default_config_config_files_from_registry(void)
get_default_config_config_files_from_registry(const char *envvar)
{
static const char *KeyName = "Software\\Heimdal"; /* XXX #define this */
const char *ValueName;
char *config_file = NULL;
LONG rcode;
HKEY key;
if (stricmp(envvar, "KRB5_CONFIG") == 0)
ValueName = "config";
else
ValueName = envvar;
rcode = RegOpenKeyEx(HKEY_CURRENT_USER, KeyName, 0, KEY_READ, &key);
if (rcode == ERROR_SUCCESS) {
config_file = heim_parse_reg_value_as_multi_string(NULL, key, "config",
config_file = heim_parse_reg_value_as_multi_string(NULL, key, ValueName,
REG_NONE, 0, PATH_SEP);
RegCloseKey(key);
}
@@ -228,7 +234,7 @@ get_default_config_config_files_from_registry(void)
rcode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, KEY_READ, &key);
if (rcode == ERROR_SUCCESS) {
config_file = heim_parse_reg_value_as_multi_string(NULL, key, "config",
config_file = heim_parse_reg_value_as_multi_string(NULL, key, ValueName,
REG_NONE, 0, PATH_SEP);
RegCloseKey(key);
}
@@ -326,7 +332,7 @@ heim_get_default_config_files(const char *def,
#ifdef _WIN32
if (files == NULL) {
char * reg_files;
reg_files = get_default_config_config_files_from_registry();
reg_files = get_default_config_config_files_from_registry(envvar);
if (reg_files != NULL) {
heim_error_code code;