summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-07-21 08:32:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:52 -0500
commit4396d0d1482d4033a469f7a3e3835a6f3b145046 (patch)
tree7bbfae04ff6d9ebac282e7db009fcc2b2e65432a
parenteb08c1fc8f877bffeaf63acfbc97ae00a4370a15 (diff)
downloadsamba-4396d0d1482d4033a469f7a3e3835a6f3b145046.tar.gz
samba-4396d0d1482d4033a469f7a3e3835a6f3b145046.tar.bz2
samba-4396d0d1482d4033a469f7a3e3835a6f3b145046.zip
r8669: The objectguid module belongs in Samba's ldb module collection, not in
ldb, as it can't build without the NDR and GUID code. Also make it properly use the NDR encoding for the GUID (I forgot last time, and used a string), as well as set the dependencies on the module correctly. Andrew Bartlett (This used to be commit 8054abc76e5e3588cebc7fc01062a1223b7f140b)
-rw-r--r--source4/dsdb/config.mk11
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c (renamed from source4/lib/ldb/modules/objectguid.c)14
-rw-r--r--source4/dsdb/samdb/samdb.c14
-rw-r--r--source4/lib/ldb/common/ldb_modules.c10
-rw-r--r--source4/lib/ldb/config.mk9
5 files changed, 25 insertions, 33 deletions
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index 51a87c8d67..8f66eab39c 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -1,6 +1,17 @@
# Directory Service subsystem
################################################
+# Start MODULE libldb_objectguid
+[MODULE::libldb_objectguid]
+SUBSYSTEM = LIBLDB
+INIT_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/objectguid.o
+REQUIRED_SUBSYSTEMS = \
+ NDR_RAW NDR_MISC
+# End MODULE libldb_objectguid
+################################################
+
+################################################
# Start MODULE libldb_samldb
[MODULE::libldb_samldb]
SUBSYSTEM = LIBLDB
diff --git a/source4/lib/ldb/modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index 0e789c2bda..45f1a10730 100644
--- a/source4/lib/ldb/modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -73,10 +73,11 @@ static struct ldb_message_element *objectguid_find_attribute(const struct ldb_me
/* add_record: add crateTimestamp/modifyTimestamp attributes */
static int objectguid_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
+ struct ldb_val v;
struct ldb_message *msg2;
struct ldb_message_element *attribute;
struct GUID guid;
- char *guidstr;
+ NTSTATUS nt_status;
int ret, i;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
@@ -104,13 +105,16 @@ static int objectguid_add_record(struct ldb_module *module, const struct ldb_mes
/* a new GUID */
guid = GUID_random();
- guidstr = GUID_string(msg2, &guid);
- if (!guidstr) {
+
+ nt_status = ndr_push_struct_blob(&v, msg2, &guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NT_STATUS_IS_OK(nt_status)) {
return -1;
}
- if (ldb_msg_add_string(module->ldb, msg2, "objectGUID", guidstr) != 0) {
- return -1;
+ ret = ldb_msg_add_value(module->ldb, msg2, "objectGUID", &v);
+ if (ret) {
+ return ret;
}
ret = ldb_next_add_record(module, msg2);
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index fd542c5567..448e4292aa 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -978,20 +978,6 @@ int samdb_msg_set_ldaptime(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, str
*/
int samdb_add(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
{
- int ret;
- struct ldb_val v;
- NTSTATUS status;
- struct GUID guid = GUID_random();
-
- status = ndr_push_struct_blob(&v, mem_ctx, &guid,
- (ndr_push_flags_fn_t)ndr_push_GUID);
- if (!NT_STATUS_IS_OK(status)) {
- return -1;
- }
-
- ret = ldb_msg_add_value(sam_ldb, msg, "objectGUID", &v);
- if (ret != 0) return ret;
-
return ldb_add(sam_ldb, msg);
}
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index d6213be79a..dcc384ffad 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -189,8 +189,8 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
continue;
}
- if (strcmp(modules[i], "objectguid") == 0) {
- current = objectguid_module_init(ldb, options);
+ if (strcmp(modules[i], "rdn_name") == 0) {
+ current = rdn_name_module_init(ldb, options);
if (!current) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
return -1;
@@ -199,8 +199,9 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
continue;
}
- if (strcmp(modules[i], "rdn_name") == 0) {
- current = rdn_name_module_init(ldb, options);
+#ifdef _SAMBA_BUILD_
+ if (strcmp(modules[i], "objectguid") == 0) {
+ current = objectguid_module_init(ldb, options);
if (!current) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
return -1;
@@ -209,7 +210,6 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
continue;
}
-#ifdef _SAMBA_BUILD_
if (strcmp(modules[i], "samldb") == 0) {
current = samldb_module_init(ldb, options);
if (!current) {
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index fe339f9e17..87e15f1375 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -8,15 +8,6 @@ INIT_OBJ_FILES = \
################################################
################################################
-# Start MODULE libldb_objectguid
-[MODULE::libldb_objectguid]
-SUBSYSTEM = LIBLDB
-INIT_OBJ_FILES = \
- lib/ldb/modules/objectguid.o
-# End MODULE libldb_objectguid
-################################################
-
-################################################
# Start MODULE libldb_rdn_name
[MODULE::libldb_rdn_name]
SUBSYSTEM = LIBLDB