summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-05-26 00:13:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:12 -0500
commit865e13aea13f0f3ef7a2fd9dc33c62800f53c51a (patch)
treebd5b2c6aa31eae5d52435ebef46b6db9d48fee16
parentfdb68ec206c81d6affe6c3740366a27add2d94fa (diff)
downloadsamba-865e13aea13f0f3ef7a2fd9dc33c62800f53c51a.tar.gz
samba-865e13aea13f0f3ef7a2fd9dc33c62800f53c51a.tar.bz2
samba-865e13aea13f0f3ef7a2fd9dc33c62800f53c51a.zip
r15895: Ensure all new rid allocation goes through
the same function (deals with races). Jeremy. (This used to be commit 4962548dfe8ec2854e209217066556f339d3186e)
-rw-r--r--source3/passdb/pdb_ldap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 70d9e6024c..fbc6378f68 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -4439,7 +4439,7 @@ static NTSTATUS ldapsam_get_new_rid(struct ldapsam_privates *priv,
return status;
}
-static BOOL ldapsam_new_rid(struct pdb_methods *methods, uint32 *rid)
+static NTSTATUS ldapsam_new_rid_internal(struct pdb_methods *methods, uint32 *rid)
{
int i;
@@ -4447,18 +4447,24 @@ static BOOL ldapsam_new_rid(struct pdb_methods *methods, uint32 *rid)
NTSTATUS result = ldapsam_get_new_rid(methods->private_data,
rid);
if (NT_STATUS_IS_OK(result)) {
- return True;
+ return result;
}
if (!NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED)) {
- return False;
+ return result;
}
/* The ldap update failed (maybe a race condition), retry */
}
/* Tried 10 times, fail. */
- return False;
+ return NT_STATUS_ACCESS_DENIED;
+}
+
+static BOOL ldapsam_new_rid(struct pdb_methods *methods, uint32 *rid)
+{
+ NTSTATUS result = ldapsam_new_rid_internal(methods, rid);
+ return NT_STATUS_IS_OK(result) ? True : False;
}
static BOOL ldapsam_sid_to_id(struct pdb_methods *methods,
@@ -4645,7 +4651,7 @@ static NTSTATUS ldapsam_create_user(struct pdb_methods *my_methods,
}
/* Create the basic samu structure and generate the mods for the ldap commit */
- if (!NT_STATUS_IS_OK((ret = ldapsam_get_new_rid(ldap_state, rid)))) {
+ if (!NT_STATUS_IS_OK((ret = ldapsam_new_rid_internal(my_methods, rid)))) {
DEBUG(1, ("ldapsam_create_user: Could not allocate a new RID\n"));
return ret;
}
@@ -4934,7 +4940,7 @@ static NTSTATUS ldapsam_create_dom_group(struct pdb_methods *my_methods,
smbldap_set_mod(&mods, LDAP_MOD_ADD, "gidNumber", gidstr);
}
- if (!NT_STATUS_IS_OK((ret = ldapsam_get_new_rid(ldap_state, rid)))) {
+ if (!NT_STATUS_IS_OK((ret = ldapsam_new_rid_internal(my_methods, rid)))) {
DEBUG(1, ("ldapsam_create_group: Could not allocate a new RID\n"));
return ret;
}