diff options
-rw-r--r-- | packaging/Fedora/samba4.spec | 23 | ||||
-rw-r--r-- | source4/Makefile | 2 | ||||
-rw-r--r-- | source4/auth/ntlm/config.mk | 1 | ||||
-rw-r--r-- | source4/build/smb_build/input.pm | 1 | ||||
-rw-r--r-- | source4/build/smb_build/main.pl | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/config.mk | 27 | ||||
-rw-r--r-- | source4/lib/events/config.mk | 2 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb.c | 147 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_modules.c | 214 | ||||
-rw-r--r-- | source4/lib/ldb/config.mk | 3 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_ildap/config.mk | 2 | ||||
-rw-r--r-- | source4/lib/talloc/config.mk | 2 | ||||
-rw-r--r-- | source4/nbt_server/config.mk | 1 |
13 files changed, 225 insertions, 204 deletions
diff --git a/packaging/Fedora/samba4.spec b/packaging/Fedora/samba4.spec index 58af9480d9..567d89bd5d 100644 --- a/packaging/Fedora/samba4.spec +++ b/packaging/Fedora/samba4.spec @@ -1,5 +1,5 @@ -%define main_release 1 -%define alpha_version 4 +%define main_release 2 +%define alpha_version 5 %define samba_version 4.0.0alpha%{alpha_version} %define tarball_name samba-4.0.0alpha%{alpha_version} @@ -122,8 +122,6 @@ domains and to use Windows user and group accounts on Linux. #%setup -q # copy Red Hat specific scripts -mkdir packaging/Fedora -cp %{SOURCE5} packaging/Fedora/ # Upstream patches #(none) @@ -162,7 +160,11 @@ rm -rf $RPM_BUILD_ROOT cd source #Don't call 'make install' as we want to call out to the PIDL install manually -make installbin installdat installswat installmisc installlib installheader installpc installplugins installpython DESTDIR=%{buildroot} +make install DESTDIR=%{buildroot} + +#Undo the PIDL install, we want to try again with the right options +rm -rf $RPM_BUILD_ROOT/%{_libdir}/perl5 +rm -rf $RPM_BUILD_ROOT/%{_datadir}/perl5 #Install PIDL ( cd pidl && make install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT ) @@ -216,13 +218,15 @@ rm $RPM_BUILD_ROOT/%{_bindir}/setnttoken rm $RPM_BUILD_ROOT/%{_bindir}/getntacl rm $RPM_BUILD_ROOT/%{_datadir}/samba/js/base.js +#This makes the right links, as rpmlint requires that the +#ldconfig-created links be recorded in the RPM. /sbin/ldconfig -N -n $RPM_BUILD_ROOT/%{_libdir} #Fix up permission on perl install %{_fixperms} $RPM_BUILD_ROOT/%{perl_vendorlib} #Fix up permissions in source tree, for debuginfo -find -type f | xargs chmod -x +find source/heimdal -type f | xargs chmod -x %clean rm -rf $RPM_BUILD_ROOT @@ -270,7 +274,8 @@ exit 0 %dir %{_datadir}/samba %{_datadir}/samba/*.dat %{_libdir}/*.so.* -%{_libdir}/samba +#Only needed if Samba's build produces plugins +#%{_libdir}/samba %dir %{_sysconfdir}/%{name} #Need to mark this as being owned by Samba, but it is normally created #by the provision script, which runs best if there is no existing @@ -348,5 +353,9 @@ exit 0 %doc WHATSNEW.txt %changelog +* Mon Jun 30 2008 Andrew Bartlett <abartlet@samba.org> - 0:4.0.0-0.2.alpha5.fc9 +- Update per review feedback +- Update for alpha5 + * Thu Jun 26 2008 Andrew Bartlett <abartlet@samba.org> - 0:4.0.0-0.1.alpha4.fc9 - Rework Fedora's Samba 3.2.0-1.rc2.16 spec file for Samba4 diff --git a/source4/Makefile b/source4/Makefile index e43ccf7731..93c6f4575d 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -178,7 +178,7 @@ showflags:: # The permissions to give the executables INSTALLPERMS = 0755 -install:: showlayout everything installbin installdat installswat installmisc \ +install:: showlayout everything installbin installsbin installdat installswat installmisc \ installlib installheader installpc installplugins # DESTDIR is used here to prevent packagers wasting their time diff --git a/source4/auth/ntlm/config.mk b/source4/auth/ntlm/config.mk index f31c2b7279..4792a26bfd 100644 --- a/source4/auth/ntlm/config.mk +++ b/source4/auth/ntlm/config.mk @@ -34,7 +34,6 @@ auth_anonymous_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_anonymous.o) INIT_FUNCTION = auth_server_init SUBSYSTEM = auth PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_SMB -OUTPUT_TYPE = SHARED_LIBRARY # End MODULE auth_server ####################### diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm index 53a051a3c7..1696a364b2 100644 --- a/source4/build/smb_build/input.pm +++ b/source4/build/smb_build/input.pm @@ -175,6 +175,7 @@ sub add_implicit($$) $INPUT->{$n}->{LDFLAGS} = ["\$(".uc($n)."_LDFLAGS)"]; $INPUT->{$n}->{CFLAGS} = ["\$(".uc($n)."_CFLAGS)"]; $INPUT->{$n}->{CPPFLAGS} = ["\$(".uc($n)."_CPPFLAGS)"]; + $INPUT->{$n}->{ENABLE} = "YES"; } sub calc_unique_deps($$$$$$$$) diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl index 88289af26d..f8a0cb004f 100644 --- a/source4/build/smb_build/main.pl +++ b/source4/build/smb_build/main.pl @@ -32,9 +32,9 @@ my $subsys_output_type = ["MERGED_OBJ"]; my $library_output_type; if ($config::config{USESHARED} eq "true") { - $library_output_type = ["SHARED_LIBRARY", "STATIC_LIBRARY"]; + $library_output_type = ["SHARED_LIBRARY", "MERGED_OBJ"]; } else { - $library_output_type = ["STATIC_LIBRARY"]; + $library_output_type = ["MERGED_OBJ"]; push (@$library_output_type, "SHARED_LIBRARY") if ($config::config{BLDSHARED} eq "true") } diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk index d8dc0516f6..830f7c9fa1 100644 --- a/source4/dsdb/samdb/ldb_modules/config.mk +++ b/source4/dsdb/samdb/ldb_modules/config.mk @@ -2,7 +2,6 @@ # Start MODULE ldb_objectguid [MODULE::ldb_objectguid] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR NDR_MISC INIT_FUNCTION = LDB_MODULE(objectguid) # End MODULE ldb_objectguid @@ -14,7 +13,6 @@ ldb_objectguid_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/objectguid.o # Start MODULE ldb_repl_meta_data [MODULE::ldb_repl_meta_data] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS \ LIBNDR NDR_MISC NDR_DRSUAPI \ NDR_DRSBLOBS LIBNDR @@ -29,7 +27,6 @@ ldb_repl_meta_data_OBJ_FILES = \ # Start MODULE ldb_dsdb_cache [MODULE::ldb_dsdb_cache] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS INIT_FUNCTION = LDB_MODULE(dsdb_cache) # End MODULE ldb_dsdb_cache @@ -42,7 +39,6 @@ ldb_dsdb_cache_OBJ_FILES = \ # Start MODULE ldb_schema_fsmo [MODULE::ldb_schema_fsmo] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS INIT_FUNCTION = LDB_MODULE(schema_fsmo) # End MODULE ldb_schema_fsmo @@ -55,7 +51,6 @@ ldb_schema_fsmo_OBJ_FILES = \ # Start MODULE ldb_naming_fsmo [MODULE::ldb_naming_fsmo] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS INIT_FUNCTION = LDB_MODULE(naming_fsmo) # End MODULE ldb_naming_fsmo @@ -68,7 +63,6 @@ ldb_naming_fsmo_OBJ_FILES = \ # Start MODULE ldb_pdc_fsmo [MODULE::ldb_pdc_fsmo] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS INIT_FUNCTION = LDB_MODULE(pdc_fsmo) # End MODULE ldb_pdc_fsmo @@ -81,7 +75,6 @@ ldb_pdc_fsmo_OBJ_FILES = \ # Start MODULE ldb_samldb [MODULE::ldb_samldb] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LDAP_ENCODE NDR_MISC SAMDB INIT_FUNCTION = LDB_MODULE(samldb) # @@ -95,7 +88,6 @@ ldb_samldb_OBJ_FILES = \ # Start MODULE ldb_samba3sam [MODULE::ldb_samba3sam] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY INIT_FUNCTION = LDB_MODULE(samba3sam) PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS SMBPASSWD \ NSS_WRAPPER LIBSECURITY NDR_SECURITY @@ -109,8 +101,7 @@ ldb_samba3sam_OBJ_FILES = \ # Start MODULE ldb_simple_ldap_map [MODULE::ldb_simple_ldap_map] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY -INIT_FUNCTION = LDB_MODULE(simple_ldap_map) +INIT_FUNCTION = LDB_MODULE(entryuuid),LDB_MODULE(nsuniqueid) PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR NDR_MISC ENABLE = YES ALIASES = entryuuid nsuniqueid @@ -137,7 +128,6 @@ ldb_simple_ldap_map_OBJ_FILES = \ [MODULE::ldb_rootdse] SUBSYSTEM = LIBLDB PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS SAMDB -OUTPUT_TYPE = SHARED_LIBRARY INIT_FUNCTION = LDB_MODULE(rootdse) # End MODULE ldb_rootdse ################################################ @@ -148,7 +138,6 @@ ldb_rootdse_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/rootdse.o # Start MODULE ldb_password_hash [MODULE::ldb_password_hash] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY INIT_FUNCTION = LDB_MODULE(password_hash) PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS SAMDB LDAP_ENCODE \ LIBCLI_AUTH NDR_DRSBLOBS KERBEROS \ @@ -162,7 +151,6 @@ ldb_password_hash_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/password_hash.o # Start MODULE ldb_local_password [MODULE::ldb_local_password] PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR SAMDB -OUTPUT_TYPE = SHARED_LIBRARY SUBSYSTEM = LIBLDB INIT_FUNCTION = LDB_MODULE(local_password) # End MODULE ldb_local_password @@ -174,7 +162,6 @@ ldb_local_password_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/local_password.o # Start MODULE ldb_kludge_acl [MODULE::ldb_kludge_acl] PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBSECURITY SAMDB -OUTPUT_TYPE = SHARED_LIBRARY SUBSYSTEM = LIBLDB INIT_FUNCTION = LDB_MODULE(kludge_acl) @@ -187,7 +174,6 @@ ldb_kludge_acl_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/kludge_acl.o # Start MODULE ldb_extended_dn [MODULE::ldb_extended_dn] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR LIBSECURITY SAMDB INIT_FUNCTION = LDB_MODULE(extended_dn) # End MODULE ldb_extended_dn @@ -199,7 +185,6 @@ ldb_extended_dn_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/extended_dn.o # Start MODULE ldb_show_deleted [MODULE::ldb_show_deleted] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS INIT_FUNCTION = LDB_MODULE(show_deleted) # End MODULE ldb_show_deleted @@ -211,7 +196,6 @@ ldb_show_deleted_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/show_deleted.o # Start MODULE ldb_partition [MODULE::ldb_partition] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS SAMDB INIT_FUNCTION = LDB_MODULE(partition) # End MODULE ldb_partition @@ -223,7 +207,6 @@ ldb_partition_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/partition.o # Start MODULE ldb_schema [MODULE::ldb_schema] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBLDB INIT_FUNCTION = LDB_MODULE(schema) # End MODULE ldb_schema @@ -235,10 +218,9 @@ ldb_schema_OBJ_FILES = $(addprefix $(dsdbsrcdir)/samdb/ldb_modules/, schema.o sc # Start MODULE ldb_update_kt [MODULE::ldb_update_keytab] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS CREDENTIALS #Also depends on credentials, but that would loop -INIT_FUNCTION = LDB_MODULE(update_kt) +INIT_FUNCTION = LDB_MODULE(update_keytab) # End MODULE ldb_update_kt ################################################ @@ -248,7 +230,6 @@ ldb_update_keytab_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/update_keytab.o # Start MODULE ldb_objectclass [MODULE::ldb_objectclass] INIT_FUNCTION = LDB_MODULE(objectclass) -OUTPUT_TYPE = SHARED_LIBRARY CFLAGS = -Ilib/ldb/include PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBSECURITY NDR_SECURITY SAMDB SUBSYSTEM = LIBLDB @@ -286,7 +267,6 @@ ldb_subtree_delete_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/subtree_delete.o [MODULE::ldb_linked_attributes] INIT_FUNCTION = LDB_MODULE(linked_attributes) CFLAGS = -Ilib/ldb/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS SAMDB SUBSYSTEM = LIBLDB # End MODULE ldb_linked_attributes @@ -311,7 +291,6 @@ ldb_ranged_results_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/ranged_results.o [MODULE::ldb_anr] INIT_FUNCTION = LDB_MODULE(anr) CFLAGS = -Ilib/ldb/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBSAMBA-UTIL SAMDB SUBSYSTEM = LIBLDB # End MODULE ldb_anr @@ -324,7 +303,6 @@ ldb_anr_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/anr.o [MODULE::ldb_normalise] INIT_FUNCTION = LDB_MODULE(normalise) CFLAGS = -Ilib/ldb/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBSAMBA-UTIL SAMDB SUBSYSTEM = LIBLDB # End MODULE ldb_normalise @@ -337,7 +315,6 @@ ldb_normalise_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/normalise.o [MODULE::ldb_instancetype] INIT_FUNCTION = LDB_MODULE(instancetype) CFLAGS = -Ilib/ldb/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBSAMBA-UTIL SAMDB SUBSYSTEM = LIBLDB # End MODULE ldb_instancetype diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index db70830295..127d964775 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -35,7 +35,7 @@ EVENTS_STANDARD_OBJ_FILES = $(libeventssrcdir)/events_standard.o # Start SUBSYSTEM LIBEVENTS [LIBRARY::LIBEVENTS] PUBLIC_DEPENDENCIES = LIBTALLOC -OUTPUT_TYPE = STATIC_LIBRARY +OUTPUT_TYPE = MERGED_OBJ CFLAGS = -Ilib/events # # End SUBSYSTEM LIBEVENTS diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index cac0a383d8..ce4796dee2 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -68,153 +68,6 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx) return ldb; } -static struct backends_list_entry { - struct ldb_backend_ops *ops; - struct backends_list_entry *prev, *next; -} *ldb_backends = NULL; - -#ifndef STATIC_LIBLDB_BACKENDS - -#ifdef HAVE_LDB_LDAP -#define LDAP_INIT &ldb_ldap_backend_ops, \ - &ldb_ldapi_backend_ops, \ - &ldb_ldaps_backend_ops, -#else -#define LDAP_INIT -#endif - -#ifdef HAVE_LDB_SQLITE3 -#define SQLITE3_INIT &ldb_sqlite3_backend_ops, -#else -#define SQLITE3_INIT -#endif - -#define STATIC_LIBLDB_BACKENDS \ - LDAP_INIT \ - SQLITE3_INIT \ - &ldb_tdb_backend_ops, \ - NULL -#endif - -const static struct ldb_backend_ops *builtin_backends[] = { - STATIC_LIBLDB_BACKENDS -}; - -static ldb_connect_fn ldb_find_backend(const char *url) -{ - struct backends_list_entry *backend; - int i; - - for (i = 0; builtin_backends[i]; i++) { - if (strncmp(builtin_backends[i]->name, url, - strlen(builtin_backends[i]->name)) == 0) - return builtin_backends[i]->connect_fn; - } - - for (backend = ldb_backends; backend; backend = backend->next) { - if (strncmp(backend->ops->name, url, - strlen(backend->ops->name)) == 0) { - return backend->ops->connect_fn; - } - } - - return NULL; -} - -/* - register a new ldb backend -*/ -int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) -{ - struct ldb_backend_ops *backend; - struct backends_list_entry *entry; - - backend = talloc(talloc_autofree_context(), struct ldb_backend_ops); - if (!backend) return LDB_ERR_OPERATIONS_ERROR; - - entry = talloc(talloc_autofree_context(), struct backends_list_entry); - if (!entry) { - talloc_free(backend); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (ldb_find_backend(url_prefix)) { - return LDB_SUCCESS; - } - - /* Maybe check for duplicity here later on? */ - - backend->name = talloc_strdup(backend, url_prefix); - backend->connect_fn = connectfn; - entry->ops = backend; - DLIST_ADD(ldb_backends, entry); - - return LDB_SUCCESS; -} - -/* - Return the ldb module form of a database. - The URL can either be one of the following forms - ldb://path - ldapi://path - - flags is made up of LDB_FLG_* - - the options are passed uninterpreted to the backend, and are - backend specific. - - This allows modules to get at only the backend module, for example where a - module may wish to direct certain requests at a particular backend. -*/ -int ldb_connect_backend(struct ldb_context *ldb, - const char *url, - const char *options[], - struct ldb_module **backend_module) -{ - int ret; - char *backend; - ldb_connect_fn fn; - - if (strchr(url, ':') != NULL) { - backend = talloc_strndup(ldb, url, strchr(url, ':')-url); - } else { - /* Default to tdb */ - backend = talloc_strdup(ldb, "tdb"); - } - - fn = ldb_find_backend(backend); - - if (fn == NULL) { - struct ldb_backend_ops *ops; - char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend); - if (symbol_name == NULL) { - return LDB_ERR_OPERATIONS_ERROR; - } - ops = ldb_dso_load_symbol(ldb, backend, symbol_name); - if (ops != NULL) { - fn = ops->connect_fn; - } - talloc_free(symbol_name); - } - - talloc_free(backend); - - if (fn == NULL) { - ldb_debug(ldb, LDB_DEBUG_FATAL, - "Unable to find backend for '%s'\n", url); - return LDB_ERR_OTHER; - } - - ret = fn(ldb, url, ldb->flags, options, backend_module); - - if (ret != LDB_SUCCESS) { - ldb_debug(ldb, LDB_DEBUG_ERROR, - "Failed to connect to '%s'\n", url); - return ret; - } - return ret; -} - /* try to autodetect a basedn if none specified. This fixes one of my pet hates about ldapsearch, which is that you have to get a long, diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index fbfb5e5322..4d69dc662e 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -120,36 +120,149 @@ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *m return m; } +static struct backends_list_entry { + struct ldb_backend_ops *ops; + struct backends_list_entry *prev, *next; +} *ldb_backends = NULL; + static struct ops_list_entry { const struct ldb_module_ops *ops; struct ops_list_entry *next; } *registered_modules = NULL; -#define LDB_MODULE(name) (&ldb_ ## name ## _module_ops) +static const struct ldb_builtins { + const struct ldb_backend_ops *backend_ops; + const struct ldb_module_ops *module_ops; +} builtins[]; -#ifndef STATIC_LIBLDB_MODULES +static ldb_connect_fn ldb_find_backend(const char *url) +{ + struct backends_list_entry *backend; + int i; -#define STATIC_LIBLDB_MODULES \ - LDB_MODULE(operational), \ - LDB_MODULE(rdn_name), \ - LDB_MODULE(paged_results), \ - LDB_MODULE(server_sort), \ - LDB_MODULE(asq), \ - NULL -#endif + for (i = 0; builtins[i].backend_ops || builtins[i].module_ops; i++) { + if (builtins[i].backend_ops == NULL) continue; -const static struct ldb_module_ops *builtin_modules[] = { - STATIC_LIBLDB_MODULES -}; + if (strncmp(builtins[i].backend_ops->name, url, + strlen(builtins[i].backend_ops->name)) == 0) { + return builtins[i].backend_ops->connect_fn; + } + } + + for (backend = ldb_backends; backend; backend = backend->next) { + if (strncmp(backend->ops->name, url, + strlen(backend->ops->name)) == 0) { + return backend->ops->connect_fn; + } + } + + return NULL; +} + +/* + register a new ldb backend +*/ +int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) +{ + struct ldb_backend_ops *backend; + struct backends_list_entry *entry; + + backend = talloc(talloc_autofree_context(), struct ldb_backend_ops); + if (!backend) return LDB_ERR_OPERATIONS_ERROR; + + entry = talloc(talloc_autofree_context(), struct backends_list_entry); + if (!entry) { + talloc_free(backend); + return LDB_ERR_OPERATIONS_ERROR; + } + + if (ldb_find_backend(url_prefix)) { + return LDB_SUCCESS; + } + + /* Maybe check for duplicity here later on? */ + + backend->name = talloc_strdup(backend, url_prefix); + backend->connect_fn = connectfn; + entry->ops = backend; + DLIST_ADD(ldb_backends, entry); + + return LDB_SUCCESS; +} + +/* + Return the ldb module form of a database. + The URL can either be one of the following forms + ldb://path + ldapi://path + + flags is made up of LDB_FLG_* + + the options are passed uninterpreted to the backend, and are + backend specific. + + This allows modules to get at only the backend module, for example where a + module may wish to direct certain requests at a particular backend. +*/ +int ldb_connect_backend(struct ldb_context *ldb, + const char *url, + const char *options[], + struct ldb_module **backend_module) +{ + int ret; + char *backend; + ldb_connect_fn fn; + + if (strchr(url, ':') != NULL) { + backend = talloc_strndup(ldb, url, strchr(url, ':')-url); + } else { + /* Default to tdb */ + backend = talloc_strdup(ldb, "tdb"); + } + + fn = ldb_find_backend(backend); + + if (fn == NULL) { + struct ldb_backend_ops *ops; + char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend); + if (symbol_name == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + ops = ldb_dso_load_symbol(ldb, backend, symbol_name); + if (ops != NULL) { + fn = ops->connect_fn; + } + talloc_free(symbol_name); + } + + talloc_free(backend); + + if (fn == NULL) { + ldb_debug(ldb, LDB_DEBUG_FATAL, + "Unable to find backend for '%s'\n", url); + return LDB_ERR_OTHER; + } + + ret = fn(ldb, url, ldb->flags, options, backend_module); + + if (ret != LDB_SUCCESS) { + ldb_debug(ldb, LDB_DEBUG_ERROR, + "Failed to connect to '%s'\n", url); + return ret; + } + return ret; +} static const struct ldb_module_ops *ldb_find_module_ops(const char *name) { struct ops_list_entry *e; int i; - for (i = 0; builtin_modules[i]; i++) { - if (strcmp(builtin_modules[i]->name, name) == 0) - return builtin_modules[i]; + for (i = 0; builtins[i].backend_ops || builtins[i].module_ops; i++) { + if (builtins[i].module_ops == NULL) continue; + + if (strcmp(builtins[i].module_ops->name, name) == 0) + return builtins[i].module_ops; } for (e = registered_modules; e; e = e->next) { @@ -441,3 +554,72 @@ int ldb_next_del_trans(struct ldb_module *module) FIND_OP(module, del_transaction); return module->ops->del_transaction(module); } + +#ifndef STATIC_LIBLDB_MODULES + +#ifdef HAVE_LDB_LDAP +#define LDAP_BACKEND LDB_BACKEND(ldap), LDB_BACKEND(ldapi), LDB_BACKEND(ldaps), +#else +#define LDAP_BACKEND +#endif + +#ifdef HAVE_LDB_SQLITE3 +#define SQLITE3_BACKEND LDB_BACKEND(sqlite3), +#else +#define SQLITE3_BACKEND +#endif + +#define STATIC_LIBLDB_MODULES \ + LDB_BACKEND(tdb), \ + LDAP_BACKEND \ + SQLITE3_BACKEND \ + LDB_MODULE(operational), \ + LDB_MODULE(rdn_name), \ + LDB_MODULE(paged_results), \ + LDB_MODULE(server_sort), \ + LDB_MODULE(asq), \ + NULL +#endif + +/* + * this is a bit hacked, as STATIC_LIBLDB_MODULES contains ',' + * between the elements and we want to autogenerate the + * extern struct declarations, so we do some hacks and let the + * ',' appear in an unused function prototype. + */ +#undef NULL +#define NULL LDB_MODULE(NULL), + +#define LDB_BACKEND(name) \ + int); \ + extern const struct ldb_backend_ops ldb_ ## name ## _backend_ops;\ + extern void ldb_noop ## name (int +#define LDB_MODULE(name) \ + int); \ + extern const struct ldb_module_ops ldb_ ## name ## _module_ops;\ + extern void ldb_noop ## name (int + +extern void ldb_start_noop(int, +STATIC_LIBLDB_MODULES +int); + +#undef NULL +#define NULL { \ + .backend_ops = (void *)0, \ + .module_ops = (void *)0 \ +} + +#undef LDB_BACKEND +#define LDB_BACKEND(name) { \ + .backend_ops = &ldb_ ## name ## _backend_ops, \ + .module_ops = (void *)0 \ +} +#undef LDB_MODULE +#define LDB_MODULE(name) { \ + .backend_ops = (void *)0, \ + .module_ops = &ldb_ ## name ## _module_ops \ +} + +static const struct ldb_builtins builtins[] = { + STATIC_LIBLDB_MODULES +}; diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk index 36a5870a3e..6821c058f2 100644 --- a/source4/lib/ldb/config.mk +++ b/source4/lib/ldb/config.mk @@ -92,6 +92,7 @@ ldb_skel_OBJ_FILES = $(ldbsrcdir)/modules/skel.o SUBSYSTEM = LIBLDB CFLAGS = -I$(ldbsrcdir)/include PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBEVENTS +INIT_FUNCTION = LDB_BACKEND(sqlite3) # End MODULE ldb_sqlite3 ################################################ @@ -104,6 +105,7 @@ SUBSYSTEM = LIBLDB CFLAGS = -I$(ldbsrcdir)/include -I$(ldbsrcdir)/ldb_tdb PRIVATE_DEPENDENCIES = \ LIBTDB LIBTALLOC LIBEVENTS +INIT_FUNCTION = LDB_BACKEND(tdb) # End MODULE ldb_tdb ################################################ @@ -114,7 +116,6 @@ ldb_tdb_OBJ_FILES = $(addprefix $(ldbsrcdir)/ldb_tdb/, ldb_tdb.o ldb_search.o ld # Start SUBSYSTEM ldb [LIBRARY::LIBLDB] CFLAGS = -I$(ldbsrcdir)/include -INIT_FUNCTION_TYPE = extern const struct ldb_module_ops PUBLIC_DEPENDENCIES = \ LIBTALLOC LIBEVENTS PRIVATE_DEPENDENCIES = \ diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk index 4247bd96b7..6a1ef8164c 100644 --- a/source4/lib/ldb/ldb_ildap/config.mk +++ b/source4/lib/ldb/ldb_ildap/config.mk @@ -3,8 +3,8 @@ [MODULE::ldb_ildap] SUBSYSTEM = LIBLDB CFLAGS = -I$(ldbsrcdir)/include -OUTPUT_TYPE = SHARED_LIBRARY PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP CREDENTIALS +INIT_FUNCTION = LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap) ALIASES = ldapi ldaps ldap # End MODULE ldb_ildap ################################################ diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk index 84848ae77a..c13e1b79ab 100644 --- a/source4/lib/talloc/config.mk +++ b/source4/lib/talloc/config.mk @@ -1,5 +1,5 @@ [LIBRARY::LIBTALLOC] -OUTPUT_TYPE = STATIC_LIBRARY +OUTPUT_TYPE = MERGED_OBJ CFLAGS = -Ilib/talloc LIBTALLOC_OBJ_FILES = lib/talloc/talloc.o diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index b17fd4ce52..1121bfc690 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -16,7 +16,6 @@ $(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WI # Start MODULE ldb_wins_ldb [MODULE::ldb_wins_ldb] SUBSYSTEM = LIBLDB -OUTPUT_TYPE = SHARED_LIBRARY INIT_FUNCTION = LDB_MODULE(wins_ldb) PRIVATE_DEPENDENCIES = \ LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL |