Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Dec 9, 2014
1 parent 4ea9e09 commit 12ef3a4
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions src/modules/rlm_ldap/ldap.c
Expand Up @@ -488,11 +488,8 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
/*
* Check if there was an error sending the request
*/
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER,
&lib_errno);
if (lib_errno != LDAP_SUCCESS) {
goto process_error;
}
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &lib_errno);
if (lib_errno != LDAP_SUCCESS) goto process_error;

memset(&tv, 0, sizeof(tv));
tv.tv_sec = inst->res_timeout;
Expand All @@ -509,8 +506,8 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
}

if (lib_errno == -1) {
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER,
&lib_errno);
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &lib_errno);

goto process_error;
}

Expand All @@ -522,13 +519,10 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
extra ? &part_dn : NULL,
extra ? &srv_err : NULL,
NULL, NULL, freeit);
if (freeit) {
*result = NULL;
}
if (freeit) *result = NULL;

if (lib_errno != LDAP_SUCCESS) {
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER,
&lib_errno);
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &lib_errno);
goto process_error;
}

Expand All @@ -546,7 +540,6 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c

case LDAP_NO_SUCH_OBJECT:
*error = "The specified DN wasn't found, check base_dn and identity";

status = LDAP_PROC_BAD_DN;

if (!extra) break;
Expand All @@ -558,24 +551,20 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
if (len < 0) break;

our_err = talloc_typed_asprintf(conn, "Match stopped here: [%.*s]%s", len, dn, part_dn ? part_dn : "");

goto error_string;

case LDAP_INSUFFICIENT_ACCESS:
*error = "Insufficient access. Check the identity and password configuration directives";

status = LDAP_PROC_NOT_PERMITTED;
break;

case LDAP_UNWILLING_TO_PERFORM:
*error = "Server was unwilling to perform";

status = LDAP_PROC_NOT_PERMITTED;
break;

case LDAP_FILTER_ERROR:
*error = "Bad search filter";

status = LDAP_PROC_ERROR;
break;

Expand All @@ -593,13 +582,11 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
case LDAP_UNAVAILABLE:
case LDAP_SERVER_DOWN:
status = LDAP_PROC_RETRY;

goto error_string;

case LDAP_INVALID_CREDENTIALS:
case LDAP_CONSTRAINT_VIOLATION:
status = LDAP_PROC_REJECT;

goto error_string;

case LDAP_OPERATIONS_ERROR:
Expand All @@ -610,15 +597,10 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
default:
status = LDAP_PROC_ERROR;

error_string:

if (!*error) {
*error = ldap_err2string(lib_errno);
}
error_string:
if (!*error) *error = ldap_err2string(lib_errno);

if (!extra || ((lib_errno == srv_errno) && !our_err && !srv_err)) {
break;
}
if (!extra || ((lib_errno == srv_errno) && !our_err && !srv_err)) break;

/*
* Output the error codes from the library and server
Expand Down Expand Up @@ -666,13 +648,8 @@ static ldap_rcode_t rlm_ldap_result(ldap_instance_t const *inst, ldap_handle_t c
/*
* Cleanup memory
*/
if (srv_err) {
ldap_memfree(srv_err);
}

if (part_dn) {
ldap_memfree(part_dn);
}
if (srv_err) ldap_memfree(srv_err);
if (part_dn) ldap_memfree(part_dn);

talloc_free(our_err);

Expand Down

0 comments on commit 12ef3a4

Please sign in to comment.