Windows: Move cache specific code out of mit_glue.c
Move code for checking backwards compatible configuration file location into cache.c. Also use registry handling code from config_reg.c.
This commit is contained in:
@@ -515,7 +515,7 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
|
||||
|
||||
#ifdef _WIN32
|
||||
if (e == NULL) {
|
||||
p = e = _krb5_get_default_mit_cc_name();
|
||||
e = p = _krb5_get_default_cc_name_from_registry();
|
||||
}
|
||||
#endif
|
||||
if (e == NULL) {
|
||||
@@ -1698,3 +1698,30 @@ krb5_cc_get_kdc_offset(krb5_context context, krb5_ccache id, krb5_deltat *offset
|
||||
}
|
||||
return (*id->ops->get_kdc_offset)(context, id, offset);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
char *
|
||||
_krb5_get_default_cc_name_from_registry()
|
||||
{
|
||||
HKEY hk_k5 = 0;
|
||||
LONG code;
|
||||
char * ccname = NULL;
|
||||
|
||||
code = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
"Software\\MIT\\Kerberos5",
|
||||
0, KEY_READ, &hk_k5);
|
||||
|
||||
if (code != ERROR_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
ccname = _krb5_parse_reg_value_as_string(NULL, hk_k5, "ccname",
|
||||
REG_NONE, 0);
|
||||
|
||||
RegCloseKey(hk_k5);
|
||||
|
||||
return ccname;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -431,68 +431,4 @@ krb5_free_default_realm(krb5_context context, krb5_realm realm)
|
||||
return krb5_xfree(realm);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
char *
|
||||
_krb5_get_default_mit_cc_name(void)
|
||||
{
|
||||
HKEY hk_k5 = 0;
|
||||
LONG code;
|
||||
DWORD type;
|
||||
DWORD cb = 0, alloc_cb = 0;
|
||||
LPBYTE buffer = NULL;
|
||||
|
||||
code = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
"Software\\MIT\\Kerberos5",
|
||||
0, KEY_READ, &hk_k5);
|
||||
|
||||
if (code != ERROR_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
do {
|
||||
code = RegQueryValueEx(hk_k5, "ccname", NULL,
|
||||
&type, buffer, &cb);
|
||||
|
||||
if (code != ERROR_SUCCESS && code != ERROR_MORE_DATA)
|
||||
break;
|
||||
|
||||
if (type != REG_SZ || cb == 0) {
|
||||
code = ERROR_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (buffer == NULL || code == ERROR_MORE_DATA ||
|
||||
cb >= alloc_cb) {
|
||||
LPBYTE new_buf;
|
||||
|
||||
alloc_cb = cb + sizeof(char);
|
||||
new_buf = realloc(buffer, alloc_cb);
|
||||
|
||||
if (new_buf == NULL) {
|
||||
code = ERROR_MORE_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
buffer = new_buf;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
} while (TRUE);
|
||||
|
||||
if (code == ERROR_SUCCESS) {
|
||||
if (buffer[cb / sizeof(char) - 1] != 0) {
|
||||
buffer[cb / sizeof(char)] = 0;
|
||||
}
|
||||
|
||||
return (char *) buffer;
|
||||
}
|
||||
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* HEIMDAL_SMALLER */
|
||||
|
Reference in New Issue
Block a user