[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Jul 1 04:38:01 MDT 2011


The branch, master has been updated
       via  1765833 s3:smbldap: make smbldap_connect_system self contained
       via  6aff8b1 s3:smbldap: add a destructor to smbldap_state, just in case
       via  796c7ab s3:smbldap: let smbldap_free_struct do what it claims to
       via  7eb9c70 s3:smbldap: free the idle event scheduled in smbldap_open in smbldap_close
       via  343ef46 s3:smbldap: use smbldap_state as memory context for idle event
      from  f3c3768 s4-dsdb guard principalName parse for invalid inputs

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1765833481ca441429bdf8dd167b729a24edbfa2
Author: Gregor Beck <gbeck at sernet.de>
Date:   Tue Jun 21 08:16:56 2011 +0200

    s3:smbldap: make smbldap_connect_system self contained
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Fri Jul  1 12:37:50 CEST 2011 on sn-devel-104

commit 6aff8b19fcdbf694cc8dbd388f87e55cce475939
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
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 796c7ab282f11ad46bb5e90d721c54223045540f
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
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 7eb9c70342a86d444608317d606776e745723cb3
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
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 343ef46b9b764bfab93bad3fdcb4031adcc6f7db
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
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

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 38c7b20..5c99e4b 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1166,8 +1166,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;
 
@@ -1178,7 +1179,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);
@@ -1224,7 +1226,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;
@@ -1239,6 +1241,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;
 }
 
@@ -1293,9 +1300,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;
 	}
 
@@ -1307,7 +1312,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);
 	}
@@ -1332,6 +1337,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 */
 
@@ -1820,7 +1827,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);
@@ -1846,13 +1853,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
@@ -1876,6 +1887,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