Skip to content

Commit

Permalink
Make kdc name type strictness configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Nov 15, 2016
1 parent 961f543 commit 9e2b696
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions kdc/default_config.c
Expand Up @@ -59,6 +59,7 @@ krb5_kdc_get_config(krb5_context context, krb5_kdc_configuration **config)
c->check_ticket_addresses = TRUE;
c->allow_null_ticket_addresses = TRUE;
c->allow_anonymous = FALSE;
c->strict_nametypes = FALSE;
c->trpolicy = TRPOLICY_ALWAYS_CHECK;
c->enable_pkinit = FALSE;
c->pkinit_princ_in_cert = TRUE;
Expand Down Expand Up @@ -163,6 +164,12 @@ krb5_kdc_get_config(krb5_context context, krb5_kdc_configuration **config)
"kdc",
"allow-anonymous", NULL);

c->strict_nametypes =
krb5_config_get_bool_default(context, NULL,
c->strict_nametypes,
"kdc",
"strict-nametypes", NULL);

c->max_datagram_reply_length =
krb5_config_get_int_default(context,
NULL,
Expand Down
1 change: 1 addition & 0 deletions kdc/kdc.h
Expand Up @@ -69,6 +69,7 @@ typedef struct krb5_kdc_configuration {
krb5_boolean check_ticket_addresses;
krb5_boolean allow_null_ticket_addresses;
krb5_boolean allow_anonymous;
krb5_boolean strict_nametypes;
enum krb5_kdc_trpolicy trpolicy;

krb5_boolean enable_pkinit;
Expand Down
22 changes: 21 additions & 1 deletion kdc/misc.c
Expand Up @@ -33,6 +33,22 @@

#include "kdc_locl.h"

static int
name_type_ok(krb5_context context,
krb5_kdc_configuration *config,
krb5_const_principal principal)
{
int nt = krb5_principal_get_type(context, principal);

if (!krb5_principal_is_krbtgt(context, principal))
return 1;
if (nt == KRB5_NT_SRV_INST || nt == KRB5_NT_UNKNOWN)
return 1;
if (config->strict_nametypes == 0)
return 1;
return 0;
}

struct timeval _kdc_now;

krb5_error_code
Expand All @@ -44,7 +60,7 @@ _kdc_db_fetch(krb5_context context,
HDB **db,
hdb_entry_ex **h)
{
hdb_entry_ex *ent;
hdb_entry_ex *ent = NULL;
krb5_error_code ret = HDB_ERR_NOENTRY;
int i;
unsigned kvno = 0;
Expand All @@ -53,6 +69,9 @@ _kdc_db_fetch(krb5_context context,

*h = NULL;

if (!name_type_ok(context, config, principal))
goto out2;

if (kvno_ptr != NULL && *kvno_ptr != 0) {
kvno = *kvno_ptr;
flags |= HDB_F_KVNO_SPECIFIED;
Expand Down Expand Up @@ -131,6 +150,7 @@ _kdc_db_fetch(krb5_context context,
}
}

out2:
if (ret == HDB_ERR_NOENTRY) {
krb5_set_error_message(context, ret, "no such entry found in hdb");
}
Expand Down

0 comments on commit 9e2b696

Please sign in to comment.