[SCM] Samba Shared Repository - branch v3-6-test updated
Karolin Seeger
kseeger at samba.org
Mon Jul 4 13:46:19 MDT 2011
The branch, v3-6-test has been updated
via c6d5c7c s3:smbldap: make smbldap_connect_system self contained
via 56bc5c7 s3:smbldap: add a destructor to smbldap_state, just in case
via 66e8538 s3:smbldap: let smbldap_free_struct do what it claims to
via 56e9ad4 s3:smbldap: free the idle event scheduled in smbldap_open in smbldap_close
via 119a45e s3:smbldap: use smbldap_state as memory context for idle event
from e282a81 s3:smbd do not panic when CTDB is unhealthy (Bug #8278)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit c6d5c7cc830d59e7b6f0fa5a38eae27b0f1aa4bb
Author: Gregor Beck <gbeck at sernet.de>
Date: Tue Jun 21 08:16:56 2011 +0200
s3:smbldap: make smbldap_connect_system self contained
The last patches address bug #8253 (winbindd panics if verify_idpool() fails).
commit 56bc5c73eaa7509d4e58ed010c834304b238c72c
Author: Gregor Beck <gbeck at sernet.de>
Date: Tue Jun 21 08:06:28 2011 +0200
s3:smbldap: add a destructor to smbldap_state, just in case
commit 66e853875ec13481093bf79522004665fe66260d
Author: Gregor Beck <gbeck at sernet.de>
Date: Tue Jun 21 08:02:53 2011 +0200
s3:smbldap: let smbldap_free_struct do what it claims to
commit 56e9ad4aa736875ac5666a9c3e33ae3d94fb2f5c
Author: Gregor Beck <gbeck at sernet.de>
Date: Tue Jun 21 08:00:59 2011 +0200
s3:smbldap: free the idle event scheduled in smbldap_open in smbldap_close
commit 119a45e9f8e4fdc17417a1b618094e3280add584
Author: Gregor Beck <gbeck at sernet.de>
Date: Tue Jun 21 07:51:41 2011 +0200
s3:smbldap: use smbldap_state as memory context for idle event
ensure the event is canceled if the smbldap_state gets freed
this fixes a panic of winbindd if verify_idpool fails
-----------------------------------------------------------------------
Summary of changes:
source3/lib/smbldap.c | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 0c5ea98..1d507fb 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1165,8 +1165,9 @@ static int rebindproc_connect (LDAP * ld, LDAP_CONST char *url, int request,
/*******************************************************************
connect to the ldap server under system privilege.
******************************************************************/
-static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_struct)
+static int smbldap_connect_system(struct smbldap_state *ldap_state)
{
+ LDAP *ldap_struct = ldap_state->ldap_struct;
int rc;
int version;
@@ -1177,7 +1178,8 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_
/* get the default dn and password only if they are not set already */
if (!fetch_ldap_pw(&bind_dn, &bind_secret)) {
DEBUG(0, ("ldap_connect_system: Failed to retrieve password from secrets.tdb\n"));
- return LDAP_INVALID_CREDENTIALS;
+ rc = LDAP_INVALID_CREDENTIALS;
+ goto done;
}
smbldap_set_creds(ldap_state, false, bind_dn, bind_secret);
SAFE_FREE(bind_dn);
@@ -1223,7 +1225,7 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_
ld_error ? ld_error : "(unknown)"));
SAFE_FREE(ld_error);
ldap_state->num_failures++;
- return rc;
+ goto done;
}
ldap_state->num_failures = 0;
@@ -1238,6 +1240,11 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_
DEBUG(3, ("ldap_connect_system: successful connection to the LDAP server\n"));
DEBUGADD(10, ("ldap_connect_system: LDAP server %s support paged results\n",
ldap_state->paged_results ? "does" : "does not"));
+done:
+ if (rc != 0) {
+ ldap_unbind(ldap_struct);
+ ldap_state->ldap_struct = NULL;
+ }
return rc;
}
@@ -1292,9 +1299,7 @@ static int smbldap_open(struct smbldap_state *ldap_state)
return rc;
}
- if ((rc = smbldap_connect_system(ldap_state, ldap_state->ldap_struct))) {
- ldap_unbind(ldap_state->ldap_struct);
- ldap_state->ldap_struct = NULL;
+ if ((rc = smbldap_connect_system(ldap_state))) {
return rc;
}
@@ -1306,7 +1311,7 @@ static int smbldap_open(struct smbldap_state *ldap_state)
if (ldap_state->event_context != NULL) {
ldap_state->idle_event = event_add_timed(
- ldap_state->event_context, NULL,
+ ldap_state->event_context, ldap_state,
timeval_current_ofs(SMBLDAP_IDLE_TIME, 0),
smbldap_idle_fn, ldap_state);
}
@@ -1331,6 +1336,8 @@ static NTSTATUS smbldap_close(struct smbldap_state *ldap_state)
smbldap_delete_state(ldap_state);
+ TALLOC_FREE(ldap_state->idle_event);
+
DEBUG(5,("The connection to the LDAP server was closed\n"));
/* maybe free the results here --metze */
@@ -1819,7 +1826,7 @@ static void smbldap_idle_fn(struct event_context *event_ctx,
/* this needs to be made monotonic clock aware inside tevent: */
state->idle_event = event_add_timed(
- event_ctx, NULL,
+ event_ctx, state,
timeval_add(&now_abs, SMBLDAP_IDLE_TIME, 0),
smbldap_idle_fn,
private_data);
@@ -1845,13 +1852,17 @@ void smbldap_free_struct(struct smbldap_state **ldap_state)
SAFE_FREE((*ldap_state)->bind_dn);
SAFE_FREE((*ldap_state)->bind_secret);
- TALLOC_FREE((*ldap_state)->idle_event);
-
- *ldap_state = NULL;
+ TALLOC_FREE(*ldap_state);
/* No need to free any further, as it is talloc()ed */
}
+static int smbldap_state_destructor(struct smbldap_state *state)
+{
+ smbldap_free_struct(&state);
+ return 0;
+}
+
/**********************************************************************
Intitalise the 'general' ldap structures, on which ldap operations may be conducted
@@ -1875,6 +1886,7 @@ NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
(*smbldap_state)->event_context = event_ctx;
+ talloc_set_destructor(*smbldap_state, smbldap_state_destructor);
return NT_STATUS_OK;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list