clean up error handling, plug memory leaks, and free memory in error path,

assume realloc(NULL, ...) works, factor out common code, indent


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13509 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2004-03-14 12:38:48 +00:00
parent 86731c301b
commit ea42ef5261

View File

@@ -130,6 +130,20 @@ LDAP__bytes2hex(const char *buffer, size_t buf_len, char **out)
return 0; return 0;
} }
static int
LDAP_no_size_limit(krb5_context context, LDAP *lp)
{
int ret, limit = LDAP_NO_LIMIT;
ret = ldap_set_option(lp, LDAP_OPT_SIZELIMIT, (const void *)&limit);
if (ret != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_set_option: %s",
ldap_err2string(ret));
return HDB_ERR_BADVERSION;
}
return 0;
}
static krb5_error_code static krb5_error_code
LDAP__setmod(LDAPMod *** modlist, int modop, const char *attribute, LDAP__setmod(LDAPMod *** modlist, int modop, const char *attribute,
int *pIndex) int *pIndex)
@@ -702,22 +716,20 @@ LDAP_dn2principal(krb5_context context, HDB * db, const char *dn,
krb5_principal * principal) krb5_principal * principal)
{ {
krb5_error_code ret; krb5_error_code ret;
int rc, limit = 1; int rc;
char **values; char **values;
LDAPMessage *res = NULL, *e; LDAPMessage *res = NULL, *e;
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_SIZELIMIT, (const void *)&limit); ret = LDAP_no_size_limit(context, HDB2LDAP(db));
if (rc != LDAP_SUCCESS) { if (ret)
krb5_set_error_string(context, "ldap_set_option: %s", ldap_err2string(rc));
ret = HDB_ERR_BADVERSION;
goto out; goto out;
}
rc = ldap_search_s(HDB2LDAP(db), dn, LDAP_SCOPE_SUBTREE, rc = ldap_search_s(HDB2LDAP(db), dn, LDAP_SCOPE_SUBTREE,
"(objectclass=krb5Principal)", krb5principal_attrs, "(objectclass=krb5Principal)", krb5principal_attrs,
0, &res); 0, &res);
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_search_s: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_search_s: %s",
ldap_err2string(rc));
ret = HDB_ERR_NOENTRY; ret = HDB_ERR_NOENTRY;
goto out; goto out;
} }
@@ -745,42 +757,48 @@ LDAP_dn2principal(krb5_context context, HDB * db, const char *dn,
} }
static krb5_error_code static krb5_error_code
LDAP__lookup_princ(krb5_context context, HDB * db, const char *princname, LDAP__lookup_princ(krb5_context context,
HDB *db,
const char *princname,
const char *userid, const char *userid,
LDAPMessage ** msg) LDAPMessage **msg)
{ {
krb5_error_code ret; krb5_error_code ret;
int rc, limit = 1; int rc;
char *filter = NULL; char *filter = NULL;
(void) LDAP__connect(context, db); ret = LDAP__connect(context, db);
if (ret)
return ret;
rc = rc = asprintf(&filter,
asprintf(&filter, "(&(objectclass=krb5Principal)(krb5PrincipalName=%s))",
"(&(objectclass=krb5Principal)(krb5PrincipalName=%s))", princname);
princname);
if (rc < 0) { if (rc < 0) {
krb5_set_error_string(context, "asprintf: out of memory"); krb5_set_error_string(context, "asprintf: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_SIZELIMIT, (const void *)&limit); ret = LDAP_no_size_limit(context, HDB2LDAP(db));
if (rc != LDAP_SUCCESS) { if (ret)
krb5_set_error_string(context, "ldap_set_option: %s", ldap_err2string(rc));
ret = HDB_ERR_BADVERSION;
goto out; goto out;
}
rc = ldap_search_s(HDB2LDAP(db), db->hdb_name, LDAP_SCOPE_SUBTREE, filter, rc = ldap_search_s(HDB2LDAP(db), db->hdb_name, LDAP_SCOPE_SUBTREE, filter,
krb5kdcentry_attrs, 0, msg); krb5kdcentry_attrs, 0, msg);
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_search_s: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_search_s: %s",
ldap_err2string(rc));
ret = HDB_ERR_NOENTRY; ret = HDB_ERR_NOENTRY;
goto out; goto out;
} }
if (userid && ldap_count_entries(HDB2LDAP(db), *msg) == 0) { if (userid && ldap_count_entries(HDB2LDAP(db), *msg) == 0) {
free(filter);
filter = NULL;
ldap_msgfree(*msg);
*msg = NULL;
rc = asprintf(&filter, rc = asprintf(&filter,
"(&(objectclass=account)(uid=%s))", "(&(objectclass=account)(uid=%s))",
userid); userid);
@@ -790,28 +808,26 @@ LDAP__lookup_princ(krb5_context context, HDB * db, const char *princname,
goto out; goto out;
} }
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_SIZELIMIT, (const void *)&limit); ret = LDAP_no_size_limit(context, HDB2LDAP(db));
if (ret)
goto out;
rc = ldap_search_s(HDB2LDAP(db), db->hdb_name, LDAP_SCOPE_SUBTREE,
filter, krb5kdcentry_attrs, 0, msg);
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_set_option: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_search_s: %s",
ret = HDB_ERR_BADVERSION; ldap_err2string(rc));
ret = HDB_ERR_NOENTRY;
goto out; goto out;
} }
rc = ldap_search_s(HDB2LDAP(db), db->hdb_name, LDAP_SCOPE_SUBTREE, filter,
krb5kdcentry_attrs, 0, msg);
if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_search_s: %s", ldap_err2string(rc));
ret = HDB_ERR_NOENTRY;
goto out;
}
} }
ret = 0; ret = 0;
out: out:
if (filter != NULL) { if (filter != NULL)
free(filter); free(filter);
}
return ret; return ret;
} }
@@ -819,31 +835,37 @@ static krb5_error_code
LDAP_principal2message(krb5_context context, HDB * db, LDAP_principal2message(krb5_context context, HDB * db,
krb5_principal princ, LDAPMessage ** msg) krb5_principal princ, LDAPMessage ** msg)
{ {
char *princname = NULL; char *name, *name_short = NULL;
char *princname_short = NULL;
krb5_error_code ret; krb5_error_code ret;
krb5_realm r; krb5_realm *r, *r0;
ret = krb5_unparse_name(context, princ, &princname); *msg = NULL;
if (ret != 0) {
free(princname); ret = krb5_unparse_name(context, princ, &name);
if (ret)
return ret;
ret = krb5_get_default_realms(context, &r0);
if(ret) {
free(name);
return ret; return ret;
} }
for (r = r0; *r != NULL; r++) {
ret = krb5_get_default_realm(context, &r); if(strcmp(krb5_principal_get_realm(context, princ), *r) == 0) {
if(ret) ret = krb5_unparse_name_short(context, princ, &name_short);
return ret; if (ret) {
if(strcmp(krb5_principal_get_realm(context, princ), r) == 0) { krb5_free_host_realm(context, r0);
ret = krb5_unparse_name_short(context, princ, &princname_short); free(name);
if (ret != 0) { return ret;
return ret; }
break;
} }
} }
free(r); krb5_free_host_realm(context, r0);
ret = LDAP__lookup_princ(context, db, princname, princname_short, msg); ret = LDAP__lookup_princ(context, db, name, name_short, msg);
free(princname); free(name);
free(princname_short); free(name_short);
return ret; return ret;
} }
@@ -866,28 +888,26 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
memset(ent, 0, sizeof(*ent)); memset(ent, 0, sizeof(*ent));
ent->flags = int2HDBFlags(0); ent->flags = int2HDBFlags(0);
ret = ret = LDAP_get_string_value(db, msg, "krb5PrincipalName",
LDAP_get_string_value(db, msg, "krb5PrincipalName", &unparsed_name);
&unparsed_name);
if (ret == 0) { if (ret == 0) {
ret = krb5_parse_name(context, unparsed_name, &ent->principal); ret = krb5_parse_name(context, unparsed_name, &ent->principal);
if (ret != 0) { if (ret != 0) {
goto out; goto out;
} }
} else { } else {
ret = LDAP_get_string_value(db, msg, "uid", ret = LDAP_get_string_value(db, msg, "uid",
&unparsed_name); &unparsed_name);
if (ret == 0) { if (ret == 0) {
ret = krb5_parse_name(context, unparsed_name, &ent->principal); ret = krb5_parse_name(context, unparsed_name, &ent->principal);
if (ret != 0) { if (ret != 0) {
goto out; goto out;
} }
} }
} }
ret = ret = LDAP_get_integer_value(db, msg, "krb5KeyVersionNumber",
LDAP_get_integer_value(db, msg, "krb5KeyVersionNumber", &ent->kvno);
&ent->kvno);
if (ret != 0) { if (ret != 0) {
ent->kvno = 0; ent->kvno = 0;
} }
@@ -936,6 +956,11 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
} }
ent->etypes->len = ldap_count_values(values); ent->etypes->len = ldap_count_values(values);
ent->etypes->val = calloc(ent->etypes->len, sizeof(int)); ent->etypes->val = calloc(ent->etypes->len, sizeof(int));
if (ent->etypes->val == NULL) {
krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM;
goto out;
}
for (i = 0; i < ent->etypes->len; i++) { for (i = 0; i < ent->etypes->len; i++) {
ent->etypes->val[i] = atoi(values[i]); ent->etypes->val[i] = atoi(values[i]);
} }
@@ -945,52 +970,47 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
/* manually construct the NT (type 23) key */ /* manually construct the NT (type 23) key */
ret = LDAP_get_string_value(db, msg, "sambaNTPassword", &ntPasswordIN); ret = LDAP_get_string_value(db, msg, "sambaNTPassword", &ntPasswordIN);
if (ret == 0) { if (ret == 0) {
if (!ent->keys.val) { int *etypes;
ent->keys.len = 1; Key *keys;
ent->keys.val = (Key *) malloc(sizeof(Key));
} else { keys = realloc(ent->keys.val,
Key *old_keys = ent->keys.val; (ent->keys.len + 1) * sizeof(ent->keys.val[0]));
ent->keys.len++; if (keys == NULL) {
ent->keys.val = realloc(ent->keys.val, ent->keys.len * sizeof(Key)); free(ntPasswordIN);
if (!ent->keys.val) { krb5_set_error_string(context, "malloc: out of memory");
free(old_keys); ret = ENOMEM;
krb5_set_error_string(context, "malloc: out of memory"); goto out;
ret = ENOMEM;
goto out;
}
} }
memset(&ent->keys.val[ent->keys.len-1], '\0', sizeof(Key)); ent->keys.val = keys;
ent->keys.val[ent->keys.len-1].key.keytype = ETYPE_ARCFOUR_HMAC_MD5; memset(&ent->keys.val[ent->keys.len], 0, sizeof(Key));
krb5_data_alloc (&ent->keys.val[ent->keys.len-1].key.keyvalue, 16); ent->keys.val[ent->keys.len].key.keytype = ETYPE_ARCFOUR_HMAC_MD5;
LDAP__hex2bytes(ntPasswordIN, ent->keys.val[ent->keys.len-1].key.keyvalue.data, 16); ret = krb5_data_alloc (&ent->keys.val[ent->keys.len].key.keyvalue, 16);
if (ret) {
krb5_set_error_string(context, "malloc: out of memory");
free(ntPasswordIN);
ret = ENOMEM;
goto out;
}
LDAP__hex2bytes(ntPasswordIN,
ent->keys.val[ent->keys.len].key.keyvalue.data, 16);
free(ntPasswordIN); free(ntPasswordIN);
if (!ent->etypes) { ent->keys.len++;
ent->etypes = malloc(sizeof(*(ent->etypes)));
if (ent->etypes == NULL) { etypes = realloc(ent->etypes->val,
krb5_set_error_string(context, "malloc: out of memory"); (ent->etypes->len + 1) * sizeof(ent->etypes->val[0]));
ret = ENOMEM; if (etypes == NULL) {
goto out; krb5_set_error_string(context, "malloc: out of memory");
} ret = ENOMEM;
ent->etypes->len = 1; goto out;
ent->etypes->val = (int *) malloc(sizeof(int));
} else {
int *old_etypes = ent->etypes->val;
ent->etypes->len++;
ent->etypes->val = realloc(ent->etypes->val, ent->etypes->len * sizeof(int));
if (!ent->etypes->val) {
free(old_etypes);
krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM;
goto out;
}
} }
ent->etypes->val[ent->etypes->len-1] = ETYPE_ARCFOUR_HMAC_MD5; ent->etypes->val = etypes;
ent->etypes->val[ent->etypes->len] = ETYPE_ARCFOUR_HMAC_MD5;
ent->etypes->len++;
} }
ret = ret = LDAP_get_generalized_time_value(db, msg, "createTimestamp",
LDAP_get_generalized_time_value(db, msg, "createTimestamp", &ent->created_by.time);
&ent->created_by.time);
if (ret != 0) { if (ret != 0) {
ent->created_by.time = time(NULL); ent->created_by.time = time(NULL);
} }
@@ -1027,60 +1047,53 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
ent->modified_by = NULL; ent->modified_by = NULL;
} }
if ((ent->valid_start = (KerberosTime *) malloc(sizeof(KerberosTime))) ent->valid_start = malloc(sizeof(*ent->valid_start));
== NULL) { if (ent->valid_start == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
ret = ret = LDAP_get_generalized_time_value(db, msg, "krb5ValidStart",
LDAP_get_generalized_time_value(db, msg, "krb5ValidStart", ent->valid_start);
ent->valid_start);
if (ret != 0) { if (ret != 0) {
/* OPTIONAL */ /* OPTIONAL */
free(ent->valid_start); free(ent->valid_start);
ent->valid_start = NULL; ent->valid_start = NULL;
} }
ent->valid_end = malloc(sizeof(*ent->valid_end));
if ((ent->valid_end = (KerberosTime *) malloc(sizeof(KerberosTime))) == if (ent->valid_end == NULL) {
NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
ret = ret = LDAP_get_generalized_time_value(db, msg, "krb5ValidEnd",
LDAP_get_generalized_time_value(db, msg, "krb5ValidEnd", ent->valid_end);
ent->valid_end);
if (ret != 0) { if (ret != 0) {
/* OPTIONAL */ /* OPTIONAL */
free(ent->valid_end); free(ent->valid_end);
ent->valid_end = NULL; ent->valid_end = NULL;
} }
ent->pw_end = malloc(sizeof(*ent->pw_end));
if ((ent->pw_end = (KerberosTime *) malloc(sizeof(KerberosTime))) == if (ent->pw_end == NULL) {
NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
ret = LDAP_get_generalized_time_value(db, msg, "krb5PasswordEnd", ret = LDAP_get_generalized_time_value(db, msg, "krb5PasswordEnd",
ent->pw_end); ent->pw_end);
if (ret != 0) { if (ret != 0) {
/* OPTIONAL */ /* OPTIONAL */
free(ent->pw_end); free(ent->pw_end);
ent->pw_end = NULL; ent->pw_end = NULL;
} }
ret = LDAP_get_integer_value(db, msg, "sambaPwdMustChange", &tmp_time);
ret = LDAP_get_integer_value(db, msg, "sambaPwdMustChange",
&tmp_time);
if (ret == 0) { if (ret == 0) {
if (!ent->pw_end) { if (ent->pw_end == NULL) {
if ((ent->pw_end = (KerberosTime *) malloc(sizeof(KerberosTime))) == ent->pw_end = malloc(sizeof(*ent->pw_end));
NULL) { if (ent->pw_end == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
@@ -1090,14 +1103,14 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
} }
#if 0 /* we we have last_pw_change */ #if 0 /* we we have last_pw_change */
if ((ent->last_pw_change = (KerberosTime *) malloc(sizeof(KerberosTime))) == ent->last_pw_change = malloc(sizeof(*ent->last_pw_change));
NULL) { if (ent->last_pw_change == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
ret = LDAP_get_integer_value(db, msg, "sambaPwdLastSet",
ret = LDAP_get_integer_value(db, msg, "sambaPwdLastSet", &tmp_time); &tmp_time);
if (ret != 0) { if (ret != 0) {
/* OPTIONAL */ /* OPTIONAL */
free(ent->last_pw_change); free(ent->last_pw_change);
@@ -1107,7 +1120,7 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
} }
#endif #endif
ent->max_life = (int *) malloc(sizeof(int)); ent->max_life = malloc(sizeof(*ent->max_life));
if (ent->max_life == NULL) { if (ent->max_life == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
@@ -1119,7 +1132,7 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
ent->max_life = NULL; ent->max_life = NULL;
} }
ent->max_renew = (int *) malloc(sizeof(int)); ent->max_renew = malloc(sizeof(*ent->max_renew));
if (ent->max_renew == NULL) { if (ent->max_renew == NULL) {
krb5_set_error_string(context, "malloc: out of memory"); krb5_set_error_string(context, "malloc: out of memory");
ret = ENOMEM; ret = ENOMEM;
@@ -1209,13 +1222,13 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
if (ent->pw_end) { if (ent->pw_end) {
free(ent->pw_end); free(ent->pw_end);
ent->pw_end = NULL; ent->pw_end = NULL;
} }
break; break;
case 'I': case 'I':
ent->flags.server = TRUE; ent->flags.server = TRUE;
ent->flags.client = TRUE; ent->flags.client = TRUE;
break; break;
} }
} }
out2: out2:
free(samba_acct_flags); free(samba_acct_flags);
@@ -1229,7 +1242,6 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
} }
if (ret != 0) { if (ret != 0) {
/* I don't think this frees ent itself. */
hdb_free_entry(context, ent); hdb_free_entry(context, ent);
} }
@@ -1250,7 +1262,8 @@ LDAP_lock(krb5_context context, HDB * db, int operation)
return 0; return 0;
} }
static krb5_error_code LDAP_unlock(krb5_context context, HDB * db) static krb5_error_code
LDAP_unlock(krb5_context context, HDB * db)
{ {
return 0; return 0;
} }
@@ -1312,18 +1325,19 @@ LDAP_seq(krb5_context context, HDB * db, unsigned flags, hdb_entry * entry)
} }
static krb5_error_code static krb5_error_code
LDAP_firstkey(krb5_context context, HDB * db, unsigned flags, LDAP_firstkey(krb5_context context, HDB *db, unsigned flags,
hdb_entry * entry) hdb_entry *entry)
{ {
int msgid, limit = LDAP_NO_LIMIT, rc; krb5_error_code ret;
int msgid;
(void) LDAP__connect(context, db); ret = LDAP__connect(context, db);
if (ret)
return ret;
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_SIZELIMIT, (const void *)&limit); ret = LDAP_no_size_limit(context, HDB2LDAP(db));
if (rc != LDAP_SUCCESS) { if (ret)
krb5_set_error_string(context, "ldap_set_option: %s", ldap_err2string(rc)); return ret;
return HDB_ERR_BADVERSION;
}
msgid = ldap_search(HDB2LDAP(db), db->hdb_name, msgid = ldap_search(HDB2LDAP(db), db->hdb_name,
LDAP_SCOPE_SUBTREE, "(objectclass=krb5Principal)", LDAP_SCOPE_SUBTREE, "(objectclass=krb5Principal)",
@@ -1379,23 +1393,27 @@ static krb5_error_code LDAP__connect(krb5_context context, HDB * db)
return 0; return 0;
} }
rc = ldap_initialize((LDAP **) & db->hdb_db, "ldapi:///"); rc = ldap_initialize((LDAP **)&db->hdb_db, "ldapi:///");
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_initialize: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_initialize: %s",
ldap_err2string(rc));
return HDB_ERR_NOENTRY; return HDB_ERR_NOENTRY;
} }
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_PROTOCOL_VERSION, (const void *)&version); rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_PROTOCOL_VERSION, (const void *)&version);
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_set_option: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_set_option: %s",
ldap_err2string(rc));
ldap_unbind_ext(HDB2LDAP(db), NULL, NULL); ldap_unbind_ext(HDB2LDAP(db), NULL, NULL);
db->hdb_db = NULL; db->hdb_db = NULL;
return HDB_ERR_BADVERSION; return HDB_ERR_BADVERSION;
} }
rc = ldap_sasl_bind_s(HDB2LDAP(db), NULL, "EXTERNAL", &bv, NULL, NULL, NULL); rc = ldap_sasl_bind_s(HDB2LDAP(db), NULL, "EXTERNAL", &bv,
NULL, NULL, NULL);
if (rc != LDAP_SUCCESS) { if (rc != LDAP_SUCCESS) {
krb5_set_error_string(context, "ldap_sasl_bind_s: %s", ldap_err2string(rc)); krb5_set_error_string(context, "ldap_sasl_bind_s: %s",
ldap_err2string(rc));
ldap_unbind_ext(HDB2LDAP(db), NULL, NULL); ldap_unbind_ext(HDB2LDAP(db), NULL, NULL);
db->hdb_db = NULL; db->hdb_db = NULL;
return HDB_ERR_BADVERSION; return HDB_ERR_BADVERSION;
@@ -1431,9 +1449,8 @@ LDAP_fetch(krb5_context context, HDB * db, unsigned flags,
krb5_error_code ret; krb5_error_code ret;
ret = LDAP_principal2message(context, db, entry->principal, &msg); ret = LDAP_principal2message(context, db, entry->principal, &msg);
if (ret != 0) { if (ret)
return ret; return ret;
}
e = ldap_first_entry(HDB2LDAP(db), msg); e = ldap_first_entry(HDB2LDAP(db), msg);
if (e == NULL) { if (e == NULL) {