1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00

don't call ads_destroy() twice; fixes segfault in winbindd when DC goes down; bug 437

This commit is contained in:
Gerald Carter -
parent bbc403ec6e
commit 9da4d1f7db
3 changed files with 19 additions and 6 deletions

View File

@ -1787,7 +1787,8 @@ ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32 *usn)
void *res; void *res;
status = ads_do_search_retry(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res); status = ads_do_search_retry(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
if (!ADS_ERR_OK(status)) return status; if (!ADS_ERR_OK(status))
return status;
if (ads_count_replies(ads, res) != 1) { if (ads_count_replies(ads, res) != 1) {
return ADS_ERROR(LDAP_NO_RESULTS_RETURNED); return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);

View File

@ -54,15 +54,20 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
return status; return status;
} }
if (*res) ads_msgfree(ads, *res); if (*res)
ads_msgfree(ads, *res);
*res = NULL; *res = NULL;
DEBUG(3,("Reopening ads connection to realm '%s' after error %s\n", DEBUG(3,("Reopening ads connection to realm '%s' after error %s\n",
ads->config.realm, ads_errstr(status))); ads->config.realm, ads_errstr(status)));
if (ads->ld) { if (ads->ld) {
ldap_unbind(ads->ld); ldap_unbind(ads->ld);
} }
ads->ld = NULL; ads->ld = NULL;
status = ads_connect(ads); status = ads_connect(ads);
if (!ADS_ERR_OK(status)) { if (!ADS_ERR_OK(status)) {
DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n", DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n",
ads_errstr(status))); ads_errstr(status)));

View File

@ -787,9 +787,13 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
} }
rc = ads_USN(ads, seq); rc = ads_USN(ads, seq);
if (!ADS_ERR_OK(rc)) { if (!ADS_ERR_OK(rc)) {
/* its a dead connection */
ads_destroy(&ads); /* its a dead connection ; don't destroy it
through since ads_USN() has already done
that indirectly */
domain->private = NULL; domain->private = NULL;
} }
return ads_ntstatus(rc); return ads_ntstatus(rc);
@ -910,8 +914,11 @@ static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
rc = ads_domain_sid(ads, sid); rc = ads_domain_sid(ads, sid);
if (!ADS_ERR_OK(rc)) { if (!ADS_ERR_OK(rc)) {
/* its a dead connection */
ads_destroy(&ads); /* its a dead connection; don't destroy it though
since that has already been done indirectly
by ads_domain_sid() */
domain->private = NULL; domain->private = NULL;
} }