ipa-pwd-extop: Use common krb5 structs from kdb.h

This removes custom structures and allows easier sharing of code with ipa-kdb
This commit is contained in:
Simo Sorce 2011-06-20 09:23:37 -04:00
parent 672035cbba
commit b4aab3d98d
4 changed files with 14 additions and 19 deletions

View File

@ -93,7 +93,7 @@ static int filter_keys(struct ipapwd_krbcfg *krbcfg, struct ipapwd_keyset *kset)
for (i = 0; i < kset->num_keys; i++) {
for (j = 0; j < krbcfg->num_supp_encsalts; j++) {
if (kset->keys[i].ekey->type ==
krbcfg->supp_encsalts[j].enc_type) {
krbcfg->supp_encsalts[j].ks_enctype) {
break;
}
}

View File

@ -97,20 +97,15 @@ struct ipapwd_operation {
/* from ipapwd_common.c */
struct ipapwd_encsalt {
krb5_int32 enc_type;
krb5_int32 salt_type;
};
struct ipapwd_krbcfg {
krb5_context krbctx;
char *realm;
int mkvno;
krb5_keyblock *kmkey;
int num_supp_encsalts;
struct ipapwd_encsalt *supp_encsalts;
krb5_key_salt_tuple *supp_encsalts;
int num_pref_encsalts;
struct ipapwd_encsalt *pref_encsalts;
krb5_key_salt_tuple *pref_encsalts;
char **passsync_mgrs;
int num_passsync_mgrs;
bool allow_lm_hash;

View File

@ -69,15 +69,15 @@ static const char *ipapwd_def_encsalts[] = {
static int new_ipapwd_encsalt(krb5_context krbctx,
const char * const *encsalts,
struct ipapwd_encsalt **es_types,
krb5_key_salt_tuple **es_types,
int *num_es_types)
{
struct ipapwd_encsalt *es;
krb5_key_salt_tuple *es;
int nes, i;
int rc;
for (i = 0; encsalts[i]; i++) /* count */ ;
es = calloc(i + 1, sizeof(struct ipapwd_encsalt));
es = calloc(i + 1, sizeof(krb5_key_salt_tuple));
if (!es) {
LOG_OOM();
rc = LDAP_OPERATIONS_ERROR;
@ -116,16 +116,16 @@ static int new_ipapwd_encsalt(krb5_context krbctx,
krberr = krb5_string_to_salttype(salt, &tmpsalt);
for (j = 0; j < nes; j++) {
krb5_c_enctype_compare(krbctx, es[j].enc_type, tmpenc, &similar);
if (similar && (es[j].salt_type == tmpsalt)) {
krb5_c_enctype_compare(krbctx, es[j].ks_enctype, tmpenc, &similar);
if (similar && (es[j].ks_salttype == tmpsalt)) {
break;
}
}
if (j == nes) {
/* not found */
es[j].enc_type = tmpenc;
es[j].salt_type = tmpsalt;
es[j].ks_enctype = tmpenc;
es[j].ks_salttype = tmpsalt;
nes++;
}

View File

@ -319,7 +319,7 @@ static Slapi_Value **encrypt_encode_key(struct ipapwd_krbcfg *krbcfg,
salt.data = NULL;
switch (krbcfg->pref_encsalts[i].salt_type) {
switch (krbcfg->pref_encsalts[i].ks_salttype) {
case KRB5_KDB_SALTTYPE_ONLYREALM:
@ -396,14 +396,14 @@ static Slapi_Value **encrypt_encode_key(struct ipapwd_krbcfg *krbcfg,
default:
LOG_FATAL("Invalid salt type [%d]\n",
krbcfg->pref_encsalts[i].salt_type);
krbcfg->pref_encsalts[i].ks_salttype);
goto enc_error;
}
/* need to build the key now to manage the AFS salt.length
* special case */
krberr = krb5_c_string_to_key(krbctx,
krbcfg->pref_encsalts[i].enc_type,
krbcfg->pref_encsalts[i].ks_enctype,
&pwd, &salt, &key);
if (krberr) {
LOG_FATAL("krb5_c_string_to_key failed [%s]\n",
@ -461,7 +461,7 @@ static Slapi_Value **encrypt_encode_key(struct ipapwd_krbcfg *krbcfg,
goto enc_error;
}
kset->keys[i].salt->type = krbcfg->pref_encsalts[i].salt_type;
kset->keys[i].salt->type = krbcfg->pref_encsalts[i].ks_salttype;
if (salt.length) {
kset->keys[i].salt->value.bv_len = salt.length;