[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Jun 26 08:10:02 MDT 2012


The branch, master has been updated
       via  290e7de s3-pdbtest: Fix pdbtest to compare the same fields
       via  43555d6 s4-samldb: do not talloc_steal() the elements of the original request
       via  a7f26d5 s3-pdbtest: Report and handle errors in pdb->getsampwnam()
       via  ff4d8fc s3-pdb_samba4: Allocate and free a talloc_stackframe() in pdb_samba4_replace_by_sam()
      from  5df1fda s3: Restore async i/o with the "native" AIO interface

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


- Log -----------------------------------------------------------------
commit 290e7de47a43d921bcd08a1f459a3d6b8d129c99
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 26 21:06:25 2012 +1000

    s3-pdbtest: Fix pdbtest to compare the same fields
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Jun 26 16:09:28 CEST 2012 on sn-devel-104

commit 43555d6439460d2bafa54300221856142c83aa3f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 26 20:53:08 2012 +1000

    s4-samldb: do not talloc_steal() the elements of the original request

commit a7f26d5c6d441e1688382e5b9d3543f8a81dd74d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 26 20:52:07 2012 +1000

    s3-pdbtest: Report and handle errors in pdb->getsampwnam()

commit ff4d8fcd8d69e19608cc5b8bd65ca022d714c95a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 26 20:51:17 2012 +1000

    s3-pdb_samba4: Allocate and free a talloc_stackframe() in pdb_samba4_replace_by_sam()

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

Summary of changes:
 source3/passdb/pdb_samba4.c             |   13 ++++++++++---
 source3/torture/pdbtest.c               |   10 ++++++----
 source4/dsdb/samdb/ldb_modules/samldb.c |   14 ++++++++++----
 3 files changed, 26 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
index 22a5908..c94f29c 100644
--- a/source3/passdb/pdb_samba4.c
+++ b/source3/passdb/pdb_samba4.c
@@ -335,6 +335,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 				     struct ldb_dn *dn,
 				     struct samu *sam)
 {
+	TALLOC_CTX *frame = talloc_stackframe();
 	int ret = LDB_SUCCESS;
 	const char *pw;
 	struct ldb_message *msg;
@@ -342,7 +343,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 	uint32_t dsdb_flags = 0;
 	/* TODO: All fields :-) */
 
-	msg = ldb_msg_new(talloc_tos());
+	msg = ldb_msg_new(frame);
 	if (!msg) {
 		return false;
 	}
@@ -350,11 +351,11 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 	msg->dn = dn;
 
 	/* build modify request */
-	ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL,
+	ret = ldb_build_mod_req(&req, state->ldb, frame, msg, NULL, NULL,
 				ldb_op_default_callback,
 				NULL);
         if (ret != LDB_SUCCESS) {
-		talloc_free(msg);
+		talloc_free(frame);
 		return ret;
         }
 
@@ -371,6 +372,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 	if (need_update(sam, PDB_PLAINTEXT_PW)) {
 		struct ldb_val pw_utf16;
 		if (pw == NULL) {
+			talloc_free(frame);
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 		
@@ -476,9 +478,11 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 		uint32_t rid;
 		NTSTATUS status = dom_sid_split_rid(NULL, sid, NULL, &rid);
 		if (!NT_STATUS_IS_OK(status)) {
+			talloc_free(frame);
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 		if (!dom_sid_in_domain(samdb_domain_sid(state->ldb), sid)) {
+			talloc_free(frame);
 			return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
 		}
 		ret |= samdb_msg_add_uint(state->ldb, msg, msg, "primaryGroupID", rid);
@@ -576,10 +580,12 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 
  */
 	if (ret != LDB_SUCCESS) {
+		talloc_free(frame);
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	if (msg->num_elements == 0) {
+		talloc_free(frame);
 		/* Nothing to do, just return success */
 		return LDB_SUCCESS;
 	}
@@ -592,6 +598,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 			 ldb_errstring(state->ldb)));
 	}
 
+	talloc_free(frame);
 	return ret;
 }
 
diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
index 1257eff..14e28e9 100644
--- a/source3/torture/pdbtest.c
+++ b/source3/torture/pdbtest.c
@@ -133,7 +133,7 @@ static bool samu_correct(struct samu *s1, struct samu *s2)
 	}
 
 	/* Check kickoff time */
-	if (pdb_get_kickoff_time(s1) != pdb_get_logoff_time(s2)) {
+	if (pdb_get_kickoff_time(s1) != pdb_get_kickoff_time(s2)) {
 		DEBUG(0, ("Kickoff time is not written correctly\n"));
 		ret = False;
 	}
@@ -428,14 +428,16 @@ int main(int argc, char **argv)
 	}
 
 	/* Get account information through getsampwnam() */
-	if (NT_STATUS_IS_ERR(pdb->getsampwnam(pdb, in, out->username))) {
-		fprintf(stderr, "Error getting sampw of added user %s.\n",
-				out->username);
+	rv = pdb->getsampwnam(pdb, in, out->username);
+	if (NT_STATUS_IS_ERR(rv)) {
+		fprintf(stderr, "Error getting sampw of added user %s: %s\n",
+			out->username, nt_errstr(rv));
 		if (!NT_STATUS_IS_OK(rv = pdb->delete_sam_account(pdb, out))) {
 			fprintf(stderr, "Error in delete_sam_account %s\n", 
 					get_friendly_nt_error_msg(rv));
 		}
 		TALLOC_FREE(ctx);
+		exit(1);
 	}
 
 	/* Verify integrity */
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index a859fc9..bb30605 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -1689,8 +1689,10 @@ static int samldb_sam_accountname_check(struct samldb_ctx *ac)
 	if (ret != LDB_SUCCESS) {
 		return ret;
 	}
-	sam_accountname = talloc_steal(ac,
-				       ldb_msg_find_attr_as_string(tmp_msg, "sAMAccountName", NULL));
+
+	/* We must not steal the original string, it belongs to the caller! */
+	sam_accountname = talloc_strdup(ac, 
+					ldb_msg_find_attr_as_string(tmp_msg, "sAMAccountName", NULL));
 	talloc_free(tmp_msg);
 
 	if (sam_accountname == NULL) {
@@ -1901,8 +1903,12 @@ static int samldb_service_principal_names_change(struct samldb_ctx *ac)
 		if (ret != LDB_SUCCESS) {
 			return ret;
 		}
-		dns_hostname = talloc_steal(ac,
-					    ldb_msg_find_attr_as_string(msg, "dNSHostName", NULL));
+		dns_hostname = talloc_strdup(ac, 
+					     ldb_msg_find_attr_as_string(msg, "dNSHostName", NULL));
+		if (dns_hostname == NULL) {
+			return ldb_module_oom(ac->module);
+		}
+			
 		talloc_free(msg);
 
 		ret = dsdb_module_search_dn(ac->module, ac, &res, ac->msg->dn,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list