diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-16 10:59:30 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-16 14:39:23 +0200 |
commit | a0bd52975171b1a4d2407026b21df5cfe3d54dce (patch) | |
tree | a455d010a2699886b8f6a7beb682e8cfadcd3754 | |
parent | d7ca757b315181c678d4f874294f72b1114f3dad (diff) | |
download | samba-a0bd52975171b1a4d2407026b21df5cfe3d54dce.tar.gz samba-a0bd52975171b1a4d2407026b21df5cfe3d54dce.tar.bz2 samba-a0bd52975171b1a4d2407026b21df5cfe3d54dce.zip |
s4:samba3sid LDB module - handle the RID as uint32_t
- This is how we always deal with RIDs
- Use an integer-length safe function for the RID update
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/samba3sid.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sid.c b/source4/dsdb/samdb/ldb_modules/samba3sid.c index 749268468d..a5b3df185c 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sid.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sid.c @@ -46,9 +46,8 @@ static int samba3sid_next_sid(struct ldb_module *module, "sambaNextGroupRid", "sambaSID", NULL }; int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); - int sambaNextRid, sambaNextGroupRid, sambaNextUserRid; struct ldb_message *msg; - int rid; + uint32_t sambaNextRid, sambaNextGroupRid, sambaNextUserRid, rid; const char *sambaSID; ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, @@ -75,9 +74,12 @@ static int samba3sid_next_sid(struct ldb_module *module, } msg = res->msgs[0]; - sambaNextRid = ldb_msg_find_attr_as_uint(msg, "sambaNextRid", -1); - sambaNextUserRid = ldb_msg_find_attr_as_uint(msg, "sambaNextUserRid", -1); - sambaNextGroupRid = ldb_msg_find_attr_as_uint(msg, "sambaNextGroupRid", -1); + sambaNextRid = ldb_msg_find_attr_as_uint(msg, "sambaNextRid", + (uint32_t) -1); + sambaNextUserRid = ldb_msg_find_attr_as_uint(msg, "sambaNextUserRid", + (uint32_t) -1); + sambaNextGroupRid = ldb_msg_find_attr_as_uint(msg, "sambaNextGroupRid", + (uint32_t) -1); sambaSID = ldb_msg_find_attr_as_string(msg, "sambaSID", NULL); if (sambaSID == NULL) { @@ -90,15 +92,15 @@ static int samba3sid_next_sid(struct ldb_module *module, } /* choose the highest of the 3 - see pdb_ldap.c for an - * explanation */ + * explaination */ rid = sambaNextRid; - if (sambaNextUserRid > rid) { + if ((sambaNextUserRid != (uint32_t) -1) && (sambaNextUserRid > rid)) { rid = sambaNextUserRid; } - if (sambaNextGroupRid > rid) { + if ((sambaNextGroupRid != (uint32_t) -1) && (sambaNextGroupRid > rid)) { rid = sambaNextGroupRid; } - if (rid == -1) { + if (rid == (uint32_t) -1) { ldb_asprintf_errstring(ldb, __location__ ": No sambaNextRid in %s", @@ -110,15 +112,15 @@ static int samba3sid_next_sid(struct ldb_module *module, /* sambaNextRid is actually the previous RID .... */ rid += 1; - (*sid) = talloc_asprintf(tmp_ctx, "%s-%d", sambaSID, rid); + (*sid) = talloc_asprintf(tmp_ctx, "%s-%u", sambaSID, rid); if (!*sid) { talloc_free(tmp_ctx); return ldb_module_oom(module); } - ret = dsdb_module_constrainted_update_integer(module, msg->dn, - "sambaNextRid", - sambaNextRid, rid); + ret = dsdb_module_constrainted_update_uint32(module, msg->dn, + "sambaNextRid", + &sambaNextRid, &rid); if (ret != LDB_SUCCESS) { ldb_asprintf_errstring(ldb, __location__ |