Ignore:
Timestamp:
Aug 6, 2011, 6:50:53 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/lib/smbldap.c

    r414 r620  
    10941094 connect to the ldap server under system privilege.
    10951095******************************************************************/
    1096 static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_struct)
    1097 {
     1096static int smbldap_connect_system(struct smbldap_state *ldap_state)
     1097{
     1098        LDAP *ldap_struct = ldap_state->ldap_struct;
    10981099        int rc;
    10991100        int version;
     
    11061107                if (!fetch_ldap_pw(&bind_dn, &bind_secret)) {
    11071108                        DEBUG(0, ("ldap_connect_system: Failed to retrieve password from secrets.tdb\n"));
    1108                         return LDAP_INVALID_CREDENTIALS;
     1109                        rc = LDAP_INVALID_CREDENTIALS;
     1110                        goto done;
    11091111                }
    11101112                smbldap_set_creds(ldap_state, false, bind_dn, bind_secret);
     
    11521154                SAFE_FREE(ld_error);
    11531155                ldap_state->num_failures++;
    1154                 return rc;
     1156                goto done;
    11551157        }
    11561158
     
    11671169        DEBUGADD(10, ("ldap_connect_system: LDAP server %s support paged results\n",
    11681170                ldap_state->paged_results ? "does" : "does not"));
     1171done:
     1172        if (rc != 0) {
     1173                ldap_unbind(ldap_struct);
     1174                ldap_state->ldap_struct = NULL;
     1175        }
    11691176        return rc;
    11701177}
     
    12211228        }
    12221229
    1223         if ((rc = smbldap_connect_system(ldap_state, ldap_state->ldap_struct))) {
    1224                 ldap_unbind(ldap_state->ldap_struct);
    1225                 ldap_state->ldap_struct = NULL;
     1230        if ((rc = smbldap_connect_system(ldap_state))) {
    12261231                return rc;
    12271232        }
     
    12351240        if (ldap_state->event_context != NULL) {
    12361241                ldap_state->idle_event = event_add_timed(
    1237                         ldap_state->event_context, NULL,
     1242                        ldap_state->event_context, ldap_state,
    12381243                        timeval_current_ofs(SMBLDAP_IDLE_TIME, 0),
    12391244                        smbldap_idle_fn, ldap_state);
     
    12591264
    12601265        smbldap_delete_state(ldap_state);
     1266
     1267        TALLOC_FREE(ldap_state->idle_event);
    12611268
    12621269        DEBUG(5,("The connection to the LDAP server was closed\n"));
     
    17461753
    17471754                state->idle_event = event_add_timed(
    1748                         event_ctx, NULL,
     1755                        event_ctx, state,
    17491756                        timeval_add(&now, SMBLDAP_IDLE_TIME, 0),
    17501757                        smbldap_idle_fn,
     
    17721779        SAFE_FREE((*ldap_state)->bind_secret);
    17731780
    1774         TALLOC_FREE((*ldap_state)->idle_event);
    1775 
    1776         *ldap_state = NULL;
     1781        TALLOC_FREE(*ldap_state);
    17771782
    17781783        /* No need to free any further, as it is talloc()ed */
     1784}
     1785
     1786static int smbldap_state_destructor(struct smbldap_state *state)
     1787{
     1788        smbldap_free_struct(&state);
     1789        return 0;
    17791790}
    17801791
     
    18021813        (*smbldap_state)->event_context = event_ctx;
    18031814
     1815        talloc_set_destructor(*smbldap_state, smbldap_state_destructor);
    18041816        return NT_STATUS_OK;
    18051817}
Note: See TracChangeset for help on using the changeset viewer.