check return values from ldap operations and close it we get back
LDAP_SERVER_DOWN. stupid ldap client lib, you should retry by yourself. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13899 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -42,7 +42,8 @@ RCSID("$Id$");
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
static krb5_error_code LDAP__connect(krb5_context context, HDB * db);
|
static krb5_error_code LDAP__connect(krb5_context context, HDB *);
|
||||||
|
static krb5_error_code LDAP_close(krb5_context context, HDB *);
|
||||||
|
|
||||||
static krb5_error_code
|
static krb5_error_code
|
||||||
LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||||
@@ -165,6 +166,20 @@ LDAP_no_size_limit(krb5_context context, LDAP *lp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_ldap(krb5_context context, HDB *db, int ret)
|
||||||
|
{
|
||||||
|
switch (ret) {
|
||||||
|
case LDAP_SUCCESS:
|
||||||
|
return 0;
|
||||||
|
case LDAP_SERVER_DOWN:
|
||||||
|
LDAP_close(context, db);
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -744,7 +759,7 @@ LDAP_dn2principal(krb5_context context, HDB * db, const char *dn,
|
|||||||
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 (check_ldap(context, db, rc)) {
|
||||||
krb5_set_error_string(context, "ldap_search_s: %s",
|
krb5_set_error_string(context, "ldap_search_s: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
ret = HDB_ERR_NOENTRY;
|
ret = HDB_ERR_NOENTRY;
|
||||||
@@ -803,7 +818,7 @@ LDAP__lookup_princ(krb5_context context,
|
|||||||
|
|
||||||
rc = ldap_search_s(HDB2LDAP(db), HDB2BASE(db), LDAP_SCOPE_SUBTREE, filter,
|
rc = ldap_search_s(HDB2LDAP(db), HDB2BASE(db), LDAP_SCOPE_SUBTREE, filter,
|
||||||
krb5kdcentry_attrs, 0, msg);
|
krb5kdcentry_attrs, 0, msg);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if (check_ldap(context, db, rc)) {
|
||||||
krb5_set_error_string(context, "ldap_search_s: %s",
|
krb5_set_error_string(context, "ldap_search_s: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
ret = HDB_ERR_NOENTRY;
|
ret = HDB_ERR_NOENTRY;
|
||||||
@@ -831,7 +846,7 @@ LDAP__lookup_princ(krb5_context context,
|
|||||||
|
|
||||||
rc = ldap_search_s(HDB2LDAP(db), HDB2BASE(db), LDAP_SCOPE_SUBTREE,
|
rc = ldap_search_s(HDB2LDAP(db), HDB2BASE(db), LDAP_SCOPE_SUBTREE,
|
||||||
filter, krb5kdcentry_attrs, 0, msg);
|
filter, krb5kdcentry_attrs, 0, msg);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if (check_ldap(context, db, rc)) {
|
||||||
krb5_set_error_string(context, "ldap_search_s: %s",
|
krb5_set_error_string(context, "ldap_search_s: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
ret = HDB_ERR_NOENTRY;
|
ret = HDB_ERR_NOENTRY;
|
||||||
@@ -1335,6 +1350,9 @@ LDAP_seq(krb5_context context, HDB * db, unsigned flags, hdb_entry * entry)
|
|||||||
ret = HDB_ERR_NOENTRY;
|
ret = HDB_ERR_NOENTRY;
|
||||||
HDBSETMSGID(db, -1);
|
HDBSETMSGID(db, -1);
|
||||||
break;
|
break;
|
||||||
|
case LDAP_SERVER_DOWN:
|
||||||
|
LDAP_close(context, db);
|
||||||
|
/* fall though */
|
||||||
case 0:
|
case 0:
|
||||||
case -1:
|
case -1:
|
||||||
default:
|
default:
|
||||||
@@ -1565,16 +1583,15 @@ LDAP_store(krb5_context context, HDB * db, unsigned flags,
|
|||||||
errfn = "ldap_modify_s";
|
errfn = "ldap_modify_s";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == LDAP_SUCCESS) {
|
if (check_ldap(context, db, rc)) {
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
char *ld_error = NULL;
|
char *ld_error = NULL;
|
||||||
ldap_get_option(HDB2LDAP(db), LDAP_OPT_ERROR_STRING,
|
ldap_get_option(HDB2LDAP(db), LDAP_OPT_ERROR_STRING,
|
||||||
&ld_error);
|
&ld_error);
|
||||||
krb5_set_error_string(context, "%s: %s (dn=%s) %s: %s",
|
krb5_set_error_string(context, "%s: %s (dn=%s) %s: %s",
|
||||||
errfn, name, dn, ldap_err2string(rc), ld_error);
|
errfn, name, dn, ldap_err2string(rc), ld_error);
|
||||||
ret = HDB_ERR_CANT_LOCK_DB;
|
ret = HDB_ERR_CANT_LOCK_DB;
|
||||||
}
|
} else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* free stuff */
|
/* free stuff */
|
||||||
|
Reference in New Issue
Block a user