kdc: pass down the server hdb_entry_ex to check_constrained_delegation()
This way we can compare the already canonicalized principals, while still passing the client specified target principal down to the backend specific constrained_delegation() hook. metze Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
This commit is contained in:

committed by
Love Hörnquist Åstrand

parent
d6a56b847b
commit
6cb0e81760
@@ -505,18 +505,32 @@ check_constrained_delegation(krb5_context context,
|
|||||||
krb5_kdc_configuration *config,
|
krb5_kdc_configuration *config,
|
||||||
HDB *clientdb,
|
HDB *clientdb,
|
||||||
hdb_entry_ex *client,
|
hdb_entry_ex *client,
|
||||||
krb5_const_principal server)
|
hdb_entry_ex *server,
|
||||||
|
krb5_const_principal target)
|
||||||
{
|
{
|
||||||
const HDB_Ext_Constrained_delegation_acl *acl;
|
const HDB_Ext_Constrained_delegation_acl *acl;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constrained_delegation (S4U2Proxy) only works within
|
||||||
|
* the same realm. We use the already canonicalized version
|
||||||
|
* of the principals here, while "target" is the principal
|
||||||
|
* provided by the client.
|
||||||
|
*/
|
||||||
|
if(!krb5_realm_compare(context, client->entry.principal, server->entry.principal)) {
|
||||||
|
ret = KRB5KDC_ERR_BADOPTION;
|
||||||
|
kdc_log(context, config, 0,
|
||||||
|
"Bad request for constrained delegation");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* if client delegates to itself, that ok */
|
/* if client delegates to itself, that ok */
|
||||||
if (krb5_principal_compare(context, client->entry.principal, server) == TRUE)
|
if (krb5_principal_compare(context, client->entry.principal, server->entry.principal) == TRUE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (clientdb->hdb_check_constrained_delegation) {
|
if (clientdb->hdb_check_constrained_delegation) {
|
||||||
ret = clientdb->hdb_check_constrained_delegation(context, clientdb, client, server);
|
ret = clientdb->hdb_check_constrained_delegation(context, clientdb, client, target);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -528,7 +542,7 @@ check_constrained_delegation(krb5_context context,
|
|||||||
|
|
||||||
if (acl) {
|
if (acl) {
|
||||||
for (i = 0; i < acl->len; i++) {
|
for (i = 0; i < acl->len; i++) {
|
||||||
if (krb5_principal_compare(context, server, &acl->val[i]) == TRUE)
|
if (krb5_principal_compare(context, target, &acl->val[i]) == TRUE)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2029,7 +2043,7 @@ server_lookup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = check_constrained_delegation(context, config, clientdb,
|
ret = check_constrained_delegation(context, config, clientdb,
|
||||||
client, sp);
|
client, server, sp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
kdc_log(context, config, 0,
|
kdc_log(context, config, 0,
|
||||||
"constrained delegation from %s as %s to %s not allowed",
|
"constrained delegation from %s as %s to %s not allowed",
|
||||||
|
Reference in New Issue
Block a user