gss: merge gss_name_to_oid and gss_mg_name_to_oid
The recently introduced gss_mg_name_to_oid() function supported looking up dynamically loaded mechanisms by name, but did not support partial matches or the legacy "Kerberos 5" name as supported by gss_name_to_oid(). Consolidate these into a single function, and also add support for dynamically loaded mechanisms to gss_oid_to_name(). API behavior difference: the Kerberos mechanism is now referred to by "krb5" rather tha "Kerberos 5", although for legacy compatibility gss_name_to_oid() will recognize the old name. However, gss_oid_to_name() will return "krb5". The anticipated impact is minimal as these are not standard GSS-APIs and do not appear to have any public usage outside Heimdal.
This commit is contained in:
@@ -65,34 +65,3 @@ gss_oid_to_str(OM_uint32 *minor_status, gss_OID oid, gss_buffer_t oid_str)
|
||||
*minor_status = 0;
|
||||
return GSS_S_COMPLETE;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION const char * GSSAPI_LIB_CALL
|
||||
gss_oid_to_name(gss_const_OID oid)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; _gss_ont_mech[i].oid; i++) {
|
||||
if (gss_oid_equal(oid, _gss_ont_mech[i].oid))
|
||||
return _gss_ont_mech[i].name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GSSAPI_LIB_FUNCTION gss_OID GSSAPI_LIB_CALL
|
||||
gss_name_to_oid(const char *name)
|
||||
{
|
||||
size_t i, partial = (size_t)-1;
|
||||
|
||||
for (i = 0; _gss_ont_mech[i].oid; i++) {
|
||||
if (strcasecmp(name, _gss_ont_mech[i].short_desc) == 0)
|
||||
return _gss_ont_mech[i].oid;
|
||||
if (strncasecmp(name, _gss_ont_mech[i].short_desc, strlen(name)) == 0) {
|
||||
if (partial != (size_t)-1)
|
||||
return NULL;
|
||||
partial = i;
|
||||
}
|
||||
}
|
||||
if (partial != (size_t)-1)
|
||||
return _gss_ont_mech[partial].oid;
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user