|
|
388f6b |
diff --git a/ptclient/ldap.c b/ptclient/ldap.c
|
|
|
388f6b |
index 7e48879..dafa724 100644
|
|
|
388f6b |
--- a/ptclient/ldap.c
|
|
|
388f6b |
+++ b/ptclient/ldap.c
|
|
|
388f6b |
@@ -932,7 +932,7 @@ static int ptsmodule_get_dn(
|
|
|
388f6b |
{
|
|
|
388f6b |
rc = ptsmodule_expand_tokens(ptsm->filter, canon_id, NULL, &filter);
|
|
|
388f6b |
if (rc != PTSM_OK)
|
|
|
388f6b |
- return rc;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
|
|
|
388f6b |
if (ptsm->domain_base_dn && ptsm->domain_base_dn[0] != '\0' && (strrchr(canon_id, '@') != NULL)) {
|
|
|
388f6b |
syslog(LOG_DEBUG, "Attempting to get domain for %s from %s", canon_id, ptsm->domain_base_dn);
|
|
|
388f6b |
@@ -955,19 +955,23 @@ static int ptsmodule_get_dn(
|
|
|
388f6b |
ldap_unbind(ptsm->ld);
|
|
|
388f6b |
ptsm->ld = NULL;
|
|
|
388f6b |
syslog(LOG_ERR, "LDAP not available: %s", ldap_err2string(rc));
|
|
|
388f6b |
- return PTSM_RETRY;
|
|
|
388f6b |
+ rc = PTSM_RETRY;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
syslog(LOG_ERR, "LDAP search for domain failed: %s", ldap_err2string(rc));
|
|
|
388f6b |
- return PTSM_FAIL;
|
|
|
388f6b |
+ rc = PTSM_FAIL;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
if (ldap_count_entries(ptsm->ld, res) < 1) {
|
|
|
388f6b |
syslog(LOG_ERR, "No domain %s found", domain);
|
|
|
388f6b |
- return PTSM_FAIL;
|
|
|
388f6b |
+ rc = PTSM_FAIL;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
} else if (ldap_count_entries(ptsm->ld, res) > 1) {
|
|
|
388f6b |
syslog(LOG_ERR, "Multiple domains %s found", domain);
|
|
|
388f6b |
- return PTSM_FAIL;
|
|
|
388f6b |
+ rc = PTSM_FAIL;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
} else {
|
|
|
388f6b |
if ((entry = ldap_first_entry(ptsm->ld, res)) != NULL) {
|
|
|
388f6b |
if ((vals = ldap_get_values(ptsm->ld, entry, ptsm->domain_result_attribute)) != NULL) {
|
|
|
388f6b |
@@ -982,7 +986,7 @@ static int ptsmodule_get_dn(
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
if (rc != PTSM_OK) {
|
|
|
388f6b |
- return rc;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
} else {
|
|
|
388f6b |
base = xstrdup(ptsm->base);
|
|
|
388f6b |
syslog(LOG_DEBUG, "Continuing with ptsm->base: %s", ptsm->base);
|
|
|
388f6b |
@@ -993,23 +997,23 @@ static int ptsmodule_get_dn(
|
|
|
388f6b |
} else {
|
|
|
388f6b |
rc = ptsmodule_expand_tokens(ptsm->base, canon_id, NULL, &base);
|
|
|
388f6b |
if (rc != PTSM_OK)
|
|
|
388f6b |
- return rc;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
rc = ldap_search_st(ptsm->ld, base, ptsm->scope, filter, attrs, 0, &(ptsm->timeout), &res;;
|
|
|
388f6b |
|
|
|
388f6b |
if (rc != LDAP_SUCCESS) {
|
|
|
388f6b |
syslog(LOG_DEBUG, "Searching %s with %s failed", base, base);
|
|
|
388f6b |
- free(filter);
|
|
|
388f6b |
- free(base);
|
|
|
388f6b |
|
|
|
388f6b |
if (rc == LDAP_SERVER_DOWN) {
|
|
|
388f6b |
ldap_unbind(ptsm->ld);
|
|
|
388f6b |
ptsm->ld = NULL;
|
|
|
388f6b |
- return PTSM_RETRY;
|
|
|
388f6b |
+ rc = PTSM_RETRY;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
- return PTSM_FAIL;
|
|
|
388f6b |
+ rc = PTSM_FAIL;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
free(filter);
|
|
|
388f6b |
@@ -1035,6 +1039,13 @@ static int ptsmodule_get_dn(
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
return (*ret ? PTSM_OK : PTSM_FAIL);
|
|
|
388f6b |
+
|
|
|
388f6b |
+ done:
|
|
|
388f6b |
+ if (filter)
|
|
|
388f6b |
+ free(filter);
|
|
|
388f6b |
+ if (base)
|
|
|
388f6b |
+ free(base);
|
|
|
388f6b |
+ return rc;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
|
|
|
388f6b |
@@ -1344,7 +1355,7 @@ static int ptsmodule_make_authstate_group(
|
|
|
388f6b |
rc = ptsmodule_connect();
|
|
|
388f6b |
if (rc != PTSM_OK) {
|
|
|
388f6b |
*reply = "ptsmodule_connect() failed";
|
|
|
388f6b |
- goto done;;
|
|
|
388f6b |
+ goto done;
|
|
|
388f6b |
}
|
|
|
388f6b |
|
|
|
388f6b |
rc = ptsmodule_expand_tokens(ptsm->group_filter, canon_id+6, NULL, &filter);
|