[SCM] Samba Shared Repository - branch master updated
Matthias Dieter Wallnöfer
mdw at samba.org
Sat Oct 16 07:55:01 MDT 2010
The branch, master has been updated
via 39d11a9 ldb:"ldb_dn_compare_base" - use "unsigned int" counters
via 531d7f5 ldb:"ldb_dn_add_child" - use "unsigned int" counters
via 1557acb ldb:"ldb_dn_remove_base_components" - use an "unsigned int" counter
via 19e9434 ldb:"ldb_dn_canonical" - use an "unsigned int" counter
via bc02948 s4:samldb LDB module - use appropriate fixed-length integer types where needed
via 42d9978 s4:dsdb/samdb/ldb_modules/util.c - remove now unused functions which set integers
via a0bd529 s4:samba3sid LDB module - handle the RID as uint32_t
from d7ca757 s4:objectclass LDB module - implement the "isCriticalSystemObject" subtree delete protection
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 39d11a977d0f326fe676b245fa55e63416350e81
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 15:10:11 2010 +0200
ldb:"ldb_dn_compare_base" - use "unsigned int" counters
Autobuild-User: Matthias Dieter Wallnöfer <mdw at samba.org>
Autobuild-Date: Sat Oct 16 13:54:13 UTC 2010 on sn-devel-104
commit 531d7f569e2fc1c385fb294fe7fb81d9b3d371f9
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 15:08:40 2010 +0200
ldb:"ldb_dn_add_child" - use "unsigned int" counters
commit 1557acb44af8c43ceafa5516915f7107e169f190
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 15:04:57 2010 +0200
ldb:"ldb_dn_remove_base_components" - use an "unsigned int" counter
commit 19e94349b3bf3ba605cb5fde3fca9fe12bfe74d9
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 14:47:42 2010 +0200
ldb:"ldb_dn_canonical" - use an "unsigned int" counter
Convert it to use an "unsigned int" counter which represents the exact length
of the DN components.
commit bc0294814af8dd2756191c8df74bb8db0fe61319
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 14:19:19 2010 +0200
s4:samldb LDB module - use appropriate fixed-length integer types where needed
- The "systemFlags" we interpret always as signed
- Use "samdb_msg_add_int" where possible (much saver for integer storing than
ldb_msg_add_fmt)
commit 42d9978cdd20c4f5a8cfee8e9db8e8d7b405b677
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 11:00:12 2010 +0200
s4:dsdb/samdb/ldb_modules/util.c - remove now unused functions which set integers
Please do always use the functions which specifiy the appropriate integer
length to not run into platform-specific issues. Therefore I'm removing these
generic calls.
commit a0bd52975171b1a4d2407026b21df5cfe3d54dce
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date: Sat Oct 16 10:59:30 2010 +0200
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
-----------------------------------------------------------------------
Summary of changes:
source4/dsdb/samdb/ldb_modules/samba3sid.c | 28 ++++++-----
source4/dsdb/samdb/ldb_modules/samldb.c | 9 ++--
source4/dsdb/samdb/ldb_modules/util.c | 74 ----------------------------
source4/lib/ldb/common/ldb_dn.c | 27 +++++-----
4 files changed, 34 insertions(+), 104 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sid.c b/source4/dsdb/samdb/ldb_modules/samba3sid.c
index 7492684..a5b3df1 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__
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 9d4f3b8..3a971e8 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -259,7 +259,7 @@ static bool samldb_krbtgtnumber_available(struct samldb_ctx *ac, unsigned krbtgt
static int samldb_rodc_add(struct samldb_ctx *ac)
{
struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
- unsigned krbtgt_number, i_start, i;
+ uint32_t krbtgt_number, i_start, i;
int ret;
char *newpass;
@@ -359,7 +359,7 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
int ret;
bool id_exists;
uint32_t msds_intid;
- uint32_t system_flags;
+ int32_t system_flags;
struct ldb_context *ldb;
struct ldb_result *ldb_res;
struct ldb_dn *schema_dn;
@@ -389,7 +389,7 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
}
/* check systemFlags for SCHEMA_BASE_OBJECT flag */
- system_flags = ldb_msg_find_attr_as_uint(ac->msg, "systemFlags", 0);
+ system_flags = ldb_msg_find_attr_as_int(ac->msg, "systemFlags", 0);
if (system_flags & SYSTEM_FLAG_SCHEMA_BASE_OBJECT) {
return LDB_SUCCESS;
}
@@ -423,7 +423,8 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
talloc_free(ldb_res);
} while(id_exists);
- return ldb_msg_add_fmt(ac->msg, "msDS-IntId", "%d", msds_intid);
+ return samdb_msg_add_int(ldb, ac->msg, ac->msg, "msDS-IntId",
+ msds_intid);
}
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c
index 2380e02..e550630 100644
--- a/source4/dsdb/samdb/ldb_modules/util.c
+++ b/source4/dsdb/samdb/ldb_modules/util.c
@@ -616,55 +616,6 @@ int dsdb_module_rid_manager_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx, s
"rIDManagerReference", dn);
}
-
-/*
- update an integer attribute safely via a constrained delete/add
- */
-int dsdb_module_constrainted_update_integer(struct ldb_module *module, struct ldb_dn *dn,
- const char *attr, uint64_t old_val, uint64_t new_val)
-{
- struct ldb_message *msg;
- struct ldb_message_element *el;
- struct ldb_val v1, v2;
- int ret;
- char *vstring;
-
- msg = ldb_msg_new(module);
- msg->dn = dn;
-
- ret = ldb_msg_add_empty(msg, attr, LDB_FLAG_MOD_DELETE, &el);
- if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return ret;
- }
- el->num_values = 1;
- el->values = &v1;
- vstring = talloc_asprintf(msg, "%llu", (unsigned long long)old_val);
- if (!vstring) {
- talloc_free(msg);
- return ldb_module_oom(module);
- }
- v1 = data_blob_string_const(vstring);
-
- ret = ldb_msg_add_empty(msg, attr, LDB_FLAG_MOD_ADD, &el);
- if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return ret;
- }
- el->num_values = 1;
- el->values = &v2;
- vstring = talloc_asprintf(msg, "%llu", (unsigned long long)new_val);
- if (!vstring) {
- talloc_free(msg);
- return ldb_module_oom(module);
- }
- v2 = data_blob_string_const(vstring);
-
- ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
- talloc_free(msg);
- return ret;
-}
-
/*
used to chain to the callers callback
*/
@@ -676,31 +627,6 @@ int dsdb_next_callback(struct ldb_request *req, struct ldb_reply *ares)
return up_req->callback(up_req, ares);
}
-
-/*
- set an integer attribute
- */
-int dsdb_module_set_integer(struct ldb_module *module, struct ldb_dn *dn,
- const char *attr, uint64_t new_val)
-{
- struct ldb_message *msg;
- int ret;
-
- msg = ldb_msg_new(module);
- msg->dn = dn;
-
- ret = ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)new_val);
- if (ret != LDB_SUCCESS) {
- talloc_free(msg);
- return ret;
- }
- msg->elements[0].flags = LDB_FLAG_MOD_REPLACE;
-
- ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
- talloc_free(msg);
- return ret;
-}
-
/*
load the uSNHighest and the uSNUrgent attributes from the @REPLCHANGED
object for a partition
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 9bbefdd..69018b7 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -1029,7 +1029,7 @@ char *ldb_dn_alloc_casefold(TALLOC_CTX *mem_ctx, struct ldb_dn *dn)
int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
{
int ret;
- long long int n_base, n_dn;
+ unsigned int n_base, n_dn;
if ( ! base || base->invalid) return 1;
if ( ! dn || dn->invalid) return -1;
@@ -1080,7 +1080,7 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
n_base = base->comp_num - 1;
n_dn = dn->comp_num - 1;
- while (n_base >= 0) {
+ while (n_base != (unsigned int) -1) {
char *b_name = base->components[n_base].cf_name;
char *dn_name = dn->components[n_dn].cf_name;
@@ -1486,7 +1486,7 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
if (dn->components) {
unsigned int n;
- long long int i, j;
+ unsigned int i, j;
if (dn->comp_num == 0) {
return false;
@@ -1514,7 +1514,8 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
return false;
}
- for (i = dn->comp_num - 1, j = n - 1; i >= 0; i--, j--) {
+ for (i = dn->comp_num - 1, j = n - 1; i != (unsigned int) -1;
+ i--, j--) {
dn->components[j] = dn->components[i];
}
@@ -1600,7 +1601,7 @@ bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...)
bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num)
{
- long long int i;
+ unsigned int i;
if ( ! ldb_dn_validate(dn)) {
return false;
@@ -1611,11 +1612,11 @@ bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num)
}
/* free components */
- for (i = num; i > 0; i--) {
- LDB_FREE(dn->components[dn->comp_num - i].name);
- LDB_FREE(dn->components[dn->comp_num - i].value.data);
- LDB_FREE(dn->components[dn->comp_num - i].cf_name);
- LDB_FREE(dn->components[dn->comp_num - i].cf_value.data);
+ for (i = dn->comp_num - num; i < dn->comp_num; i++) {
+ LDB_FREE(dn->components[i].name);
+ LDB_FREE(dn->components[i].value.data);
+ LDB_FREE(dn->components[i].cf_name);
+ LDB_FREE(dn->components[i].cf_value.data);
}
dn->comp_num -= num;
@@ -1711,7 +1712,7 @@ struct ldb_dn *ldb_dn_get_parent(TALLOC_CTX *mem_ctx, struct ldb_dn *dn)
*/
static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_format) {
- long long int i;
+ unsigned int i;
TALLOC_CTX *tmpctx;
char *cracked = NULL;
const char *format = (ex_format ? "\n" : "/" );
@@ -1723,7 +1724,7 @@ static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_for
tmpctx = talloc_new(mem_ctx);
/* Walk backwards down the DN, grabbing 'dc' components at first */
- for (i = dn->comp_num - 1; i >= 0; i--) {
+ for (i = dn->comp_num - 1; i != (unsigned int) -1; i--) {
if (ldb_attr_cmp(dn->components[i].name, "dc") != 0) {
break;
}
@@ -1742,7 +1743,7 @@ static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_for
}
/* Only domain components? Finish here */
- if (i < 0) {
+ if (i == (unsigned int) -1) {
cracked = talloc_strdup_append_buffer(cracked, format);
talloc_steal(mem_ctx, cracked);
goto done;
--
Samba Shared Repository
More information about the samba-cvs
mailing list