[PATCH] Fix dependencies in ldb subsystem

Tim Potter tpot at samba.org
Sun Apr 2 23:12:20 GMT 2006


OK this isn't really a working patch, but I was wondering if anyone had
any better ideas on how to fix this problem.

Making ldb in to a library is a great idea, as it allows other
components within Samba to depend on ldb without bringing in any other
dependencies.  Unfortunately this is all messed up by the static modules
outside of ldb that end up pulling in other code.

I've started to try and tease this apart and have the subsystems that
have their own special ldb modules to register them by hand.  Hey jelmer
and metze, what do you think about this?

My goal is to create a swig interface to ldb within Samba, but the
static modules (wins, rootdse, etc) are getting in the way.


Tim.
-------------- next part --------------
Index: dsdb/samdb/samdb.c
===================================================================
--- dsdb/samdb/samdb.c	(revision 14869)
+++ dsdb/samdb/samdb.c	(working copy)
@@ -36,6 +36,15 @@
 #include "dsdb/samdb/samdb.h"
 #include "ads.h"
 
+int objectguid_module_init(void);
+int samldb_module_init(void);
+int ldb_samba3sam_module_init(void);
+int proxy_module_init(void);
+int rootdse_module_init(void);
+int password_hash_module_init(void);
+int ldb_kludge_acl_init(void);
+int ldb_extended_dn_init(void);
+
 /*
   connect to the SAM database
   return an opaque context pointer on success, or NULL on failure
@@ -44,6 +53,20 @@
 				  struct auth_session_info *session_info)
 {
 	struct ldb_context *ldb;
+	static int initialised = 0;
+
+	if (!initialised) {
+		objectguid_module_init();
+		samldb_module_init();
+		ldb_samba3sam_module_init();
+		proxy_module_init();
+		rootdse_module_init();
+		password_hash_module_init();
+		ldb_kludge_acl_init();
+		ldb_extended_dn_init();
+		initialised = 1;
+	}
+
 	ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(), session_info,
 			       NULL, 0, NULL);
 	if (!ldb) {
Index: dsdb/samdb/ldb_modules/config.mk
===================================================================
--- dsdb/samdb/ldb_modules/config.mk	(revision 14869)
+++ dsdb/samdb/ldb_modules/config.mk	(working copy)
@@ -1,7 +1,7 @@
 ################################################
 # Start MODULE ldb_objectguid
 [MODULE::ldb_objectguid]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = objectguid_module_init
 OBJ_FILES = \
 		objectguid.o
@@ -13,7 +13,7 @@
 ################################################
 # Start MODULE ldb_samldb
 [MODULE::ldb_samldb]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = samldb_module_init
 OBJ_FILES = \
 		samldb.o
@@ -25,7 +25,7 @@
 ################################################
 # Start MODULE ldb_samba3sam
 [MODULE::ldb_samba3sam]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = ldb_samba3sam_module_init
 ENABLE = NO
 OBJ_FILES = \
@@ -49,7 +49,7 @@
 ################################################
 # Start MODULE ldb_rootdse
 [MODULE::ldb_rootdse]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = rootdse_module_init
 OBJ_FILES = \
 		rootdse.o
@@ -60,7 +60,7 @@
 ################################################
 # Start MODULE ldb_password_hash
 [MODULE::ldb_password_hash]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = password_hash_module_init
 OBJ_FILES = \
 		password_hash.o
@@ -73,7 +73,7 @@
 ################################################
 # Start MODULE ldb_cludge_acl
 [MODULE::ldb_kludge_acl]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = ldb_kludge_acl_init
 OBJ_FILES = \
 		kludge_acl.o
@@ -86,7 +86,7 @@
 ################################################
 # Start MODULE ldb_extended_dn
 [MODULE::ldb_extended_dn]
-SUBSYSTEM = ldb
+SUBSYSTEM = samdb
 INIT_FUNCTION = ldb_extended_dn_init
 OBJ_FILES = \
 		extended_dn.o
Index: nbt_server/wins/winsserver.c
===================================================================
--- nbt_server/wins/winsserver.c	(revision 14869)
+++ nbt_server/wins/winsserver.c	(working copy)
@@ -830,6 +830,8 @@
 
 }
 
+int wins_ldb_module_init(void);
+
 /*
   startup the WINS server, if configured
 */
@@ -859,5 +861,7 @@
 
 	irpc_add_name(nbtsrv->task->msg_ctx, "wins_server");
 
+	wins_ldb_module_init();
+
 	return NT_STATUS_OK;
 }
Index: nbt_server/config.mk
===================================================================
--- nbt_server/config.mk	(revision 14869)
+++ nbt_server/config.mk	(working copy)
@@ -13,28 +13,17 @@
 #######################
 
 #######################
-# Start MODULE ldb_wins_ldb
-[MODULE::ldb_wins_ldb]
-SUBSYSTEM = ldb
-INIT_FUNCTION = wins_ldb_module_init
-OBJ_FILES = \
-		wins/wins_ldb.o
-REQUIRED_SUBSYSTEMS = \
-		LIBNETIF
-# End MODULE ldb_wins_ldb
-#######################
-
-#######################
 # Start SUBSYSTEM NBTD_WINS
 [SUBSYSTEM::NBTD_WINS]
 OBJ_FILES = \
 		wins/winsserver.o \
 		wins/winsclient.o \
 		wins/winswack.o \
-		wins/wins_dns_proxy.o
+		wins/wins_dns_proxy.o \
+		wins/wins_ldb.o
 PRIVATE_PROTO_HEADER = wins/winsserver_proto.h
 REQUIRED_SUBSYSTEMS = \
-		LIBCLI_NBT WINSDB
+		LIBCLI_NBT WINSDB LIBNETIF
 # End SUBSYSTEM NBTD_WINS
 #######################
 


More information about the samba-technical mailing list