summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-10-24 19:39:26 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-10-24 18:39:43 +0000
commit32189689df2bc40473dfeaccff6219f8e0d56b76 (patch)
tree7db1cfcda0cbf68478471e6d79d95b0ce8c937e9 /source4/dsdb/samdb
parent49dee0e453049a2b26aaacf81e61a0f11afccd91 (diff)
downloadsamba-32189689df2bc40473dfeaccff6219f8e0d56b76.tar.gz
samba-32189689df2bc40473dfeaccff6219f8e0d56b76.tar.bz2
samba-32189689df2bc40473dfeaccff6219f8e0d56b76.zip
s4:dsdb - use LDB results in "add_time_element" and "add_uint64_element"
In both the "objectguid" and the "repl_meta_data" DSDB module. Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date: Sun Oct 24 18:39:43 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c39
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c20
2 files changed, 35 insertions, 24 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index cb8f683b40..d7dc885003 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -55,18 +55,20 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t)
{
struct ldb_message_element *el;
char *s;
+ int ret;
if (ldb_msg_find_element(msg, attr) != NULL) {
- return 0;
+ return LDB_SUCCESS;
}
s = ldb_timestring(msg, t);
if (s == NULL) {
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
- if (ldb_msg_add_string(msg, attr, s) != 0) {
- return -1;
+ ret = ldb_msg_add_string(msg, attr, s);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
el = ldb_msg_find_element(msg, attr);
@@ -74,7 +76,7 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t)
is ignored */
el->flags = LDB_FLAG_MOD_REPLACE;
- return 0;
+ return LDB_SUCCESS;
}
/*
@@ -84,13 +86,15 @@ static int add_uint64_element(struct ldb_context *ldb, struct ldb_message *msg,
const char *attr, uint64_t v)
{
struct ldb_message_element *el;
+ int ret;
if (ldb_msg_find_element(msg, attr) != NULL) {
- return 0;
+ return LDB_SUCCESS;
}
- if (samdb_msg_add_uint64(ldb, msg, msg, attr, v) != LDB_SUCCESS) {
- return -1;
+ ret = samdb_msg_add_uint64(ldb, msg, msg, attr, v);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
el = ldb_msg_find_element(msg, attr);
@@ -98,7 +102,7 @@ static int add_uint64_element(struct ldb_context *ldb, struct ldb_message *msg,
is ignored */
el->flags = LDB_FLAG_MOD_REPLACE;
- return 0;
+ return LDB_SUCCESS;
}
struct og_context {
@@ -175,12 +179,12 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
guid = GUID_random();
ret = dsdb_msg_add_guid(msg, &guid, "objectGUID");
- if (ret) {
+ if (ret != LDB_SUCCESS) {
return ret;
}
- if (add_time_element(msg, "whenCreated", t) != 0 ||
- add_time_element(msg, "whenChanged", t) != 0) {
+ if (add_time_element(msg, "whenCreated", t) != LDB_SUCCESS ||
+ add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
return ldb_operr(ldb);
}
@@ -189,8 +193,10 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
* make sure this function is split and a callback is used */
ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
- if (add_uint64_element(ldb, msg, "uSNCreated", seq_num) != 0 ||
- add_uint64_element(ldb, msg, "uSNChanged", seq_num) != 0) {
+ if (add_uint64_element(ldb, msg, "uSNCreated",
+ seq_num) != LDB_SUCCESS ||
+ add_uint64_element(ldb, msg, "uSNChanged",
+ seq_num) != LDB_SUCCESS) {
return ldb_operr(ldb);
}
}
@@ -242,14 +248,15 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
return ldb_operr(ldb);
}
- if (add_time_element(msg, "whenChanged", t) != 0) {
+ if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
return ldb_operr(ldb);
}
/* Get a sequence number from the backend */
ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
- if (add_uint64_element(ldb, msg, "uSNChanged", seq_num) != 0) {
+ if (add_uint64_element(ldb, msg, "uSNChanged",
+ seq_num) != LDB_SUCCESS) {
return ldb_operr(ldb);
}
}
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 5188a66efb..1544c89170 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -511,6 +511,7 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t)
{
struct ldb_message_element *el;
char *s;
+ int ret;
if (ldb_msg_find_element(msg, attr) != NULL) {
return LDB_SUCCESS;
@@ -521,8 +522,9 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t)
return LDB_ERR_OPERATIONS_ERROR;
}
- if (ldb_msg_add_string(msg, attr, s) != LDB_SUCCESS) {
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = ldb_msg_add_string(msg, attr, s);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
el = ldb_msg_find_element(msg, attr);
@@ -2230,13 +2232,14 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req)
/* we only change whenChanged and uSNChanged if the seq_num
has changed */
if (ac->seq_num != 0) {
- if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
+ ret = add_time_element(msg, "whenChanged", t);
+ if (ret != LDB_SUCCESS) {
talloc_free(ac);
return ret;
}
- if (add_uint64_element(ldb, msg, "uSNChanged",
- ac->seq_num) != LDB_SUCCESS) {
+ ret = add_uint64_element(ldb, msg, "uSNChanged", ac->seq_num);
+ if (ret != LDB_SUCCESS) {
talloc_free(ac);
return ret;
}
@@ -2346,13 +2349,14 @@ static int replmd_rename_callback(struct ldb_request *req, struct ldb_reply *are
}
talloc_steal(down_req, msg);
- if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
+ ret = add_time_element(msg, "whenChanged", t);
+ if (ret != LDB_SUCCESS) {
talloc_free(ac);
return ret;
}
- if (add_uint64_element(ldb, msg, "uSNChanged",
- ac->seq_num) != LDB_SUCCESS) {
+ ret = add_uint64_element(ldb, msg, "uSNChanged", ac->seq_num);
+ if (ret != LDB_SUCCESS) {
talloc_free(ac);
return ret;
}