From 58d50a614f1b4a3fc6b60ad5f777d987263fe54f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Mar 2004 06:45:39 +0000 Subject: make a more recent snapshot of ldb available to interested people. Note that I decided to make it LGPL. ldb is not finished yet, but enough of it is there for people to get an idea of what it does, and quite a few simple tests work (This used to be commit dc6f41f9e777d37f883303ddef0d96840d80f78e) --- source4/lib/ldb/include/includes.h | 22 ++++ source4/lib/ldb/include/ldb.h | 204 ++++++++++++++++++++++++++++++++++++ source4/lib/ldb/include/ldb_parse.h | 53 ++++++++++ 3 files changed, 279 insertions(+) create mode 100644 source4/lib/ldb/include/includes.h create mode 100644 source4/lib/ldb/include/ldb.h create mode 100644 source4/lib/ldb/include/ldb_parse.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h new file mode 100644 index 0000000000..ea8540d330 --- /dev/null +++ b/source4/lib/ldb/include/includes.h @@ -0,0 +1,22 @@ +/* + a temporary includes file until I work on the ldb build system +*/ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include "ldb.h" +#include "ldb_parse.h" + +#define malloc_p(type) (type *)malloc(sizeof(type)) +#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) +#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) + +#include "tdb/tdb.h" +#include "proto.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h new file mode 100644 index 0000000000..35474d23c5 --- /dev/null +++ b/source4/lib/ldb/include/ldb.h @@ -0,0 +1,204 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb header + * + * Description: defines for base ldb API + * + * Author: Andrew Tridgell + */ + +/* + major restrictions as compared to normal LDAP: + + - no async calls. + - each record must have a unique key field + - the key must be representable as a NULL terminated C string and may not + contain a comma or braces + + major restrictions as compared to tdb: + + - no explicit locking calls + +*/ + + +/* + an individual lump of data in a result comes in this format. The + pointer will usually be to a UTF-8 string if the application is + sensible, but it can be to anything you like, including binary data + blobs of arbitrary size. +*/ +struct ldb_val { + unsigned int length; + void *data; +}; + +/* these flags are used in ldd_message_element.flags fields. The + LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify + whether attributes are being added, deleted or modified */ +#define LDB_FLAG_MOD_MASK 0x3 +#define LDB_FLAG_MOD_ADD 1 +#define LDB_FLAG_MOD_REPLACE 2 +#define LDB_FLAG_MOD_DELETE 3 + + +/* + results are given back as arrays of ldb_message_element +*/ +struct ldb_message_element { + unsigned int flags; + char *name; + struct ldb_val value; +}; + + +/* + a ldb_message represents all or part of a record. It can contain an arbitrary + number of elements. +*/ +struct ldb_message { + char *dn; + unsigned int num_elements; + struct ldb_message_element *elements; + void *private; /* private to the backend */ +}; + + +enum ldb_scope {LDB_SCOPE_DEFAULT=-1, + LDB_SCOPE_BASE=0, + LDB_SCOPE_ONELEVEL=1, + LDB_SCOPE_SUBTREE=2}; + +struct ldb_context; + +/* + the fuction type for the callback used in traversing the database +*/ +typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); + + +/* + these function pointers define the operations that a ldb backend must perform + they correspond exactly to the ldb_*() interface +*/ +struct ldb_backend_ops { + int (*close)(struct ldb_context *); + int (*search)(struct ldb_context *, const char *, enum ldb_scope, + const char *, const char *[], struct ldb_message ***); + int (*search_free)(struct ldb_context *, struct ldb_message **); + int (*add)(struct ldb_context *, const struct ldb_message *); + int (*modify)(struct ldb_context *, const struct ldb_message *); + int (*delete)(struct ldb_context *, const char *); + const char * (*errstring)(struct ldb_context *); +}; + +/* + every ldb connection is started by establishing a ldb_context +*/ +struct ldb_context { + /* a private pointer for the backend to use */ + void *private; + + /* the operations provided by the backend */ + const struct ldb_backend_ops *ops; +}; + + +#define LDB_FLG_RDONLY 1 + +/* + connect to 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 +*/ +struct ldb_context *ldb_connect(const char *url, unsigned int flags, + const char *options[]); + +/* + close the connection to the database +*/ +int ldb_close(struct ldb_context *ldb); + + +/* + search the database given a LDAP-like search expression + + return the number of records found, or -1 on error +*/ +int ldb_search(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + const char *expression, + const char *attrs[], struct ldb_message ***res); + +/* + free a set of messages returned by ldb_search +*/ +int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); + + +/* + add a record to the database. Will fail if a record with the given class and key + already exists +*/ +int ldb_add(struct ldb_context *ldb, + const struct ldb_message *message); + +/* + modify the specified attributes of a record +*/ +int ldb_modify(struct ldb_context *ldb, + const struct ldb_message *message); + +/* + delete a record from the database +*/ +int ldb_delete(struct ldb_context *ldb, const char *dn); + + +/* + return extended error information from the last call +*/ +const char *ldb_errstring(struct ldb_context *ldb); + +/* + ldif manipulation functions +*/ +int ldif_write(int (*fprintf_fn)(void *, const char *, ...), + void *private, + const struct ldb_message *msg); +void ldif_read_free(struct ldb_message *msg); +struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_message *ldif_read_file(FILE *f); +struct ldb_message *ldif_read_string(const char *s); +int ldif_write_file(FILE *f, const struct ldb_message *msg); diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h new file mode 100644 index 0000000000..c0d5806cc9 --- /dev/null +++ b/source4/lib/ldb/include/ldb_parse.h @@ -0,0 +1,53 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb expression parse header + * + * Description: structure for expression parsing + * + * Author: Andrew Tridgell + */ + + +enum ldb_parse_op {LDB_OP_SIMPLE, LDB_OP_AND, LDB_OP_OR, LDB_OP_NOT}; + +struct ldb_parse_tree { + enum ldb_parse_op operation; + union { + struct { + char *attr; + struct ldb_val value; + } simple; + struct { + unsigned int num_elements; + struct ldb_parse_tree **elements; + } list; + struct { + struct ldb_parse_tree *child; + } not; + } u; +}; -- cgit From 4258c7f27ff628b93e296fd0fc0f7a5a5bf2efeb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Mar 2004 06:51:44 +0000 Subject: building with Makefile.ldb now works (This used to be commit 12538cd2c650bacabd37f4d2ecd3ff3ffce87a00) --- source4/lib/ldb/include/proto.h | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 source4/lib/ldb/include/proto.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/proto.h b/source4/lib/ldb/include/proto.h new file mode 100644 index 0000000000..8690d96fee --- /dev/null +++ b/source4/lib/ldb/include/proto.h @@ -0,0 +1,126 @@ +#ifndef _PROTO_H_ +#define _PROTO_H_ + +/* This file is automatically generated with "make proto". DO NOT EDIT */ + + +/* The following definitions come from common/ldb.c */ + +struct ldb_context *ldb_connect(const char *url, unsigned int flags, + const char *options[]); +int ldb_close(struct ldb_context *ldb); +int ldb_search(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + const char *expression, + const char *attrs[], struct ldb_message ***res); +int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); +int ldb_add(struct ldb_context *ldb, + const struct ldb_message *message); +int ldb_modify(struct ldb_context *ldb, + const struct ldb_message *message); +int ldb_delete(struct ldb_context *ldb, const char *dn); +const char *ldb_errstring(struct ldb_context *ldb); + +/* The following definitions come from common/ldb_ldif.c */ + +char *ldb_base64_encode(const char *buf, int len); +int ldb_should_b64_encode(const struct ldb_val *val); +int ldif_write(int (*fprintf_fn)(void *, const char *, ...), + void *private, + const struct ldb_message *msg); +void ldif_read_free(struct ldb_message *msg); +struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_message *ldif_read_file(FILE *f); +struct ldb_message *ldif_read_string(const char *s); +int ldif_write_file(FILE *f, const struct ldb_message *msg); + +/* The following definitions come from common/ldb_parse.c */ + +struct ldb_parse_tree *ldb_parse_tree(const char *s); +void ldb_parse_tree_free(struct ldb_parse_tree *tree); + +/* The following definitions come from common/util.c */ + +void *realloc_array(void *ptr, size_t el_size, unsigned count); +int list_find(const void *needle, + const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn); + +/* The following definitions come from ldb_ldap/ldb_ldap.c */ + +struct ldb_context *lldb_connect(const char *url, + unsigned int flags, + const char *options[]); + +/* The following definitions come from ldb_tdb/ldb_index.c */ + +int ltdb_search_indexed(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char *attrs[], struct ldb_message ***res); +int ltdb_index_add(struct ldb_context *ldb, const struct ldb_message *msg); +int ltdb_index_del(struct ldb_context *ldb, const struct ldb_message *msg); + +/* The following definitions come from ldb_tdb/ldb_match.c */ + +int ldb_message_match(struct ldb_context *ldb, + struct ldb_message *msg, + struct ldb_parse_tree *tree, + const char *base, + enum ldb_scope scope); + +/* The following definitions come from ldb_tdb/ldb_pack.c */ + +int ltdb_pack_data(struct ldb_context *ctx, + const struct ldb_message *message, + struct TDB_DATA *data); +int ltdb_unpack_data(struct ldb_context *ctx, + const struct TDB_DATA *data, + struct ldb_message *message); + +/* The following definitions come from ldb_tdb/ldb_search.c */ + +int ldb_msg_find_attr(const struct ldb_message *msg, const char *attr); +int ltdb_has_wildcard(const struct ldb_val *val); +void ltdb_search_dn1_free(struct ldb_context *ldb, struct ldb_message *msg); +int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message *msg); +int ltdb_search_dn(struct ldb_context *ldb, char *dn, + const char *attrs[], struct ldb_message ***res); +int ltdb_add_attr_results(struct ldb_context *ldb, struct ldb_message *msg, + const char *attrs[], + unsigned int *count, + struct ldb_message ***res); +int ltdb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); +int ltdb_search(struct ldb_context *ldb, const char *base, + enum ldb_scope scope, const char *expression, + const char *attrs[], struct ldb_message ***res); + +/* The following definitions come from ldb_tdb/ldb_tdb.c */ + +struct TDB_DATA ltdb_key(const char *dn); +int ltdb_store(struct ldb_context *ldb, const struct ldb_message *msg, int flgs); +int ltdb_delete_noindex(struct ldb_context *ldb, const char *dn); +struct ldb_context *ltdb_connect(const char *url, + unsigned int flags, + const char *options[]); + +/* The following definitions come from ldb_tdb/ldbadd.c */ + + +/* The following definitions come from ldb_tdb/ldbdel.c */ + + +/* The following definitions come from ldb_tdb/ldbsearch.c */ + + +/* The following definitions come from tools/ldbadd.c */ + + +/* The following definitions come from tools/ldbdel.c */ + + +/* The following definitions come from tools/ldbsearch.c */ + + +#endif /* _PROTO_H_ */ -- cgit From ee44733f94864fb0a1ae15d48e3335c0705a82ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Apr 2004 12:29:21 +0000 Subject: added the rest of the ldb_modify() code, which required a fairly large change in the ldb API. The API is now much closer to LDAP. (This used to be commit e9e85c464411c561c5073d262a2e3533fec175ca) --- source4/lib/ldb/include/ldb.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 35474d23c5..12064bbf75 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -73,7 +73,8 @@ struct ldb_val { struct ldb_message_element { unsigned int flags; char *name; - struct ldb_val value; + unsigned int num_values; + struct ldb_val *values; }; @@ -88,6 +89,20 @@ struct ldb_message { void *private; /* private to the backend */ }; +enum ldb_changetype { + LDB_CHANGETYPE_NONE=0, + LDB_CHANGETYPE_ADD, + LDB_CHANGETYPE_DELETE, + LDB_CHANGETYPE_MODIFY +}; + +/* + a ldif record - from ldif_read +*/ +struct ldb_ldif { + enum ldb_changetype changetype; + struct ldb_message msg; +}; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, LDB_SCOPE_BASE=0, @@ -196,9 +211,9 @@ const char *ldb_errstring(struct ldb_context *ldb); */ int ldif_write(int (*fprintf_fn)(void *, const char *, ...), void *private, - const struct ldb_message *msg); -void ldif_read_free(struct ldb_message *msg); -struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); -struct ldb_message *ldif_read_file(FILE *f); -struct ldb_message *ldif_read_string(const char *s); -int ldif_write_file(FILE *f, const struct ldb_message *msg); + const struct ldb_ldif *ldif); +void ldif_read_free(struct ldb_ldif *); +struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_ldif *ldif_read_file(FILE *f); +struct ldb_ldif *ldif_read_string(const char *s); +int ldif_write_file(FILE *f, const struct ldb_ldif *msg); -- cgit From aebfb3b9f415d3c1f6b2a39aee27b072d48893cb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 Apr 2004 22:39:47 +0000 Subject: r128: Another registry update. Changes: - Start with the LDB backend - The API is now more windows-like, which should make it easier to use in rpc_server - Added a GTK+ front-end - Added some more IDL More updates will follow, especially in the RPC field.. (This used to be commit 3adffa021779b26047a20f16a3c0b53d74751560) --- source4/lib/ldb/include/proto.h | 126 ---------------------------------------- 1 file changed, 126 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/proto.h b/source4/lib/ldb/include/proto.h index 8690d96fee..e69de29bb2 100644 --- a/source4/lib/ldb/include/proto.h +++ b/source4/lib/ldb/include/proto.h @@ -1,126 +0,0 @@ -#ifndef _PROTO_H_ -#define _PROTO_H_ - -/* This file is automatically generated with "make proto". DO NOT EDIT */ - - -/* The following definitions come from common/ldb.c */ - -struct ldb_context *ldb_connect(const char *url, unsigned int flags, - const char *options[]); -int ldb_close(struct ldb_context *ldb); -int ldb_search(struct ldb_context *ldb, - const char *base, - enum ldb_scope scope, - const char *expression, - const char *attrs[], struct ldb_message ***res); -int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); -int ldb_add(struct ldb_context *ldb, - const struct ldb_message *message); -int ldb_modify(struct ldb_context *ldb, - const struct ldb_message *message); -int ldb_delete(struct ldb_context *ldb, const char *dn); -const char *ldb_errstring(struct ldb_context *ldb); - -/* The following definitions come from common/ldb_ldif.c */ - -char *ldb_base64_encode(const char *buf, int len); -int ldb_should_b64_encode(const struct ldb_val *val); -int ldif_write(int (*fprintf_fn)(void *, const char *, ...), - void *private, - const struct ldb_message *msg); -void ldif_read_free(struct ldb_message *msg); -struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); -struct ldb_message *ldif_read_file(FILE *f); -struct ldb_message *ldif_read_string(const char *s); -int ldif_write_file(FILE *f, const struct ldb_message *msg); - -/* The following definitions come from common/ldb_parse.c */ - -struct ldb_parse_tree *ldb_parse_tree(const char *s); -void ldb_parse_tree_free(struct ldb_parse_tree *tree); - -/* The following definitions come from common/util.c */ - -void *realloc_array(void *ptr, size_t el_size, unsigned count); -int list_find(const void *needle, - const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn); - -/* The following definitions come from ldb_ldap/ldb_ldap.c */ - -struct ldb_context *lldb_connect(const char *url, - unsigned int flags, - const char *options[]); - -/* The following definitions come from ldb_tdb/ldb_index.c */ - -int ltdb_search_indexed(struct ldb_context *ldb, - const char *base, - enum ldb_scope scope, - struct ldb_parse_tree *tree, - const char *attrs[], struct ldb_message ***res); -int ltdb_index_add(struct ldb_context *ldb, const struct ldb_message *msg); -int ltdb_index_del(struct ldb_context *ldb, const struct ldb_message *msg); - -/* The following definitions come from ldb_tdb/ldb_match.c */ - -int ldb_message_match(struct ldb_context *ldb, - struct ldb_message *msg, - struct ldb_parse_tree *tree, - const char *base, - enum ldb_scope scope); - -/* The following definitions come from ldb_tdb/ldb_pack.c */ - -int ltdb_pack_data(struct ldb_context *ctx, - const struct ldb_message *message, - struct TDB_DATA *data); -int ltdb_unpack_data(struct ldb_context *ctx, - const struct TDB_DATA *data, - struct ldb_message *message); - -/* The following definitions come from ldb_tdb/ldb_search.c */ - -int ldb_msg_find_attr(const struct ldb_message *msg, const char *attr); -int ltdb_has_wildcard(const struct ldb_val *val); -void ltdb_search_dn1_free(struct ldb_context *ldb, struct ldb_message *msg); -int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message *msg); -int ltdb_search_dn(struct ldb_context *ldb, char *dn, - const char *attrs[], struct ldb_message ***res); -int ltdb_add_attr_results(struct ldb_context *ldb, struct ldb_message *msg, - const char *attrs[], - unsigned int *count, - struct ldb_message ***res); -int ltdb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); -int ltdb_search(struct ldb_context *ldb, const char *base, - enum ldb_scope scope, const char *expression, - const char *attrs[], struct ldb_message ***res); - -/* The following definitions come from ldb_tdb/ldb_tdb.c */ - -struct TDB_DATA ltdb_key(const char *dn); -int ltdb_store(struct ldb_context *ldb, const struct ldb_message *msg, int flgs); -int ltdb_delete_noindex(struct ldb_context *ldb, const char *dn); -struct ldb_context *ltdb_connect(const char *url, - unsigned int flags, - const char *options[]); - -/* The following definitions come from ldb_tdb/ldbadd.c */ - - -/* The following definitions come from ldb_tdb/ldbdel.c */ - - -/* The following definitions come from ldb_tdb/ldbsearch.c */ - - -/* The following definitions come from tools/ldbadd.c */ - - -/* The following definitions come from tools/ldbdel.c */ - - -/* The following definitions come from tools/ldbsearch.c */ - - -#endif /* _PROTO_H_ */ -- cgit From 42889e5e1e276c8957cc666991364c6f0b6bdc79 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 9 Apr 2004 08:06:39 +0000 Subject: r134: - added ldb to the build of smbd - fixed build of the ldb registry backend (This used to be commit 0b66590330603efaa816fd2348c05a994a1580ef) --- source4/lib/ldb/include/proto.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 source4/lib/ldb/include/proto.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/proto.h b/source4/lib/ldb/include/proto.h deleted file mode 100644 index e69de29bb2..0000000000 -- cgit From ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Apr 2004 20:18:22 +0000 Subject: r152: a quick airport commit .... added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9) --- source4/lib/ldb/include/includes.h | 3 +++ source4/lib/ldb/include/ldb.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index ea8540d330..70ad1f3588 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -2,7 +2,9 @@ a temporary includes file until I work on the ldb build system */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include #include @@ -11,6 +13,7 @@ #include #include #include +#include #include "ldb.h" #include "ldb_parse.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 12064bbf75..dc1b1d7732 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - const char *attrs[], struct ldb_message ***res); + char * const attrs[], struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From 6411aa483f9233af098b4893ad67ebd2fd9d5868 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Apr 2004 07:05:28 +0000 Subject: r381: make the code more C++ friendly (This used to be commit 8acecc7f27e25ab876fffffe43ae75b5f77aff77) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dc1b1d7732..d010d8dd40 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -128,7 +128,7 @@ struct ldb_backend_ops { int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add)(struct ldb_context *, const struct ldb_message *); int (*modify)(struct ldb_context *, const struct ldb_message *); - int (*delete)(struct ldb_context *, const char *); + int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); }; @@ -137,7 +137,7 @@ struct ldb_backend_ops { */ struct ldb_context { /* a private pointer for the backend to use */ - void *private; + void *private_data; /* the operations provided by the backend */ const struct ldb_backend_ops *ops; -- cgit From b0b97592be312b3553ac31cc3f3cb994de06e506 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 28 Apr 2004 07:32:37 +0000 Subject: r382: More C++ friendliness fixes. (This used to be commit e96f3a2005cf6f4da2ecd4670a35eab1b4f250d0) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d010d8dd40..ef00cdf32c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -86,7 +86,7 @@ struct ldb_message { char *dn; unsigned int num_elements; struct ldb_message_element *elements; - void *private; /* private to the backend */ + void *private_data; /* private to the backend */ }; enum ldb_changetype { @@ -210,10 +210,10 @@ const char *ldb_errstring(struct ldb_context *ldb); ldif manipulation functions */ int ldif_write(int (*fprintf_fn)(void *, const char *, ...), - void *private, + void *private_data, const struct ldb_ldif *ldif); void ldif_read_free(struct ldb_ldif *); -struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); -- cgit From a00c266702ca81a3689996198590b5b69a967940 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Apr 2004 13:06:25 +0000 Subject: r387: more C++ friendly changes (This used to be commit ac0c525a8b8a05cc275fb9f4c1dcfd749604c85f) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index ef00cdf32c..6369ab683a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -126,8 +126,8 @@ struct ldb_backend_ops { int (*search)(struct ldb_context *, const char *, enum ldb_scope, const char *, const char *[], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); - int (*add)(struct ldb_context *, const struct ldb_message *); - int (*modify)(struct ldb_context *, const struct ldb_message *); + int (*add_record)(struct ldb_context *, const struct ldb_message *); + int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); }; -- cgit From 0dad5a34273bf5cadcfd4a36d69bdffbf69eb073 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 1 May 2004 09:45:56 +0000 Subject: r435: a major upgrade for ldb - added the ability to mark record attributes as being CASE_INSENSITIVE, WILDCARD or INTEGER. - added the ability to support objectclass subclasses, and to search by a parent class - added internal support for case insensitive versus case sensitive indexing (not UTF8 compliant yet) - cleaned up a number of const warnings - added a number of helper functions for fetching integers, strings and doubles - added a in-memory cache for important database properties, supported by a database sequence number - changed some variable names to avoid conflicts with C++ (This used to be commit f2bf06f25c2e6c744817711c7bedbd1d3b52f994) --- source4/lib/ldb/include/includes.h | 1 + source4/lib/ldb/include/ldb.h | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 70ad1f3588..485d7157b8 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "ldb.h" #include "ldb_parse.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6369ab683a..215671c98a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, const char *[], struct ldb_message ***); + const char *, char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -206,6 +206,11 @@ int ldb_delete(struct ldb_context *ldb, const char *dn); */ const char *ldb_errstring(struct ldb_context *ldb); +/* + casefold a string (should be UTF8, but at the moment it isn't) +*/ +char *ldb_casefold(const char *s); + /* ldif manipulation functions */ @@ -217,3 +222,4 @@ struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); + -- cgit From 78aa8f181469b24f7ad836c2b7b8629c33f9f6b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 May 2004 10:06:45 +0000 Subject: r444: - added the beginnings of a ldb test suite and benchmark - updated the test slapd config to use bdb and indexing (This used to be commit 7ad0858c060ee212a33434dc4be75e7a0cd1a0e3) --- source4/lib/ldb/include/includes.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 485d7157b8..7ee6876f48 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "ldb.h" #include "ldb_parse.h" -- cgit From 208e09747c242ab5bd59a658033db49efa8d8696 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 May 2004 14:51:26 +0000 Subject: r456: - added -i option to ldbsearch - fixed sorting bug in ldb index handing (This used to be commit cdd48e2b9b3ca6be5503eec401e09db162408ac8) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 215671c98a..c0521ecffa 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, char * const [], struct ldb_message ***); + const char *, const char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - char * const attrs[], struct ldb_message ***res); + const char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From 232bc1503fc0e3f85b4711f077d2566dc0f0c823 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 May 2004 04:27:29 +0000 Subject: r490: - expanded the test suite to test modify and delete operations - made yet another attempt to make ldb const clean. - "make test" now runs both the tdb and ldap backend tests, and run the ldbtest utility with and without indexing - added prototypes in ldb.h for ldb_msg_*() public functions (This used to be commit 01e87406768cb5a98ac8530a2f361a4987a36cd3) --- source4/lib/ldb/include/ldb.h | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c0521ecffa..cee72c3c21 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); + const char *, char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - const char * const *attrs, struct ldb_message ***res); + char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search @@ -223,3 +223,44 @@ struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); + +/* useful functions for ldb_message structure manipulation */ + +/* find an element within an message */ +struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, + const char *attr_name); + +/* compare two ldb_val values - return 0 on match */ +int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2); + +/* find a value within an ldb_message_element */ +struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, + struct ldb_val *val); + +/* add a new empty element to a ldb_message */ +int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); + +/* add a element to a ldb_message */ +int ldb_msg_add(struct ldb_message *msg, + const struct ldb_message_element *el, + int flags); + +/* compare two message elements - return 0 on match */ +int ldb_msg_element_compare(struct ldb_message_element *el1, + struct ldb_message_element *el2); + +/* find elements in a message and convert to a specific type, with + a give default value if not found. Assumes that elements are + single valued */ +int ldb_msg_find_int(const struct ldb_message *msg, + const char *attr_name, + int default_value); +unsigned int ldb_msg_find_uint(const struct ldb_message *msg, + const char *attr_name, + int default_value); +double ldb_msg_find_double(const struct ldb_message *msg, + const char *attr_name, + double default_value); +const char *ldb_msg_find_string(const struct ldb_message *msg, + const char *attr_name, + const char *default_value); -- cgit From d8ce7c6a2acbf371509a23775470e7614bcb6027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 04:40:15 +0000 Subject: r502: modified ldb to allow the use of an external pool memory allocator. The way to use this is to call ldb_set_alloc() with a function pointer to whatever memory allocator you like. It includes a context pointer to allow for pool based allocators. (This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34) --- source4/lib/ldb/include/includes.h | 6 ---- source4/lib/ldb/include/ldb.h | 71 +++++++++++++++++++++++++++++++------ source4/lib/ldb/include/ldb_parse.h | 4 +++ 3 files changed, 65 insertions(+), 16 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 7ee6876f48..bf61a983e0 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -18,11 +18,5 @@ #include #include #include "ldb.h" -#include "ldb_parse.h" - -#define malloc_p(type) (type *)malloc(sizeof(type)) -#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) -#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) - #include "tdb/tdb.h" #include "proto.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index cee72c3c21..852389d415 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -32,6 +32,9 @@ * Author: Andrew Tridgell */ +#ifndef _LDB_H_ +#define _LDB_H_ 1 + /* major restrictions as compared to normal LDAP: @@ -46,7 +49,6 @@ */ - /* an individual lump of data in a result comes in this format. The pointer will usually be to a UTF-8 string if the application is @@ -58,6 +60,9 @@ struct ldb_val { void *data; }; +#include "ldb_parse.h" + + /* these flags are used in ldd_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify whether attributes are being added, deleted or modified */ @@ -130,8 +135,24 @@ struct ldb_backend_ops { int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); + + /* this is called when the alloc ops changes to ensure we + don't have any old allocated data in the context */ + void (*cache_free)(struct ldb_context *); }; + +/* + the user can optionally supply a allocator function. It is presumed + it will act like a modern realloc(), with a context ptr to allow + for pool allocators +*/ +struct ldb_alloc_ops { + void *(*alloc)(void *context, void *ptr, size_t size); + void *context; +}; + + /* every ldb connection is started by establishing a ldb_context */ @@ -141,6 +162,9 @@ struct ldb_context { /* the operations provided by the backend */ const struct ldb_backend_ops *ops; + + /* memory allocation info */ + struct ldb_alloc_ops alloc_ops; }; @@ -209,19 +233,21 @@ const char *ldb_errstring(struct ldb_context *ldb); /* casefold a string (should be UTF8, but at the moment it isn't) */ -char *ldb_casefold(const char *s); +char *ldb_casefold(struct ldb_context *ldb, const char *s); /* ldif manipulation functions */ -int ldif_write(int (*fprintf_fn)(void *, const char *, ...), +int ldif_write(struct ldb_context *ldb, + int (*fprintf_fn)(void *, const char *, ...), void *private_data, const struct ldb_ldif *ldif); -void ldif_read_free(struct ldb_ldif *); -struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); -struct ldb_ldif *ldif_read_file(FILE *f); -struct ldb_ldif *ldif_read_string(const char *s); -int ldif_write_file(FILE *f, const struct ldb_ldif *msg); +void ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); +struct ldb_ldif *ldif_read(struct ldb_context *ldb, + int (*fgetc_fn)(void *), void *private_data); +struct ldb_ldif *ldif_read_file(struct ldb_context *ldb, FILE *f); +struct ldb_ldif *ldif_read_string(struct ldb_context *ldb, const char *s); +int ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); /* useful functions for ldb_message structure manipulation */ @@ -238,10 +264,12 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); /* add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_context *ldb, + struct ldb_message *msg, const char *attr_name, int flags); /* add a element to a ldb_message */ -int ldb_msg_add(struct ldb_message *msg, +int ldb_msg_add(struct ldb_context *ldb, + struct ldb_message *msg, const struct ldb_message_element *el, int flags); @@ -264,3 +292,26 @@ double ldb_msg_find_double(const struct ldb_message *msg, const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); + + +/* + this allows the user to choose their own allocation function + the allocation function should behave like a modern realloc() + function, which means that: + malloc(size) == alloc(context, NULL, size) + free(ptr) == alloc(context, ptr, 0) + realloc(ptr, size) == alloc(context, ptr, size) + The context argument is provided to allow for pool based allocators, + which often take a context argument +*/ +int ldb_set_alloc(struct ldb_context *ldb, + void *(*alloc)(void *context, void *ptr, size_t size), + void *context); + + +/* these are used as type safe versions of the ldb allocation functions */ +#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) +#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) +#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) + +#endif diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index c0d5806cc9..930799d7b6 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -32,6 +32,8 @@ * Author: Andrew Tridgell */ +#ifndef _LDB_PARSE_H +#define _LDB_PARSE_H 1 enum ldb_parse_op {LDB_OP_SIMPLE, LDB_OP_AND, LDB_OP_OR, LDB_OP_NOT}; @@ -51,3 +53,5 @@ struct ldb_parse_tree { } not; } u; }; + +#endif -- cgit From 68293565de0b799dcc51e001dabf53adf88ee7ad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 09:55:05 +0000 Subject: r513: added a generic ldb debug system to allow the Samba debug functions to be cleanly interfaced to ldb (This used to be commit 74b89d5f960d6b936751e3f057b4540eb80b79cd) --- source4/lib/ldb/include/ldb.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 852389d415..adb6c31952 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -152,6 +152,21 @@ struct ldb_alloc_ops { void *context; }; +/* debugging uses one of the following levels */ +enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, + LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; + +/* + the user can optionally supply a debug function. The function + is based on the vfprintf() style of interface, but with the addition + of a severity level +*/ +struct ldb_debug_ops { + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap); + void *context; +}; + /* every ldb connection is started by establishing a ldb_context @@ -165,6 +180,9 @@ struct ldb_context { /* memory allocation info */ struct ldb_alloc_ops alloc_ops; + + /* memory allocation info */ + struct ldb_debug_ops debug_ops; }; @@ -308,6 +326,17 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(void *context, void *ptr, size_t size), void *context); +/* + this allows the user to set a debug function for error reporting +*/ +int ldb_set_debug(struct ldb_context *ldb, + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap), + void *context); + +/* this sets up debug to print messages on stderr */ +int ldb_set_debug_stderr(struct ldb_context *ldb); + /* these are used as type safe versions of the ldb allocation functions */ #define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -- cgit From 265023fafa463c742f89510879acb2a830de8ab9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 May 2004 23:54:41 +0000 Subject: r574: - another attempt at const cleanliness in ldb - fixed a problem with searching for values containing an '=' sign - fixed the semantics of attempting an attribute deletion on an attribute that doesn't exist. - added some more ldb_msg_*() utilities (This used to be commit 62b4ec367d170330d837b0f1fe5cd13205a53b59) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index adb6c31952..7215bf5705 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -129,7 +129,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, char * const [], struct ldb_message ***); + const char *, const char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -216,7 +216,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From f0a8f718ff474009300af6746fa0fbb61c649ea9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 20 May 2004 13:25:06 +0000 Subject: r792: - changed the ldb ldif_* functions to be in the ldb_ namespace - added better error reporting in ldbdel - fixed a bug in handling packing of records which contain elements with no values (it caused db corruption) - allow search with "dn" as target attribute (This used to be commit 36575396234e3d35dbd442c8f1ff54a17ae64e64) --- source4/lib/ldb/include/ldb.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7215bf5705..448d5607a8 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -60,9 +60,6 @@ struct ldb_val { void *data; }; -#include "ldb_parse.h" - - /* these flags are used in ldd_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify whether attributes are being added, deleted or modified */ @@ -256,16 +253,16 @@ char *ldb_casefold(struct ldb_context *ldb, const char *s); /* ldif manipulation functions */ -int ldif_write(struct ldb_context *ldb, - int (*fprintf_fn)(void *, const char *, ...), - void *private_data, - const struct ldb_ldif *ldif); -void ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); -struct ldb_ldif *ldif_read(struct ldb_context *ldb, - int (*fgetc_fn)(void *), void *private_data); -struct ldb_ldif *ldif_read_file(struct ldb_context *ldb, FILE *f); -struct ldb_ldif *ldif_read_string(struct ldb_context *ldb, const char *s); -int ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); +int ldb_ldif_write(struct ldb_context *ldb, + int (*fprintf_fn)(void *, const char *, ...), + void *private_data, + const struct ldb_ldif *ldif); +void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); +struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, + int (*fgetc_fn)(void *), void *private_data); +struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); +struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); +int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); /* useful functions for ldb_message structure manipulation */ -- cgit From b553acce4b426e1a2e4fda3a9acbfbf41003154a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Jun 2004 01:30:27 +0000 Subject: r1018: fix a const and unsigned int problem in ldb (This used to be commit 3d52ca93731ad67c14ac42f627e3feb1a964b29a) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 448d5607a8..241f186991 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -300,7 +300,7 @@ int ldb_msg_find_int(const struct ldb_message *msg, int default_value); unsigned int ldb_msg_find_uint(const struct ldb_message *msg, const char *attr_name, - int default_value); + unsigned int default_value); double ldb_msg_find_double(const struct ldb_message *msg, const char *attr_name, double default_value); -- cgit From 8a01231a8bb03884c17c174f7d2cfea536da1130 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 7 Jun 2004 01:59:23 +0000 Subject: r1055: Standalone build fixes for ldb: - Various Makefile fixes - #include ldb still needs a proper build system though. (-: (This used to be commit 52e4fe8ce9142c4002263686c8043d94b37d7a9c) --- source4/lib/ldb/include/includes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index bf61a983e0..e55b494b98 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -6,6 +6,7 @@ #define _GNU_SOURCE #endif #include +#include #include #include #include @@ -18,5 +19,5 @@ #include #include #include "ldb.h" -#include "tdb/tdb.h" +#include "tdb.h" #include "proto.h" -- cgit From a2a97238f5ade51d7908803dee11d913531b7821 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 22 Sep 2004 02:03:34 +0000 Subject: r2484: allow ldb to build standalone again (This used to be commit 05601a4c6f7c7a019fcac8743e2e4775a498b26a) --- source4/lib/ldb/include/includes.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index e55b494b98..1d3ac2a50e 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -18,6 +18,13 @@ #include #include #include + + +#ifndef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a,b) +#endif + #include "ldb.h" #include "tdb.h" #include "proto.h" + -- cgit From 1429ed54f14055a1a9399452cb6cfc94f9451cf5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 3 Oct 2004 06:39:19 +0000 Subject: r2792: got rid of talloc_ldb_alloc() and instead created talloc_realloc_fn(), so talloc now doesn't contain any ldb specific functions. allow NULL to be passed to a couple more talloc() functions (This used to be commit 1246f80d806fb5f63cfbf3879de6d546384552a8) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 241f186991..4b1401f673 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -145,7 +145,7 @@ struct ldb_backend_ops { for pool allocators */ struct ldb_alloc_ops { - void *(*alloc)(void *context, void *ptr, size_t size); + void *(*alloc)(const void *context, void *ptr, size_t size); void *context; }; @@ -320,7 +320,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, which often take a context argument */ int ldb_set_alloc(struct ldb_context *ldb, - void *(*alloc)(void *context, void *ptr, size_t size), + void *(*alloc)(const void *context, void *ptr, size_t size), void *context); /* -- cgit From a9bd40549767c19207f3ec520a3e4346beeabef4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Oct 2004 19:28:02 +0000 Subject: r3093: - implment ldb_rename() and ldbrename - add tests for ldbrename - disable all tests which regenerate the index (this is broken for me...the process hangs, tridge we need to discuss that) - link only the needed stuff to the ldb tools - build ldbtest inside samba metze (This used to be commit 18552f4786c24e0019cc87726ef4c05365fe586e) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4b1401f673..3c78f12fb5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -2,6 +2,7 @@ ldb database library Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2004 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -30,6 +31,7 @@ * Description: defines for base ldb API * * Author: Andrew Tridgell + * Author: Stefan Metzmacher */ #ifndef _LDB_H_ @@ -131,6 +133,7 @@ struct ldb_backend_ops { int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); + int (*rename_record)(struct ldb_context *, const char *olddn, const char *newdn); const char * (*errstring)(struct ldb_context *); /* this is called when the alloc ops changes to ensure we @@ -234,6 +237,11 @@ int ldb_add(struct ldb_context *ldb, int ldb_modify(struct ldb_context *ldb, const struct ldb_message *message); +/* + rename a record in the database +*/ +int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn); + /* delete a record from the database */ -- cgit From 26c6b4c70bd85d8030a96651f2a255a4d48fcda1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 01:42:45 +0000 Subject: r3449: more include file reduction the ldb part isn't ideal, I will have to think of a better solution (This used to be commit 6b1f86aea8427a8e957b1aeb0ec2f507297f07cb) --- source4/lib/ldb/include/includes.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 1d3ac2a50e..44ff672266 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -28,3 +28,11 @@ #include "tdb.h" #include "proto.h" +#ifdef HAVE_INTPTR_T +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) +#else +#define discard_const(ptr) ((void *)(ptr)) +#endif +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + + -- cgit From 679e95db033fd11d17c1f1ac5e44f6cc4df2220e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Nov 2004 11:40:27 +0000 Subject: r3754: merge in ldb modules support from the tmp branch ldbPlugins (This used to be commit 71323f424b4561af1fdddd2358629049be3dad8c) --- source4/lib/ldb/include/ldb.h | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3c78f12fb5..6a06678e0e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -121,26 +121,39 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); +struct ldb_module_ops; + +/* basic module structure */ +struct ldb_module { + struct ldb_module *prev, *next; + struct ldb_context *ldb; + void *private_data; + const struct ldb_module_ops *ops; +}; + /* - these function pointers define the operations that a ldb backend must perform + these function pointers define the operations that a ldb module must perform they correspond exactly to the ldb_*() interface */ -struct ldb_backend_ops { - int (*close)(struct ldb_context *); - int (*search)(struct ldb_context *, const char *, enum ldb_scope, +struct ldb_module_ops { + const char *name; + int (*close)(struct ldb_module *); + int (*search)(struct ldb_module *, const char *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_context *, struct ldb_message **); - int (*add_record)(struct ldb_context *, const struct ldb_message *); - int (*modify_record)(struct ldb_context *, const struct ldb_message *); - int (*delete_record)(struct ldb_context *, const char *); - int (*rename_record)(struct ldb_context *, const char *olddn, const char *newdn); - const char * (*errstring)(struct ldb_context *); + int (*search_free)(struct ldb_module *, struct ldb_message **); + int (*add_record)(struct ldb_module *, const struct ldb_message *); + int (*modify_record)(struct ldb_module *, const struct ldb_message *); + int (*delete_record)(struct ldb_module *, const char *); + int (*rename_record)(struct ldb_module *, const char *, const char *); + const char * (*errstring)(struct ldb_module *); /* this is called when the alloc ops changes to ensure we don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_context *); + void (*cache_free)(struct ldb_module *); }; +/* the modules init function */ +typedef struct ldb_module *(*init_ldb_module_function)(void); /* the user can optionally supply a allocator function. It is presumed @@ -172,11 +185,8 @@ struct ldb_debug_ops { every ldb connection is started by establishing a ldb_context */ struct ldb_context { - /* a private pointer for the backend to use */ - void *private_data; - /* the operations provided by the backend */ - const struct ldb_backend_ops *ops; + struct ldb_module *modules; /* memory allocation info */ struct ldb_alloc_ops alloc_ops; -- cgit From 79ebe463e2aed9125c9086f6bff99adeef5e4b88 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Nov 2004 11:42:17 +0000 Subject: r3755: add missing files (This used to be commit 0b715b6ce21d23970d207d57e90133be17790d15) --- source4/lib/ldb/include/dlinklist.h | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 source4/lib/ldb/include/dlinklist.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h new file mode 100644 index 0000000000..40f7f0a0c7 --- /dev/null +++ b/source4/lib/ldb/include/dlinklist.h @@ -0,0 +1,93 @@ +/* + Unix SMB/CIFS implementation. + some simple double linked list macros + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* To use these macros you must have a structure containing a next and + prev pointer */ + + +/* hook into the front of the list */ +#define DLIST_ADD(list, p) \ +do { \ + if (!(list)) { \ + (list) = (p); \ + (p)->next = (p)->prev = NULL; \ + } else { \ + (list)->prev = (p); \ + (p)->next = (list); \ + (p)->prev = NULL; \ + (list) = (p); \ + }\ +} while (0) + +/* remove an element from a list - element doesn't have to be in list. */ +#define DLIST_REMOVE(list, p) \ +do { \ + if ((p) == (list)) { \ + (list) = (p)->next; \ + if (list) (list)->prev = NULL; \ + } else { \ + if ((p)->prev) (p)->prev->next = (p)->next; \ + if ((p)->next) (p)->next->prev = (p)->prev; \ + } \ + if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \ +} while (0) + +/* promote an element to the top of the list */ +#define DLIST_PROMOTE(list, p) \ +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD(list, p); \ +} while (0) + +/* hook into the end of the list - needs a tmp pointer */ +#define DLIST_ADD_END(list, p, type) \ +do { \ + if (!(list)) { \ + (list) = (p); \ + (p)->next = (p)->prev = NULL; \ + } else { \ + type tmp; \ + for (tmp = (list); tmp->next; tmp = tmp->next) ; \ + tmp->next = (p); \ + (p)->next = NULL; \ + (p)->prev = tmp; \ + } \ +} while (0) + +/* demote an element to the end of the list, needs a tmp pointer */ +#define DLIST_DEMOTE(list, p, tmp) \ +do { \ + DLIST_REMOVE(list, p); \ + DLIST_ADD_END(list, p, tmp); \ +} while (0) + +/* concatenate two lists - putting all elements of the 2nd list at the + end of the first list */ +#define DLIST_CONCATENATE(list1, list2, type) \ +do { \ + if (!(list1)) { \ + (list1) = (list2); \ + } else { \ + type tmp; \ + for (tmp = (list1); tmp->next; tmp = tmp->next) ; \ + tmp->next = (list2); \ + (list2)->prev = tmp; \ + } \ +} while (0) -- cgit From 8a18778286a16423d7d6e483fdb308a91e294efe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 09:00:52 +0000 Subject: r3783: - don't use make proto for ldb anymore - split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c) --- source4/lib/ldb/include/includes.h | 8 +-- source4/lib/ldb/include/ldb.h | 93 ++++++++++--------------- source4/lib/ldb/include/ldb_parse.h | 3 + source4/lib/ldb/include/ldb_private.h | 126 ++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+), 63 deletions(-) create mode 100644 source4/lib/ldb/include/ldb_private.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 44ff672266..4926e1524a 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -19,14 +19,8 @@ #include #include - -#ifndef _PRINTF_ATTRIBUTE -#define _PRINTF_ATTRIBUTE(a,b) -#endif - #include "ldb.h" -#include "tdb.h" -#include "proto.h" +#include "ldb_private.h" #ifdef HAVE_INTPTR_T #define discard_const(ptr) ((void *)((intptr_t)(ptr))) diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6a06678e0e..03d0cc7a3b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -121,39 +121,7 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); -struct ldb_module_ops; - -/* basic module structure */ -struct ldb_module { - struct ldb_module *prev, *next; - struct ldb_context *ldb; - void *private_data; - const struct ldb_module_ops *ops; -}; - -/* - these function pointers define the operations that a ldb module must perform - they correspond exactly to the ldb_*() interface -*/ -struct ldb_module_ops { - const char *name; - int (*close)(struct ldb_module *); - int (*search)(struct ldb_module *, const char *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_module *, struct ldb_message **); - int (*add_record)(struct ldb_module *, const struct ldb_message *); - int (*modify_record)(struct ldb_module *, const struct ldb_message *); - int (*delete_record)(struct ldb_module *, const char *); - int (*rename_record)(struct ldb_module *, const char *, const char *); - const char * (*errstring)(struct ldb_module *); - - /* this is called when the alloc ops changes to ensure we - don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_module *); -}; - -/* the modules init function */ -typedef struct ldb_module *(*init_ldb_module_function)(void); +struct ldb_module; /* the user can optionally supply a allocator function. It is presumed @@ -180,22 +148,6 @@ struct ldb_debug_ops { void *context; }; - -/* - every ldb connection is started by establishing a ldb_context -*/ -struct ldb_context { - /* the operations provided by the backend */ - struct ldb_module *modules; - - /* memory allocation info */ - struct ldb_alloc_ops alloc_ops; - - /* memory allocation info */ - struct ldb_debug_ops debug_ops; -}; - - #define LDB_FLG_RDONLY 1 /* @@ -285,6 +237,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif /* useful functions for ldb_message structure manipulation */ +int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_attr_cmp(const char *dn1, const char *dn2); + /* find an element within an message */ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); @@ -305,6 +260,12 @@ int ldb_msg_add(struct ldb_context *ldb, struct ldb_message *msg, const struct ldb_message_element *el, int flags); +int ldb_msg_add_value(struct ldb_context *ldb, + struct ldb_message *msg, + const char *attr_name, + struct ldb_val *val); +int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, + const char *attr_name, char *str); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, @@ -313,19 +274,27 @@ int ldb_msg_element_compare(struct ldb_message_element *el1, /* find elements in a message and convert to a specific type, with a give default value if not found. Assumes that elements are single valued */ +const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); int ldb_msg_find_int(const struct ldb_message *msg, const char *attr_name, int default_value); unsigned int ldb_msg_find_uint(const struct ldb_message *msg, const char *attr_name, unsigned int default_value); +int64_t ldb_msg_find_int64(const struct ldb_message *msg, + const char *attr_name, + int64_t default_value); +uint64_t ldb_msg_find_uint64(const struct ldb_message *msg, + const char *attr_name, + uint64_t default_value); double ldb_msg_find_double(const struct ldb_message *msg, const char *attr_name, double default_value); const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); - +struct ldb_val ldb_val_dup(struct ldb_context *ldb, + const struct ldb_val *v); /* this allows the user to choose their own allocation function @@ -341,6 +310,24 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(const void *context, void *ptr, size_t size), void *context); +/* these are used as type safe versions of the ldb allocation functions */ +#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) +#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) +#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) + +void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size); +void *ldb_malloc(struct ldb_context *ldb, size_t size); +void ldb_free(struct ldb_context *ldb, void *ptr); +void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen); +void *ldb_strdup(struct ldb_context *ldb, const char *str); +void *ldb_realloc_array(struct ldb_context *ldb, + void *ptr, size_t el_size, unsigned count); + +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif +int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + /* this allows the user to set a debug function for error reporting */ @@ -352,10 +339,4 @@ int ldb_set_debug(struct ldb_context *ldb, /* this sets up debug to print messages on stderr */ int ldb_set_debug_stderr(struct ldb_context *ldb); - -/* these are used as type safe versions of the ldb allocation functions */ -#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) -#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) - #endif diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index 930799d7b6..d9125d05ed 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -54,4 +54,7 @@ struct ldb_parse_tree { } u; }; +struct ldb_parse_tree *ldb_parse_tree(struct ldb_context *ldb, const char *s); +void ldb_parse_tree_free(struct ldb_context *ldb, struct ldb_parse_tree *tree); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h new file mode 100644 index 0000000000..dfd388b8c6 --- /dev/null +++ b/source4/lib/ldb/include/ldb_private.h @@ -0,0 +1,126 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2004 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb private header + * + * Description: defines internal ldb structures used by th esubsystem and modules + * + * Author: Andrew Tridgell + * Author: Stefan Metzmacher + */ + +#ifndef _LDB_PRIVATE_H_ +#define _LDB_PRIVATE_H_ 1 + +struct ldb_context; + +struct ldb_module_ops; + +/* basic module structure */ +struct ldb_module { + struct ldb_module *prev, *next; + struct ldb_context *ldb; + void *private_data; + const struct ldb_module_ops *ops; +}; + +/* + these function pointers define the operations that a ldb module must perform + they correspond exactly to the ldb_*() interface +*/ +struct ldb_module_ops { + const char *name; + int (*close)(struct ldb_module *); + int (*search)(struct ldb_module *, const char *, enum ldb_scope, + const char *, const char * const [], struct ldb_message ***); + int (*search_free)(struct ldb_module *, struct ldb_message **); + int (*add_record)(struct ldb_module *, const struct ldb_message *); + int (*modify_record)(struct ldb_module *, const struct ldb_message *); + int (*delete_record)(struct ldb_module *, const char *); + int (*rename_record)(struct ldb_module *, const char *, const char *); + const char * (*errstring)(struct ldb_module *); + + /* this is called when the alloc ops changes to ensure we + don't have any old allocated data in the context */ + void (*cache_free)(struct ldb_module *); +}; + +/* the modules init function */ +typedef struct ldb_module *(*ldb_module_init_function)(void); + +/* + every ldb connection is started by establishing a ldb_context +*/ +struct ldb_context { + /* the operations provided by the backend */ + struct ldb_module *modules; + + /* memory allocation info */ + struct ldb_alloc_ops alloc_ops; + + /* memory allocation info */ + struct ldb_debug_ops debug_ops; +}; + +/* The following definitions come from lib/ldb/common/ldb_modules.c */ + +int ldb_load_modules(struct ldb_context *ldb, const char *options[]); +int ldb_next_close(struct ldb_module *module); +int ldb_next_search(struct ldb_module *module, + const char *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, struct ldb_message ***res); +int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg); +int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); +int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); +int ldb_next_delete_record(struct ldb_module *module, const char *dn); +int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn); +const char *ldb_next_errstring(struct ldb_module *module); +void ldb_next_cache_free(struct ldb_module *module); + +/* The following definitions come from lib/ldb/common/util.c */ +int ldb_list_find(const void *needle, + const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn); + +/* The following definitions come from lib/ldb/common/ldb_debug.c */ +void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + +/* The following definitions come from lib/ldb/common/ldb_ldif.c */ +char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len); +int ldb_should_b64_encode(const struct ldb_val *val); + +struct ldb_context *ltdb_connect(const char *url, + unsigned int flags, + const char *options[]); +struct ldb_context *lldb_connect(const char *url, + unsigned int flags, + const char *options[]); +struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); + +#endif -- cgit From a4de8cd6a5a882a8d49fdb4b0e625ffdc6b401bb Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 21 Nov 2004 15:51:54 +0000 Subject: r3897: add a locking infrastructure (This used to be commit a99c0adb09e2bc77b876d23cb2d0711ccffd83ca) --- source4/lib/ldb/include/ldb_private.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index dfd388b8c6..720d8928dd 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -63,6 +63,8 @@ struct ldb_module_ops { int (*modify_record)(struct ldb_module *, const struct ldb_message *); int (*delete_record)(struct ldb_module *, const char *); int (*rename_record)(struct ldb_module *, const char *, const char *); + int (*named_lock)(struct ldb_module *, const char *); + int (*named_unlock)(struct ldb_module *, const char *); const char * (*errstring)(struct ldb_module *); /* this is called when the alloc ops changes to ensure we @@ -101,6 +103,8 @@ int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *mes int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_delete_record(struct ldb_module *module, const char *dn); int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn); +int ldb_next_named_lock(struct ldb_module *module, const char *lockname); +int ldb_next_named_unlock(struct ldb_module *module, const char *lockname); const char *ldb_next_errstring(struct ldb_module *module); void ldb_next_cache_free(struct ldb_module *module); -- cgit From 9012a501533126c4c0ac25a16fd6439a45df3d9a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 4 Dec 2004 10:14:03 +0000 Subject: r4059: moved the ldb -o option parsing to a common routine (This used to be commit ee52c1e38c9bac852458196ffbd677cca62a3965) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 720d8928dd..a2171162ad 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -127,4 +127,6 @@ struct ldb_context *lldb_connect(const char *url, const char *options[]); struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); +const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg); + #endif -- cgit From 09c1b9cbe5175636bcf4b606edfd0022bd9cfd6b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 31 Dec 2004 03:51:42 +0000 Subject: r4427: - added ldb_msg_*() functions for sorting, comparing and copying messages - added a ldb_msg_canonicalize() function that fixes a record to not have any duplicate elements - changed ldbedit to use ldb_msg_canonicalize(). This fixes a bug when you rename multiple elements in a record in one edit (This used to be commit f006e724400843419c8b6155cbeae1876983855e) --- source4/lib/ldb/include/ldb.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 03d0cc7a3b..9dff510417 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -293,6 +293,18 @@ double ldb_msg_find_double(const struct ldb_message *msg, const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); + +void ldb_msg_sort_elements(struct ldb_message *msg); + +void ldb_msg_free(struct ldb_context *ldb, struct ldb_message *msg); + +struct ldb_message *ldb_msg_copy(struct ldb_context *ldb, + const struct ldb_message *msg); + +struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, + const struct ldb_message *msg); + + struct ldb_val ldb_val_dup(struct ldb_context *ldb, const struct ldb_val *v); -- cgit From f9e507980e6a3340ae135e81d3106a836116d6b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 1 Jan 2005 05:06:22 +0000 Subject: r4466: rather than defining "STANDALONE" for building tdb, ldb and talloc outside the tree, instead defined _SAMBA_BUILD_ inside the Samba build. This makes it easier to pull code out of Samba for external use. (This used to be commit 09e98c8745cca7ccb1ad7134c0c09b8e4c0f4f06) --- source4/lib/ldb/include/talloc.h | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 source4/lib/ldb/include/talloc.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/talloc.h b/source4/lib/ldb/include/talloc.h new file mode 100644 index 0000000000..ffb4c9f252 --- /dev/null +++ b/source4/lib/ldb/include/talloc.h @@ -0,0 +1,96 @@ +#ifndef _TALLOC_H_ +#define _TALLOC_H_ +/* + Unix SMB/CIFS implementation. + Samba temporary memory allocation functions + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* this is only needed for compatibility with the old talloc */ +typedef void TALLOC_CTX; + +/* + this uses a little trick to allow __LINE__ to be stringified +*/ +#define _STRING_LINE_(s) #s +#define _STRING_LINE2_(s) _STRING_LINE_(s) +#define __LINESTR__ _STRING_LINE2_(__LINE__) +#define __location__ __FILE__ ":" __LINESTR__ + +/* useful macros for creating type checked pointers */ +#define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) +#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) +#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) +#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__) +#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__) +#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) + +#define talloc_destroy(ctx) talloc_free(ctx) + +#define malloc_p(type) (type *)malloc(sizeof(type)) +#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) +#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) + +#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) +#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) + +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a1, a2) +#endif + + +/* The following definitions come from lib/talloc.c */ +void *_talloc(const void *context, size_t size); +void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); +void talloc_increase_ref_count(const void *ptr); +void *talloc_reference(const void *context, const void *ptr); +int talloc_unlink(const void *context, void *ptr); +void talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void talloc_set_name_const(const void *ptr, const char *name); +void *talloc_named(const void *context, size_t size, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +void *talloc_named_const(const void *context, size_t size, const char *name); +const char *talloc_get_name(const void *ptr); +void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +int talloc_free(void *ptr); +void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +void *talloc_steal(const void *new_ctx, const void *ptr); +off_t talloc_total_size(const void *ptr); +off_t talloc_total_blocks(const void *ptr); +void talloc_report_full(const void *ptr, FILE *f); +void talloc_report(const void *ptr, FILE *f); +void talloc_enable_leak_report(void); +void talloc_enable_leak_report_full(void); +void *_talloc_zero(const void *ctx, size_t size, const char *name); +void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +char *talloc_strdup(const void *t, const char *p); +char *talloc_strndup(const void *t, const char *p, size_t n); +char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_append(char *s, + const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +void *talloc_ldb_alloc(void *context, void *ptr, size_t size); + +#endif + -- cgit From 1a988ec9af7960616fb4661b20d86ff05146d836 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:49:29 +0000 Subject: r4474: - converted ldb to use talloc internally - added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0) --- source4/lib/ldb/include/includes.h | 6 +-- source4/lib/ldb/include/ldb.h | 46 ++--------------- source4/lib/ldb/include/ldb_private.h | 10 +--- source4/lib/ldb/include/talloc.h | 96 ----------------------------------- 4 files changed, 9 insertions(+), 149 deletions(-) delete mode 100644 source4/lib/ldb/include/talloc.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 4926e1524a..66b984a87d 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -18,15 +18,15 @@ #include #include #include +#include #include "ldb.h" #include "ldb_private.h" +#include "talloc.h" -#ifdef HAVE_INTPTR_T +#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #else #define discard_const(ptr) ((void *)(ptr)) #endif #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) - - diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9dff510417..7aa2b6f4cd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -105,7 +105,7 @@ enum ldb_changetype { */ struct ldb_ldif { enum ldb_changetype changetype; - struct ldb_message msg; + struct ldb_message *msg; }; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, @@ -123,16 +123,6 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_module; -/* - the user can optionally supply a allocator function. It is presumed - it will act like a modern realloc(), with a context ptr to allow - for pool allocators -*/ -struct ldb_alloc_ops { - void *(*alloc)(const void *context, void *ptr, size_t size); - void *context; -}; - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -240,6 +230,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); +/* create an empty message */ +struct ldb_message *ldb_msg_new(void *mem_ctx); + /* find an element within an message */ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); @@ -305,40 +298,11 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, const struct ldb_message *msg); -struct ldb_val ldb_val_dup(struct ldb_context *ldb, - const struct ldb_val *v); - -/* - this allows the user to choose their own allocation function - the allocation function should behave like a modern realloc() - function, which means that: - malloc(size) == alloc(context, NULL, size) - free(ptr) == alloc(context, ptr, 0) - realloc(ptr, size) == alloc(context, ptr, size) - The context argument is provided to allow for pool based allocators, - which often take a context argument -*/ -int ldb_set_alloc(struct ldb_context *ldb, - void *(*alloc)(const void *context, void *ptr, size_t size), - void *context); - -/* these are used as type safe versions of the ldb allocation functions */ -#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) -#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) - -void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size); -void *ldb_malloc(struct ldb_context *ldb, size_t size); -void ldb_free(struct ldb_context *ldb, void *ptr); -void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen); -void *ldb_strdup(struct ldb_context *ldb, const char *str); -void *ldb_realloc_array(struct ldb_context *ldb, - void *ptr, size_t el_size, unsigned count); +struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) #endif -int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); /* this allows the user to set a debug function for error reporting diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index a2171162ad..3d3b1ec0eb 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -66,10 +66,6 @@ struct ldb_module_ops { int (*named_lock)(struct ldb_module *, const char *); int (*named_unlock)(struct ldb_module *, const char *); const char * (*errstring)(struct ldb_module *); - - /* this is called when the alloc ops changes to ensure we - don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_module *); }; /* the modules init function */ @@ -82,10 +78,7 @@ struct ldb_context { /* the operations provided by the backend */ struct ldb_module *modules; - /* memory allocation info */ - struct ldb_alloc_ops alloc_ops; - - /* memory allocation info */ + /* debugging operations */ struct ldb_debug_ops debug_ops; }; @@ -106,7 +99,6 @@ int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const c int ldb_next_named_lock(struct ldb_module *module, const char *lockname); int ldb_next_named_unlock(struct ldb_module *module, const char *lockname); const char *ldb_next_errstring(struct ldb_module *module); -void ldb_next_cache_free(struct ldb_module *module); /* The following definitions come from lib/ldb/common/util.c */ int ldb_list_find(const void *needle, diff --git a/source4/lib/ldb/include/talloc.h b/source4/lib/ldb/include/talloc.h deleted file mode 100644 index ffb4c9f252..0000000000 --- a/source4/lib/ldb/include/talloc.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _TALLOC_H_ -#define _TALLOC_H_ -/* - Unix SMB/CIFS implementation. - Samba temporary memory allocation functions - - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* this is only needed for compatibility with the old talloc */ -typedef void TALLOC_CTX; - -/* - this uses a little trick to allow __LINE__ to be stringified -*/ -#define _STRING_LINE_(s) #s -#define _STRING_LINE2_(s) _STRING_LINE_(s) -#define __LINESTR__ _STRING_LINE2_(__LINE__) -#define __location__ __FILE__ ":" __LINESTR__ - -/* useful macros for creating type checked pointers */ -#define talloc(ctx, size) talloc_named_const(ctx, size, __location__) -#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) -#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) -#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) -#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) -#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__) -#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__) -#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__) -#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) - -#define talloc_destroy(ctx) talloc_free(ctx) - -#define malloc_p(type) (type *)malloc(sizeof(type)) -#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count) -#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count) - -#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__) -#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__) - -#ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a1, a2) -#endif - - -/* The following definitions come from lib/talloc.c */ -void *_talloc(const void *context, size_t size); -void talloc_set_destructor(const void *ptr, int (*destructor)(void *)); -void talloc_increase_ref_count(const void *ptr); -void *talloc_reference(const void *context, const void *ptr); -int talloc_unlink(const void *context, void *ptr); -void talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void talloc_set_name_const(const void *ptr, const char *name); -void *talloc_named(const void *context, size_t size, - const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -void *talloc_named_const(const void *context, size_t size, const char *name); -const char *talloc_get_name(const void *ptr); -void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -int talloc_free(void *ptr); -void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); -void *talloc_steal(const void *new_ctx, const void *ptr); -off_t talloc_total_size(const void *ptr); -off_t talloc_total_blocks(const void *ptr); -void talloc_report_full(const void *ptr, FILE *f); -void talloc_report(const void *ptr, FILE *f); -void talloc_enable_leak_report(void); -void talloc_enable_leak_report_full(void); -void *_talloc_zero(const void *ctx, size_t size, const char *name); -void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); -char *talloc_strdup(const void *t, const char *p); -char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); -char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -char *talloc_asprintf_append(char *s, - const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); -void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); -void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); -void *talloc_ldb_alloc(void *context, void *ptr, size_t size); - -#endif - -- cgit From 09a76e204cf339862f8b0b45979d65cc34aa3c36 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 09:46:59 +0000 Subject: r4477: expanded the test suite to increase code coverage a lot (This used to be commit 4edbd1b18ee38e584cf844b64c7fcb2645921837) --- source4/lib/ldb/include/ldb_private.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3d3b1ec0eb..426da5ccae 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -100,10 +100,6 @@ int ldb_next_named_lock(struct ldb_module *module, const char *lockname); int ldb_next_named_unlock(struct ldb_module *module, const char *lockname); const char *ldb_next_errstring(struct ldb_module *module); -/* The following definitions come from lib/ldb/common/util.c */ -int ldb_list_find(const void *needle, - const void *base, size_t nmemb, size_t size, comparison_fn_t comp_fn); - /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -- cgit From cec158231b5618a9a93e478b6b60914305508086 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 11 Jan 2005 13:52:29 +0000 Subject: r4678: Add some const to LDB. Andrew Bartlett (This used to be commit d4da9fb1600dba5daca9acb83f528c8f5f42f0ce) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7aa2b6f4cd..0bb8105c44 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -256,7 +256,7 @@ int ldb_msg_add(struct ldb_context *ldb, int ldb_msg_add_value(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, - struct ldb_val *val); + const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, char *str); -- cgit From ea2209e3db4dc1a6d455e01d5339b0b981c361b1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Jan 2005 04:04:38 +0000 Subject: r5092: Add a bit more const - moving it further into the LDB layer. Andrew Bartlett (This used to be commit ffad9b22be595279b247fa72d51145830fecbb06) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0bb8105c44..310000b244 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -258,7 +258,7 @@ int ldb_msg_add_value(struct ldb_context *ldb, const char *attr_name, const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, - const char *attr_name, char *str); + const char *attr_name, const char *str); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, -- cgit From ff4797a9e4b01fe8cc9421e911371677433d070c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Feb 2005 11:30:33 +0000 Subject: r5357: added ldb_msg_add_fmt(), for creating formatted ldb record values (This used to be commit 18fb48204f4c0e22ea7e61575b3f174f30ff035c) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 310000b244..c6f96f6dea 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -259,6 +259,8 @@ int ldb_msg_add_value(struct ldb_context *ldb, const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, const char *str); +int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, + const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, -- cgit From 5a88d5211ba0f6b1d09cdd92489b34d0e603716b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 13 Feb 2005 12:27:57 +0000 Subject: r5374: - changed the dn key code in the ldb tdb backend to correctly honor the case sensitive/insensitive flags on sections of a dn. So if a dn is made up of 4 attributes, and 2 of those are case insensitive and 2 are case sensitive, then all the attribute names are uppercases, but only the values of the case insensitive attributes are uppercased when forming the tdb key. - added code to canonicalise the dn, removing leading and trailing spaces from attribute names and values - when the @ATTRIBUTES record changes, fix the dn keys of any records that should now have new dn keys due to changes in the case sensitivity of the record I really did this to allow me to make the WINS database properly case insensitive, but it is also the correct general fix for ldb, as it matches the LDAP specification (and w2k LDAP server behaviour) (This used to be commit 0f034dc5636d182a1d9207ad662b3fc8df7ca3e4) --- source4/lib/ldb/include/ldb.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c6f96f6dea..09b4cbf84a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -140,6 +140,11 @@ struct ldb_debug_ops { #define LDB_FLG_RDONLY 1 +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif + + /* connect to a database. The URL can either be one of the following forms ldb://path @@ -302,10 +307,6 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); -#ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a,b) -#endif - /* this allows the user to set a debug function for error reporting */ -- cgit From b1b14817eaa6e6579596d54166e17bc8d5605c01 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 27 Feb 2005 11:35:47 +0000 Subject: r5585: LDB interfaces change: changes: - ldb_wrap disappears from code and become a private structure of db_wrap.c thanks to our move to talloc in ldb code, we do not need to expose it anymore - removal of ldb_close() function form the code thanks to our move to talloc in ldb code, we do not need it anymore use talloc_free() to close and free an ldb database - some minor updates to ldb modules code to cope with the change and fix some bugs I found out during the process (This used to be commit d58be9e74b786a11a57e89df36081d55730dfe0a) --- source4/lib/ldb/include/ldb.h | 6 ------ source4/lib/ldb/include/ldb_private.h | 8 +++----- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 09b4cbf84a..0eb661d7ce 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -158,12 +158,6 @@ struct ldb_debug_ops { struct ldb_context *ldb_connect(const char *url, unsigned int flags, const char *options[]); -/* - close the connection to the database -*/ -int ldb_close(struct ldb_context *ldb); - - /* search the database given a LDAP-like search expression diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 426da5ccae..a370a80299 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -55,7 +55,6 @@ struct ldb_module { */ struct ldb_module_ops { const char *name; - int (*close)(struct ldb_module *); int (*search)(struct ldb_module *, const char *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); int (*search_free)(struct ldb_module *, struct ldb_message **); @@ -68,9 +67,6 @@ struct ldb_module_ops { const char * (*errstring)(struct ldb_module *); }; -/* the modules init function */ -typedef struct ldb_module *(*ldb_module_init_function)(void); - /* every ldb connection is started by establishing a ldb_context */ @@ -82,10 +78,12 @@ struct ldb_context { struct ldb_debug_ops debug_ops; }; +/* the modules init function */ +typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]); + /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); -int ldb_next_close(struct ldb_module *module); int ldb_next_search(struct ldb_module *module, const char *base, enum ldb_scope scope, -- cgit From fe4d985b6f3d318d9b58a16677be3b4ae34fba15 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 25 Apr 2005 12:46:18 +0000 Subject: r6470: Remove ldb_search_free() it is not needed anymore. Just use talloc_free() to release the memory after an ldb_search(). (This used to be commit 4f0948dab0aa5e8b6a4ce486f3668ca8dfae23db) --- source4/lib/ldb/include/ldb.h | 8 ++------ source4/lib/ldb/include/ldb_private.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0eb661d7ce..f748bb6b42 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -162,6 +162,8 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags, search the database given a LDAP-like search expression return the number of records found, or -1 on error + + use talloc_free to free the ldb_message returned */ int ldb_search(struct ldb_context *ldb, const char *base, @@ -169,12 +171,6 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_message ***res); -/* - free a set of messages returned by ldb_search -*/ -int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); - - /* add a record to the database. Will fail if a record with the given class and key already exists diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index a370a80299..7a0b2fef75 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -57,7 +57,6 @@ struct ldb_module_ops { const char *name; int (*search)(struct ldb_module *, const char *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_module *, struct ldb_message **); int (*add_record)(struct ldb_module *, const struct ldb_message *); int (*modify_record)(struct ldb_module *, const struct ldb_message *); int (*delete_record)(struct ldb_module *, const char *); @@ -89,7 +88,6 @@ int ldb_next_search(struct ldb_module *module, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); -int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg); int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_delete_record(struct ldb_module *module, const char *dn); -- cgit From e5a3ec0e5b9bc7d85d3c64f0ce9628f788065d84 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 14 May 2005 22:16:02 +0000 Subject: r6790: Use config.h file for ldb and add test for stdint.h (This used to be commit c1f1b5a9455c827f7baf382d919ab8a0eab49bb3) --- source4/lib/ldb/include/includes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 66b984a87d..8b513e20c7 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -5,8 +5,8 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif +#include "config.h" #include -#include #include #include #include @@ -18,7 +18,9 @@ #include #include #include +#ifdef HAVE_STDINT_H #include +#endif #include "ldb.h" #include "ldb_private.h" -- cgit From 9a9cf9e0753c7cf040feecf670c0986a17c16dce Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 16 May 2005 22:31:45 +0000 Subject: r6833: split out the routine that calculates the diff between two ldb messages from ldbedit, so other progs can use it. (This used to be commit fa4f33558af3c65ff31424c01db16cb9d427503d) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f748bb6b42..18d974cf42 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -295,6 +295,10 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, const struct ldb_message *msg); +struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, + struct ldb_message *msg1, + struct ldb_message *msg2); + struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); /* -- cgit From fc21940da5d35ae03f73834fb6ed61de5dc15bf1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 22 May 2005 10:02:53 +0000 Subject: r6931: declare this to avoid warnings until we have loadable modules (This used to be commit 73258909dbd4e14f3c8eb5cebe0647539d141c8d) --- source4/lib/ldb/include/ldb_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 7a0b2fef75..4f86655a76 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -110,6 +110,7 @@ struct ldb_context *lldb_connect(const char *url, unsigned int flags, const char *options[]); struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg); -- cgit From a1ba224107fbcf6f8a9a3091f42cde2a0c47f85e Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 4 Jun 2005 17:13:43 +0000 Subject: r7276: - moved static tdb function ltdb_dn_fold() into common/ so that it can be called from multiple backends. (ldb_sqlite3 needs it too.) Added parameter for a callback function that determines whether an attribute needs case folding. - begin to prepare for sqlite3 in build process - work-in-progress updates, on ldb_sqlite3 (This used to be commit a80bced0b96ffb655559a43cf7f4d7a34deb5a7d) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 18d974cf42..8ccf8967cb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -225,6 +225,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); +/* case-fold a DN */ +char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)); + /* create an empty message */ struct ldb_message *ldb_msg_new(void *mem_ctx); -- cgit From 1b454c430f0ce2e86350052b5a4e23f899e9eee9 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 4 Jun 2005 22:30:38 +0000 Subject: r7286: add prototype for public connect function in ldb_sqlite3 (This used to be commit 10d438af06b3ab442c7a98b704d2e0bfe49b739d) --- source4/lib/ldb/include/ldb_private.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 4f86655a76..69bf4a6dc6 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -109,6 +109,9 @@ struct ldb_context *ltdb_connect(const char *url, struct ldb_context *lldb_connect(const char *url, unsigned int flags, const char *options[]); +struct ldb_context *lsqlite3_connect(const char *url, + unsigned int flags, + const char *options[]); struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); -- cgit From 7fc1c3553cd3666c234ec302a54ebd331589c934 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 8 Jun 2005 19:49:49 +0000 Subject: r7408: added DN explode function, based on simo's ldap_parse_dn() function. simo, when you get a chance, please change your license so this can be linked with ldb. (This used to be commit 588a1d1451d4117cb6e427a293455f2a5657b604) --- source4/lib/ldb/include/ldb_explode_dn.h | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 source4/lib/ldb/include/ldb_explode_dn.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_explode_dn.h b/source4/lib/ldb/include/ldb_explode_dn.h new file mode 100644 index 0000000000..fb34be8b87 --- /dev/null +++ b/source4/lib/ldb/include/ldb_explode_dn.h @@ -0,0 +1,38 @@ +/* + Unix SMB/CIFS implementation. + LDAP server + Copyright (C) Simo Sorce 2004 + Copyright (C) Derrell Lipman 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +struct ldb_dn_attribute { + char * rdn; + char * name; + char * value; +}; + +struct ldb_dn_component { + char * component; + int attr_num; + struct ldb_dn_attribute ** attributes; +}; + +struct ldb_dn { + char *dn; + int comp_num; + struct ldb_dn_component ** components; +}; -- cgit From 322f0df3f124c95f2f50abbb2c07616a6cf721c0 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 8 Jun 2005 20:30:50 +0000 Subject: r7410: minor cleanup (This used to be commit 4c8bffc3f01d60ef7d8b75e92f4d062326288f4c) --- source4/lib/ldb/include/ldb_explode_dn.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_explode_dn.h b/source4/lib/ldb/include/ldb_explode_dn.h index fb34be8b87..78768ebb80 100644 --- a/source4/lib/ldb/include/ldb_explode_dn.h +++ b/source4/lib/ldb/include/ldb_explode_dn.h @@ -32,7 +32,12 @@ struct ldb_dn_component { }; struct ldb_dn { - char *dn; - int comp_num; + char * dn; + int comp_num; struct ldb_dn_component ** components; }; + + +extern struct ldb_dn * +ldb_explode_dn(void *mem_ctx, + const char *orig_dn); -- cgit From a6717fae681f89cf427e282d645029ca0b3e4d44 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 9 Jun 2005 02:47:26 +0000 Subject: r7418: work in progress (This used to be commit 2a13e7655b1bce88694ddbb6a4d9349008ba42f0) --- source4/lib/ldb/include/ldb.h | 2 +- source4/lib/ldb/include/ldb_explode_dn.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8ccf8967cb..91a826447a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ const char *ldb_errstring(struct ldb_context *ldb); /* casefold a string (should be UTF8, but at the moment it isn't) */ -char *ldb_casefold(struct ldb_context *ldb, const char *s); +char *ldb_casefold(void *mem_ctx, const char *s); /* ldif manipulation functions diff --git a/source4/lib/ldb/include/ldb_explode_dn.h b/source4/lib/ldb/include/ldb_explode_dn.h index 78768ebb80..af9829ba40 100644 --- a/source4/lib/ldb/include/ldb_explode_dn.h +++ b/source4/lib/ldb/include/ldb_explode_dn.h @@ -39,5 +39,8 @@ struct ldb_dn { extern struct ldb_dn * -ldb_explode_dn(void *mem_ctx, - const char *orig_dn); +ldb_explode_dn(void * mem_ctx, + const char * orig_dn, + void * hUserData, + int (*case_fold_attr_fn)(void * hUserData, + char * attr)); -- cgit From 87acba39f9e45eb6849cfd945ce6255bac5564c9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 05:18:17 +0000 Subject: r7514: make the ldb_parse code not depend on a ldb_context, so we can now potentially use it in our ldap client code, instead of replicating all the code (This used to be commit 5b3575d9303d54a771e080a670dcd2f444b10c20) --- source4/lib/ldb/include/ldb_parse.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index d9125d05ed..50a9382534 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -54,7 +54,6 @@ struct ldb_parse_tree { } u; }; -struct ldb_parse_tree *ldb_parse_tree(struct ldb_context *ldb, const char *s); -void ldb_parse_tree_free(struct ldb_context *ldb, struct ldb_parse_tree *tree); +struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); #endif -- cgit From 9cb3b2d49bf4093f9eff8cd26a0c9c994da5d096 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 05:33:55 +0000 Subject: r7515: merge in the binary encode/decode enhancements from the libcli/ldap/ code into the ldb parse code (This used to be commit 12647e37223847da810c2d4e5f83328b1fcf88cb) --- source4/lib/ldb/include/ldb_parse.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index 50a9382534..741a8af618 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -55,5 +55,6 @@ struct ldb_parse_tree { }; struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); +const char *ldb_binary_encode(TALLOC_CTX *ctx, struct ldb_val val); #endif -- cgit From e5c70a58873d5f274ec38d85884e0e76bbbaa291 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 06:52:48 +0000 Subject: r7522: added a ldb_filter_from_tree() function that takes a ldb_parse_tree and forms a ldab search filter expression. Next step is to make our ldap server code go from ASN.1 to a ldb_parse_tree, instead of trying to construct string filters, then add a ldb_search_tree() call to allow for searches using parse trees. all of this is being done as I am hitting bitwise '&' ldap search expressions from w2k, and want to handle them cleanly. (This used to be commit 04356c1b1ed86d72934bc1b0ed60b767e10a1196) --- source4/lib/ldb/include/ldb_parse.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h index 741a8af618..c8d89d2165 100644 --- a/source4/lib/ldb/include/ldb_parse.h +++ b/source4/lib/ldb/include/ldb_parse.h @@ -35,7 +35,7 @@ #ifndef _LDB_PARSE_H #define _LDB_PARSE_H 1 -enum ldb_parse_op {LDB_OP_SIMPLE, LDB_OP_AND, LDB_OP_OR, LDB_OP_NOT}; +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; struct ldb_parse_tree { enum ldb_parse_op operation; @@ -55,6 +55,7 @@ struct ldb_parse_tree { }; struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); -const char *ldb_binary_encode(TALLOC_CTX *ctx, struct ldb_val val); +char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); +char *ldb_binary_encode(TALLOC_CTX *ctx, struct ldb_val val); #endif -- cgit From 4b0e5bd75373ffa2d847706a71fd0349dfa15e71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 09:10:17 +0000 Subject: r7527: - added a ldb_search_bytree() interface, which takes a ldb_parse_tree instead of a search expression. This allows our ldap server to pass its ASN.1 parsed search expressions straight to ldb, instead of going via strings. - updated all the ldb modules code to handle the new interface - got rid of the separate ldb_parse.h now that the ldb_parse structures are exposed externally - moved to C99 structure initialisation in ldb - switched ldap server to using ldb_search_bytree() (This used to be commit 96620ab2ee5d440bbbc51c1bc0cad9977770f897) --- source4/lib/ldb/include/ldb.h | 34 +++++++++++++++++++ source4/lib/ldb/include/ldb_parse.h | 61 ----------------------------------- source4/lib/ldb/include/ldb_private.h | 7 ++++ 3 files changed, 41 insertions(+), 61 deletions(-) delete mode 100644 source4/lib/ldb/include/ldb_parse.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 91a826447a..02df0ae810 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -145,6 +145,31 @@ struct ldb_debug_ops { #endif +/* structues for ldb_parse_tree handling code */ +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; + +struct ldb_parse_tree { + enum ldb_parse_op operation; + union { + struct { + char *attr; + struct ldb_val value; + } simple; + struct { + unsigned int num_elements; + struct ldb_parse_tree **elements; + } list; + struct { + struct ldb_parse_tree *child; + } not; + } u; +}; + +struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); +char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); +char *ldb_binary_encode(void *ctx, struct ldb_val val); + + /* connect to a database. The URL can either be one of the following forms ldb://path @@ -171,6 +196,15 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_message ***res); +/* + like ldb_search() but takes a parse tree +*/ +int ldb_search_bytree(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char * const *attrs, struct ldb_message ***res); + /* add a record to the database. Will fail if a record with the given class and key already exists diff --git a/source4/lib/ldb/include/ldb_parse.h b/source4/lib/ldb/include/ldb_parse.h deleted file mode 100644 index c8d89d2165..0000000000 --- a/source4/lib/ldb/include/ldb_parse.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - ldb database library - - Copyright (C) Andrew Tridgell 2004 - - ** NOTE! The following LGPL license applies to the ldb - ** library. This does NOT imply that all of Samba is released - ** under the LGPL - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* - * Name: ldb - * - * Component: ldb expression parse header - * - * Description: structure for expression parsing - * - * Author: Andrew Tridgell - */ - -#ifndef _LDB_PARSE_H -#define _LDB_PARSE_H 1 - -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; - -struct ldb_parse_tree { - enum ldb_parse_op operation; - union { - struct { - char *attr; - struct ldb_val value; - } simple; - struct { - unsigned int num_elements; - struct ldb_parse_tree **elements; - } list; - struct { - struct ldb_parse_tree *child; - } not; - } u; -}; - -struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); -char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); -char *ldb_binary_encode(TALLOC_CTX *ctx, struct ldb_val val); - -#endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 69bf4a6dc6..414d8c14a1 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -57,6 +57,8 @@ struct ldb_module_ops { const char *name; int (*search)(struct ldb_module *, const char *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); + int (*search_bytree)(struct ldb_module *, const char *, enum ldb_scope, + struct ldb_parse_tree *, const char * const [], struct ldb_message ***); int (*add_record)(struct ldb_module *, const struct ldb_message *); int (*modify_record)(struct ldb_module *, const struct ldb_message *); int (*delete_record)(struct ldb_module *, const char *); @@ -88,6 +90,11 @@ int ldb_next_search(struct ldb_module *module, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); +int ldb_next_search_bytree(struct ldb_module *module, + const char *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char * const *attrs, struct ldb_message ***res); int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_delete_record(struct ldb_module *module, const char *dn); -- cgit From 4fec6356ea190d202783fe19013387462a22c441 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Jun 2005 01:35:44 +0000 Subject: r7558: added support in ldb for extended ldap search requests. These are using to perform such things as bitop tests on integers. So far I have only added support for the 1.2.840.113556.1.4.803 and 1.2.840.113556.1.4.804 rules, which are for bitwise and/or (This used to be commit 5f773b065f1db959e59c02de68bcf30cef1a6c2c) --- source4/lib/ldb/include/ldb.h | 9 ++++++++- source4/lib/ldb/include/ldb_private.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 02df0ae810..5773e39fa9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -146,7 +146,8 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, + LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; struct ldb_parse_tree { enum ldb_parse_op operation; @@ -155,6 +156,12 @@ struct ldb_parse_tree { char *attr; struct ldb_val value; } simple; + struct { + char *attr; + int dnAttributes; + char *rule_id; + struct ldb_val value; + } extended; struct { unsigned int num_elements; struct ldb_parse_tree **elements; diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 414d8c14a1..e022d68ec7 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -82,6 +82,10 @@ struct ldb_context { /* the modules init function */ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]); +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) +#endif + /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); -- cgit From 785b452a042f00b561df55243e8aaee920d84ce6 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 14 Jun 2005 03:04:24 +0000 Subject: r7561: moved OID constants into ldb.h and used manifest constants in ldb_match.c (This used to be commit 42cbb155c20779c458f727488c8554842b24681b) --- source4/lib/ldb/include/ldb.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5773e39fa9..7a28d05b38 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -71,6 +71,12 @@ struct ldb_val { #define LDB_FLAG_MOD_DELETE 3 +/* + well known object IDs +*/ +#define LDB_OID_COMPARATOR_AND "1.2.840.113556.1.4.803" +#define LDB_OID_COMPARATOR_OR "1.2.840.113556.1.4.804" + /* results are given back as arrays of ldb_message_element */ -- cgit From 3e92471d4cfa169b97da73752b6eb6d1ea8cb466 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 15 Jun 2005 01:02:53 +0000 Subject: r7596: next step in ldap cleanup. I'm aiming to get rid of the cut&pasted ldif parsing code in libcli/ldap/ldap_ldif.c, and instead use the ldb ldif code. To do that I have changed the ldap code to use 'struct ldb_message_element' instead of 'struct ldap_attribute'. They are essentially the same structure anyway, so by making them really the same it will be much easier to use the ldb code in libcli/ldap/ I have also made 'struct ldb_val' the same as a DATA_BLOB, which will simplify data handling in quite a few places (I haven't yet removed all the code that maps between these two, that will come later) (This used to be commit 87fc3073392236221a3a6b933284e9e477c24ae5) --- source4/lib/ldb/include/ldb.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7a28d05b38..4bf2f9581f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -57,10 +57,12 @@ sensible, but it can be to anything you like, including binary data blobs of arbitrary size. */ +#ifndef ldb_val struct ldb_val { - unsigned int length; - void *data; + uint8_t *data; + size_t length; }; +#endif /* these flags are used in ldd_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify @@ -82,7 +84,7 @@ struct ldb_val { */ struct ldb_message_element { unsigned int flags; - char *name; + const char *name; unsigned int num_values; struct ldb_val *values; }; -- cgit From f021dffb6991138213967521c743f03f474f9af9 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 15 Jun 2005 02:43:42 +0000 Subject: r7601: ldb_sqlite3 work in progress (This used to be commit 0a64948152a446b5e127578d49b1ed8a90a1a222) --- source4/lib/ldb/include/ldb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4bf2f9581f..fabaec5da2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -275,7 +275,10 @@ int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); /* case-fold a DN */ -char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)); +char *ldb_dn_fold(void * mem_ctx, + const char * dn, + void * user_data, + int (* case_fold_attr_fn)(void * user_data, char * attr)); /* create an empty message */ struct ldb_message *ldb_msg_new(void *mem_ctx); -- cgit From 03b0f279ed7d1ed7083e0c2301af94ff39f0e8a4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Jun 2005 02:47:26 +0000 Subject: r7667: added a ldb ildap backend, using our internal ldap client library. Next step is to remove the check for the ldap libraries in configure (This used to be commit 74841dbb2a86bb1c584b5c26c4cd24a818a65a34) --- source4/lib/ldb/include/ldb_private.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e022d68ec7..4acdd543f2 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -120,6 +120,9 @@ struct ldb_context *ltdb_connect(const char *url, struct ldb_context *lldb_connect(const char *url, unsigned int flags, const char *options[]); +struct ldb_context *ildb_connect(const char *url, + unsigned int flags, + const char *options[]); struct ldb_context *lsqlite3_connect(const char *url, unsigned int flags, const char *options[]); -- cgit From ed3d8091ce2b2014350a2f7f22202dde6846a130 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 07:42:21 +0000 Subject: r7709: - convert ldb to use popt, so that it can interact with the samba cmdline credentials code (which will be done soon) - added a ldb_init() call, and changed ldb_connect() to take a ldb context. This allows for much better error handling in ldb_connect(), and also made the popt conversion easier - fixed up all the existing backends with the new syntax - improved error handling in *_connect() - fixed a crash bug in the new case_fold_required() code - ensured that ltdb_rename() and all ltdb_search() paths get the read lock - added a ldb_oom() macro to make it easier to report out of memory situations in ldb code (This used to be commit f648fdf187669d6d87d01dd4e786b03cd420f220) --- source4/lib/ldb/include/ldb.h | 7 +++++-- source4/lib/ldb/include/ldb_private.h | 33 +++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fabaec5da2..ecfa77f436 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -184,6 +184,10 @@ struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); +/* + initialise a ldb context +*/ +struct ldb_context *ldb_init(void *mem_ctx); /* connect to a database. The URL can either be one of the following forms @@ -195,8 +199,7 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); the options are passed uninterpreted to the backend, and are backend specific */ -struct ldb_context *ldb_connect(const char *url, unsigned int flags, - const char *options[]); +int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); /* search the database given a LDAP-like search expression diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 4acdd543f2..76a43cdbc2 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -86,6 +86,11 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) #endif +/* + simplify out of memory handling +*/ +#define ldb_oom(ldb) ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) + /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); @@ -114,21 +119,21 @@ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char * char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len); int ldb_should_b64_encode(const struct ldb_val *val); -struct ldb_context *ltdb_connect(const char *url, - unsigned int flags, - const char *options[]); -struct ldb_context *lldb_connect(const char *url, - unsigned int flags, - const char *options[]); -struct ldb_context *ildb_connect(const char *url, - unsigned int flags, - const char *options[]); -struct ldb_context *lsqlite3_connect(const char *url, - unsigned int flags, - const char *options[]); +int ltdb_connect(struct ldb_context *ldb, const char *url, + unsigned int flags, + const char *options[]); +int lldb_connect(struct ldb_context *ldb, const char *url, + unsigned int flags, + const char *options[]); +int ildb_connect(struct ldb_context *ldb, + const char *url, + unsigned int flags, + const char *options[]); +int lsqlite3_connect(struct ldb_context *ldb, + const char *url, + unsigned int flags, + const char *options[]); struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); -const char **ldb_options_parse(const char **options, int *ldbopts, const char *arg); - #endif -- cgit From 56cc32800036472ebc29362d65e422c0b410e3fc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 01:31:27 +0000 Subject: r7740: get rid of our duplicate base64 routines (This used to be commit cf17f90a83cf04815544c5408eb56d00546b3e88) --- source4/lib/ldb/include/ldb.h | 2 ++ source4/lib/ldb/include/ldb_private.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index ecfa77f436..e980633a62 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -270,6 +270,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); +char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); +int ldb_base64_decode(char *s); /* useful functions for ldb_message structure manipulation */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 76a43cdbc2..92588e13fd 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -116,7 +116,6 @@ const char *ldb_next_errstring(struct ldb_module *module); void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); /* The following definitions come from lib/ldb/common/ldb_ldif.c */ -char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len); int ldb_should_b64_encode(const struct ldb_val *val); int ltdb_connect(struct ldb_context *ldb, const char *url, -- cgit From bd7a474b1967423711ff93c0080ce0f89270e3f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Jun 2005 04:56:43 +0000 Subject: r7776: add a method for getting arbitrary opaque data into a ldb context, for use by backends. Currently only EventContext is used in this way. (This used to be commit 9fa21b245843371f7777682ee4e5b98e2925b4d0) --- source4/lib/ldb/include/ldb.h | 4 ++++ source4/lib/ldb/include/ldb_private.h | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e980633a62..9a3186b41c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -372,4 +372,8 @@ int ldb_set_debug(struct ldb_context *ldb, /* this sets up debug to print messages on stderr */ int ldb_set_debug_stderr(struct ldb_context *ldb); +/* control backend specific opaque values */ +int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); +void *ldb_get_opaque(struct ldb_context *ldb, const char *name); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 92588e13fd..8f91b0d9b1 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -77,6 +77,13 @@ struct ldb_context { /* debugging operations */ struct ldb_debug_ops debug_ops; + + /* backend specific opaque parameters */ + struct ldb_opaque { + struct ldb_opaque *next; + const char *name; + void *value; + } *opaque; }; /* the modules init function */ -- cgit From eb0a13025aa6d693c7e9fa213ef04fa58cf60e3e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Jun 2005 06:35:55 +0000 Subject: r7803: added support in ldb for callers to setup ldif read/write functions, so that ldbedit, ldbsearch etc can display nice human readable ldif, while storing the data as binary blobs. This will be used for storing NDR encoded objectSid and similar attributes, while making the command line interface sane (This used to be commit 37e283089a846fc0608fef3981a3447300e33728) --- source4/lib/ldb/include/ldb.h | 13 +++++++++++++ source4/lib/ldb/include/ldb_private.h | 4 ++++ 2 files changed, 17 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9a3186b41c..48290beb92 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -184,6 +184,19 @@ struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); + +/* + functions for controlling ldif encode/decode +*/ +typedef int (*ldb_ldif_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *); + +struct ldb_ldif_handler { + const char *attr; + ldb_ldif_handler_t read_fn; + ldb_ldif_handler_t write_fn; +}; + + /* initialise a ldb context */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 8f91b0d9b1..f6c1c7ff46 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -84,6 +84,10 @@ struct ldb_context { const char *name; void *value; } *opaque; + + /* ldif attribute handling table */ + unsigned ldif_num_handlers; + struct ldb_ldif_handler *ldif_handlers; }; /* the modules init function */ -- cgit From 5be159f304411b58c417a979c819f9ab211a0337 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Jun 2005 07:52:00 +0000 Subject: r7804: added the samba specific ldif handlers into the tree, but don't enable them just yet. I have tested them, and they work fine, but enabling them will break code in rpc_server/ and samdb, so we need to fix that first (This used to be commit 07d459406b4c63e49141e0e533e1274b4052abf9) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 48290beb92..3102676327 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -285,6 +285,9 @@ struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); int ldb_base64_decode(char *s); +int ldb_ldif_add_handlers(struct ldb_context *ldb, + const struct ldb_ldif_handler *handlers, + unsigned num_handlers); /* useful functions for ldb_message structure manipulation */ -- cgit From fdc0450db25021eddcc65d032fd3fd8ca5976928 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 22 Jun 2005 02:39:07 +0000 Subject: r7828: Although there is still plenty to do, ldb_sqlite3 now passes the set of tests in tests/test-sqlite3.sh (tests/test-generic.sh). There are lots of optimizations still TBD, and some things are REALLY slow right now (e.g. each add() operation takes 1/3 - 1/2 second) but it's ready for interested parties to poke it and prod it and see how (un)reasonable it is. Play away. Still to be implemented or improved: - tdb specials (@MODULES, @SUBCLASSES, etc.) - all DNs are case-folded in their entirty right now (since doing otherwise would require @ATTRIBUTES to be implemented) - speed improvements and optimizations. I am quite confident that the excessively slow add() operation can be much improved, and other areas can be somewhat improved. (This used to be commit 1dd865005594671e7effe06fb088fa97fa08de0b) --- source4/lib/ldb/include/ldb.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3102676327..1b5c7c4f57 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -254,6 +254,16 @@ int ldb_modify(struct ldb_context *ldb, */ int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn); +/* + create a named lock +*/ +int ldb_lock(struct ldb_context *ldb, const char *lockname); + +/* + release a named lock +*/ +int ldb_unlock(struct ldb_context *ldb, const char *lockname); + /* delete a record from the database */ -- cgit From 1702f52498168c0437416dec1014cedead634774 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Jun 2005 23:59:22 +0000 Subject: r7936: new ldb_dn_explode and ldb_dn_casefold functions and co (This used to be commit 7ccf21ab4eeb9821e457308a239f2103a106fb12) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1b5c7c4f57..8feec9e002 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -279,6 +279,7 @@ const char *ldb_errstring(struct ldb_context *ldb); casefold a string (should be UTF8, but at the moment it isn't) */ char *ldb_casefold(void *mem_ctx, const char *s); +int ldb_caseless_cmp(const char *s1, const char *s2); /* ldif manipulation functions -- cgit From e1e95277c0c7f86b15acd70ee3151ec2b3131c5e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 27 Jun 2005 00:00:50 +0000 Subject: r7937: main file was missing (This used to be commit 3898cdb0dc4722a7eb60a61b54ef778dab475aed) --- source4/lib/ldb/include/ldb_dn.h | 42 +++++++++++++++++++++++++++++ source4/lib/ldb/include/ldb_explode_dn.h | 46 -------------------------------- 2 files changed, 42 insertions(+), 46 deletions(-) create mode 100644 source4/lib/ldb/include/ldb_dn.h delete mode 100644 source4/lib/ldb/include/ldb_explode_dn.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_dn.h b/source4/lib/ldb/include/ldb_dn.h new file mode 100644 index 0000000000..f355ee4879 --- /dev/null +++ b/source4/lib/ldb/include/ldb_dn.h @@ -0,0 +1,42 @@ +/* + Unix SMB/CIFS implementation. + LDAP server + Copyright (C) Simo Sorce 2004 + Copyright (C) Derrell Lipman 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +struct ldb_dn_attribute { + char *name; + char *value; +}; + +struct ldb_dn_component { + int attr_num; + struct ldb_dn_attribute **attributes; +}; + +struct ldb_dn { + int comp_num; + struct ldb_dn_component **components; +}; + + +struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); +char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn); +int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); +struct ldb_dn *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *edn, void *user_data, + int (* case_fold_attr_fn)(void * user_data, char * attr)); diff --git a/source4/lib/ldb/include/ldb_explode_dn.h b/source4/lib/ldb/include/ldb_explode_dn.h deleted file mode 100644 index af9829ba40..0000000000 --- a/source4/lib/ldb/include/ldb_explode_dn.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Unix SMB/CIFS implementation. - LDAP server - Copyright (C) Simo Sorce 2004 - Copyright (C) Derrell Lipman 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -struct ldb_dn_attribute { - char * rdn; - char * name; - char * value; -}; - -struct ldb_dn_component { - char * component; - int attr_num; - struct ldb_dn_attribute ** attributes; -}; - -struct ldb_dn { - char * dn; - int comp_num; - struct ldb_dn_component ** components; -}; - - -extern struct ldb_dn * -ldb_explode_dn(void * mem_ctx, - const char * orig_dn, - void * hUserData, - int (*case_fold_attr_fn)(void * hUserData, - char * attr)); -- cgit From a06d66a3a669c3a0a0f816438e2b3e91e208f398 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Jul 2005 06:21:26 +0000 Subject: r8037: a fairly major update to the internals of ldb. Changes are: - moved the knowledge of attribute types out of ldb_tdb and into the generic ldb code. This allows the ldb_match() message match logic to be generic, so it can be used by other backend - added the generic ability to load attribute handlers, for canonicalisation, compare, ldif read and ldif write. In the future this will be used by the schema module to allow us to correctly obey the attributetype schema elements - added attribute handlers for some of the core ldap attribute types, Integer, DirectoryString, DN, ObjectClass etc - added automatic registration of attribute handlers for well-known attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass' - converted the objectSid special handlers for Samba to the new system - added more correct handling of indexing in tdb backend based on the attribute canonicalisation function - added generic support for subclasses, moving it out of the tdb backend. This will be used in future by the schema module - fixed several bugs in the dn_explode code. It still needs more work, but doesn't corrupt ldb dbs any more. (This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9) --- source4/lib/ldb/include/ldb.h | 40 +++++++++++++++++++++------ source4/lib/ldb/include/ldb_dn.h | 3 +-- source4/lib/ldb/include/ldb_private.h | 51 ++++++++++++++++++++++++++++++++--- 3 files changed, 81 insertions(+), 13 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8feec9e002..868d005399 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -186,16 +186,40 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); /* - functions for controlling ldif encode/decode + functions for controlling attribute handling */ -typedef int (*ldb_ldif_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_comparison_t)(struct ldb_context *, const struct ldb_val *, const struct ldb_val *); -struct ldb_ldif_handler { +struct ldb_attrib_handler { const char *attr; - ldb_ldif_handler_t read_fn; - ldb_ldif_handler_t write_fn; + + /* LDB_ATTR_FLAG_* */ + unsigned flags; + + /* convert from ldif to binary format */ + ldb_attr_handler_t ldif_read_fn; + + /* convert from binary to ldif format */ + ldb_attr_handler_t ldif_write_fn; + + /* canonicalise a value, for use by indexing and dn construction */ + ldb_attr_handler_t canonicalise_fn; + + /* compare two values */ + ldb_attr_comparison_t comparison_fn; }; +#define LDB_ATTR_FLAG_HIDDEN (1<<0) +#define LDB_ATTR_FLAG_WILDCARD (1<<1) + +/* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ +#define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12" +#define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" +#define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27" +#define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40" +#define LDB_SYNTAX_WILDCARD "LDB_SYNTAX_WILDCARD" +#define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* initialise a ldb context @@ -296,9 +320,9 @@ struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); int ldb_base64_decode(char *s); -int ldb_ldif_add_handlers(struct ldb_context *ldb, - const struct ldb_ldif_handler *handlers, - unsigned num_handlers); +int ldb_attrib_add_handlers(struct ldb_context *ldb, + const struct ldb_attrib_handler *handlers, + unsigned num_handlers); /* useful functions for ldb_message structure manipulation */ diff --git a/source4/lib/ldb/include/ldb_dn.h b/source4/lib/ldb/include/ldb_dn.h index f355ee4879..723b89e316 100644 --- a/source4/lib/ldb/include/ldb_dn.h +++ b/source4/lib/ldb/include/ldb_dn.h @@ -38,5 +38,4 @@ struct ldb_dn { struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *edn, void *user_data, - int (* case_fold_attr_fn)(void * user_data, char * attr)); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index f6c1c7ff46..43c925e036 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -68,6 +68,23 @@ struct ldb_module_ops { const char * (*errstring)(struct ldb_module *); }; + +/* + schema related information needed for matching rules +*/ +struct ldb_schema { + /* attribute handling table */ + unsigned num_attrib_handlers; + struct ldb_attrib_handler *attrib_handlers; + + /* objectclass information */ + unsigned num_classes; + struct ldb_subclass { + char *name; + char **subclasses; + } *classes; +}; + /* every ldb connection is started by establishing a ldb_context */ @@ -85,9 +102,7 @@ struct ldb_context { void *value; } *opaque; - /* ldif attribute handling table */ - unsigned ldif_num_handlers; - struct ldb_ldif_handler *ldif_handlers; + struct ldb_schema schema; }; /* the modules init function */ @@ -146,4 +161,34 @@ int lsqlite3_connect(struct ldb_context *ldb, struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); +const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, + const char *attrib); + +int ldb_match_message(struct ldb_context *ldb, + struct ldb_message *msg, + struct ldb_parse_tree *tree, + const char *base, + enum ldb_scope scope); + +void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); +const struct ldb_attrib_handler *ldb_attrib_handler_syntax(struct ldb_context *ldb, + const char *syntax); +int ldb_set_attrib_handlers(struct ldb_context *ldb, + const struct ldb_attrib_handler *handlers, + unsigned num_handlers); +int ldb_setup_wellknown_attributes(struct ldb_context *ldb); + +struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); +char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn); +int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn); +const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); +void ldb_subclass_remove(struct ldb_context *ldb, const char *class); +int ldb_subclass_add(struct ldb_context *ldb, const char *class, const char *subclass); + +int ldb_handler_copy(struct ldb_context *ldb, + const struct ldb_val *in, struct ldb_val *out); +int ldb_comparison_binary(struct ldb_context *ldb, + const struct ldb_val *v1, const struct ldb_val *v2); + #endif -- cgit From 1c5105065a44173667de2a022dd2417e56b527d6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 2 Jul 2005 17:30:03 +0000 Subject: r8082: large rewite of ldb_dn.c - we do not support multpiple attribute components anymore, makes code a lot easier they will be readded later if we found out they are really used, so far my tests show w2k3 do not handle them as well - fix escaping issues, move component value to be in an ldb_val structure still need to handle binary values case - make cononicalize functions leak less memory by giving a specific memory context - fix tests scripts so that test-ldap can start - make test not delete databases on completion so that I can inspect them (This used to be commit 624a73148d125690ce18515f19231d26df207738) --- source4/lib/ldb/include/ldb.h | 4 ++-- source4/lib/ldb/include/ldb_dn.h | 41 ----------------------------------- source4/lib/ldb/include/ldb_private.h | 28 +++++++++++++++++++----- 3 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 source4/lib/ldb/include/ldb_dn.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 868d005399..1f642d3bff 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -188,8 +188,8 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); /* functions for controlling attribute handling */ -typedef int (*ldb_attr_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *); -typedef int (*ldb_attr_comparison_t)(struct ldb_context *, const struct ldb_val *, const struct ldb_val *); +typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); struct ldb_attrib_handler { const char *attr; diff --git a/source4/lib/ldb/include/ldb_dn.h b/source4/lib/ldb/include/ldb_dn.h deleted file mode 100644 index 723b89e316..0000000000 --- a/source4/lib/ldb/include/ldb_dn.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Unix SMB/CIFS implementation. - LDAP server - Copyright (C) Simo Sorce 2004 - Copyright (C) Derrell Lipman 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -struct ldb_dn_attribute { - char *name; - char *value; -}; - -struct ldb_dn_component { - int attr_num; - struct ldb_dn_attribute **attributes; -}; - -struct ldb_dn { - int comp_num; - struct ldb_dn_component **components; -}; - - -struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); -char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn); -int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 43c925e036..1d7d453767 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -1,8 +1,9 @@ /* ldb database library - Copyright (C) Andrew Tridgell 2004 + Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 + Copyright (C) Simo Sorce 2004 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -105,6 +106,16 @@ struct ldb_context { struct ldb_schema schema; }; +/* internal ldb exploded dn structures */ +struct ldb_dn_component { + char *name; + struct ldb_val value; +}; +struct ldb_dn { + int comp_num; + struct ldb_dn_component *components; +}; + /* the modules init function */ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]); @@ -178,17 +189,22 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb, unsigned num_handlers); int ldb_setup_wellknown_attributes(struct ldb_context *ldb); + +/* The following definitions come from lib/ldb/common/ldb_dn.c */ struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); -char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn); -int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn); +char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); +int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); + + +/* The following definitions come from lib/ldb/common/ldb_attributes.c */ const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); void ldb_subclass_remove(struct ldb_context *ldb, const char *class); int ldb_subclass_add(struct ldb_context *ldb, const char *class, const char *subclass); -int ldb_handler_copy(struct ldb_context *ldb, +int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, const struct ldb_val *in, struct ldb_val *out); -int ldb_comparison_binary(struct ldb_context *ldb, +int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, const struct ldb_val *v1, const struct ldb_val *v2); #endif -- cgit From 7c78ec0e145064696552d750eaaa70f00a0882e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Jul 2005 05:56:06 +0000 Subject: r8342: allow ldb_ldif_read_string() to continue in the string, so you can read multiple records (This used to be commit 4b11c00421b5152fd7d4be0be0db983bb310021d) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1f642d3bff..b2468b6ecb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -316,7 +316,7 @@ void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); -struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); +struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char **s); int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); int ldb_base64_decode(char *s); -- cgit From c9b0e86a436b5b169a4c33bd25eac379cb622b17 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 12 Jul 2005 12:04:54 +0000 Subject: r8373: New wildcard matching code. This code applies correct ldap standard wildcard matching code removes WILDCARD matching from tdb @ATTRIBUTES, that's now handled independently adds some more tests for wildcard matching fixes dn comparison code in ldb_match (This used to be commit 4eb5863042011988d85092d7dde3d809aa15bd59) --- source4/lib/ldb/include/ldb.h | 14 +++++++++++--- source4/lib/ldb/include/ldb_private.h | 13 +++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b2468b6ecb..8233e78f0e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -154,7 +154,8 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, + LDB_OP_SUBSTRING=3, LDB_OP_PRESENT=4, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; struct ldb_parse_tree { @@ -164,6 +165,15 @@ struct ldb_parse_tree { char *attr; struct ldb_val value; } simple; + struct { + char *attr; + } present; + struct { + char *attr; + int start_with_wildcard; + int end_with_wildcard; + struct ldb_val **chunks; + } substring; struct { char *attr; int dnAttributes; @@ -211,14 +221,12 @@ struct ldb_attrib_handler { }; #define LDB_ATTR_FLAG_HIDDEN (1<<0) -#define LDB_ATTR_FLAG_WILDCARD (1<<1) /* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ #define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12" #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" #define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27" #define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40" -#define LDB_SYNTAX_WILDCARD "LDB_SYNTAX_WILDCARD" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 1d7d453767..da813eb588 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -175,11 +175,11 @@ struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *optio const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char *attrib); -int ldb_match_message(struct ldb_context *ldb, - struct ldb_message *msg, - struct ldb_parse_tree *tree, - const char *base, - enum ldb_scope scope); +int ldb_match_msg(struct ldb_context *ldb, + struct ldb_message *msg, + struct ldb_parse_tree *tree, + const char *base, + enum ldb_scope scope); void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); const struct ldb_attrib_handler *ldb_attrib_handler_syntax(struct ldb_context *ldb, @@ -193,9 +193,10 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb); /* The following definitions come from lib/ldb/common/ldb_dn.c */ struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); +int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); - +struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn); /* The following definitions come from lib/ldb/common/ldb_attributes.c */ const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); -- cgit From 52bef30fd48393fa7b24ade7622c758373bd6dbe Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Jul 2005 05:55:28 +0000 Subject: r8414: Some C++ friendlyness fixes - 'not' is apparently a keyword in C++. (This used to be commit bcfb3a45e4a5962fe763f8071d4458f4bd11605b) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8233e78f0e..c2d7b0d614 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -186,7 +186,7 @@ struct ldb_parse_tree { } list; struct { struct ldb_parse_tree *child; - } not; + } isnot; } u; }; -- cgit From cb2c43f7b032c26adf82f3ba7d6e3dc855f89fa4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 16 Jul 2005 18:16:32 +0000 Subject: r8515: ldb_dn_cmp now uses ldb_dn_compare so that the DNs are compared on a content level not ona form level, his means that the 2 DNs: a) cn= user, dc=this, dc = is,dc=test b) cn=user,dc=this,dc=is,dc=test are now identical even if the string form differ (spaces) (This used to be commit 76d496c30867ae80434483a34b0d842523aed762) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c2d7b0d614..485e2bc730 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -335,7 +335,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* useful functions for ldb_message structure manipulation */ -int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); /* case-fold a DN */ -- cgit From bfb11862698743ee36bc6050269378321e6e577c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 19 Jul 2005 09:09:00 +0000 Subject: r8585: add to ldb and ldap comparison functionality better pares filters Approx is currently only a stub need to dig more info to understand what it really means and how it works exactly (This used to be commit a9e8cd0bad27ed2b3c6a12302e787ba3c9a70a3c) --- source4/lib/ldb/include/ldb.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 485e2bc730..6670089902 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -154,26 +154,34 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, - LDB_OP_SUBSTRING=3, LDB_OP_PRESENT=4, - LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; +enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, + LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, + LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, + LDB_OP_APPROX=9, LDB_OP_EXTENDED=10 }; struct ldb_parse_tree { enum ldb_parse_op operation; union { struct { - char *attr; - struct ldb_val value; - } simple; + struct ldb_parse_tree *child; + } isnot; struct { char *attr; - } present; + struct ldb_val value; + } equality; struct { char *attr; int start_with_wildcard; int end_with_wildcard; struct ldb_val **chunks; } substring; + struct { + char *attr; + } present; + struct { + char *attr; + struct ldb_val value; + } comparison; struct { char *attr; int dnAttributes; @@ -184,9 +192,6 @@ struct ldb_parse_tree { unsigned int num_elements; struct ldb_parse_tree **elements; } list; - struct { - struct ldb_parse_tree *child; - } isnot; } u; }; -- cgit From 7a8ac7588720ebd1ea61a539ca4040d322c4fcf2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jul 2005 01:56:22 +0000 Subject: r8659: return ldif formatted attributes in the ejs ldb search call, so sids show up as strings not binary blobs (This used to be commit d2c29a5a51f68cabb9ef587376bf0a6b936cdd76) --- source4/lib/ldb/include/ldb.h | 3 +++ source4/lib/ldb/include/ldb_private.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6670089902..7399b8ffe7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -440,4 +440,7 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); +const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, + const char *attrib); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index da813eb588..0abf056db4 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -172,9 +172,6 @@ int lsqlite3_connect(struct ldb_context *ldb, struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); -const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, - const char *attrib); - int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, struct ldb_parse_tree *tree, -- cgit From 768585b1dd3fcc2f2180528bd94e1fef4a6ead7b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 26 Jul 2005 09:17:46 +0000 Subject: r8779: Add rdn module to makefile and headers Search by distinguishedName as if searching by dn (This used to be commit 1d4046136255aead319ab08da229146dbd285b38) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 0abf056db4..43e6a3ecba 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -171,6 +171,8 @@ int lsqlite3_connect(struct ldb_context *ldb, const char *options[]); struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); + int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, -- cgit From 6195932b4241d94453438a857179debc08495ece Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 11:15:15 +0000 Subject: r9387: regedit uses "New Key #nn" for newly created keys, which conflicts with the stricter DN rules in ldb. Escape the DN components to cope. Simo, sorry for making a change in ldb_dn.c while you have changes pending. Please feel free to revert these and switch reg_backend_ldb.c to use the new dn construction code. (This used to be commit 136ecf5cb23758558b4119b08047fc273be8b0f8) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7399b8ffe7..fdf5dc8d91 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -342,6 +342,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); +char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); /* case-fold a DN */ char *ldb_dn_fold(void * mem_ctx, -- cgit From 3e4c4cff2177af33efdb15f03a1bbcb639505cee Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 15:02:01 +0000 Subject: r9391: Convert all the code to use struct ldb_dn to ohandle ldap like distinguished names Provide more functions to handle DNs in this form (This used to be commit 692e35b7797e39533dd2a1c4b63d9da30f1eb5ba) --- source4/lib/ldb/include/ldb.h | 57 ++++++++++++++++++++++++++--------- source4/lib/ldb/include/ldb_private.h | 39 ++++++------------------ 2 files changed, 52 insertions(+), 44 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fdf5dc8d91..13c9b72e6d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -64,6 +64,16 @@ struct ldb_val { }; #endif +/* internal ldb exploded dn structures */ +struct ldb_dn_component { + char *name; + struct ldb_val value; +}; +struct ldb_dn { + int comp_num; + struct ldb_dn_component *components; +}; + /* these flags are used in ldd_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify whether attributes are being added, deleted or modified */ @@ -95,7 +105,7 @@ struct ldb_message_element { number of elements. */ struct ldb_message { - char *dn; + struct ldb_dn *dn; unsigned int num_elements; struct ldb_message_element *elements; void *private_data; /* private to the backend */ @@ -259,7 +269,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co use talloc_free to free the ldb_message returned */ int ldb_search(struct ldb_context *ldb, - const char *base, + const const struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); @@ -268,7 +278,7 @@ int ldb_search(struct ldb_context *ldb, like ldb_search() but takes a parse tree */ int ldb_search_bytree(struct ldb_context *ldb, - const char *base, + const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_message ***res); @@ -289,7 +299,7 @@ int ldb_modify(struct ldb_context *ldb, /* rename a record in the database */ -int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn); +int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); /* create a named lock @@ -304,7 +314,7 @@ int ldb_unlock(struct ldb_context *ldb, const char *lockname); /* delete a record from the database */ -int ldb_delete(struct ldb_context *ldb, const char *dn); +int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); /* @@ -337,19 +347,38 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers); +/* The following definitions come from lib/ldb/common/ldb_dn.c */ +BOOL ldb_dn_is_special(const struct ldb_dn *dn); +BOOL ldb_dn_check_special(const struct ldb_dn *dn, const char *check); +char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); +struct ldb_dn *ldb_dn_new(void *mem_ctx); +struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); +char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); +char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); +int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); +int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); +struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el); +struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn); +struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn); +struct ldb_dn_component *ldb_dn_build_component(void *mem_ctx, const char *attr, + const char *val); +struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr, + const char * value, + const struct ldb_dn *base); +struct ldb_dn *ldb_dn_make_child(void *mem_ctx, + const struct ldb_dn_component *component, + const struct ldb_dn *base); +struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); +struct ldb_dn *ldb_dn_compose_string_dn(void *mem_ctx, const char *dn1, const struct ldb_dn *dn2); +struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ - int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -/* case-fold a DN */ -char *ldb_dn_fold(void * mem_ctx, - const char * dn, - void * user_data, - int (* case_fold_attr_fn)(void * user_data, char * attr)); - /* create an empty message */ struct ldb_message *ldb_msg_new(void *mem_ctx); @@ -411,9 +440,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, void ldb_msg_sort_elements(struct ldb_message *msg); -void ldb_msg_free(struct ldb_context *ldb, struct ldb_message *msg); - -struct ldb_message *ldb_msg_copy(struct ldb_context *ldb, +struct ldb_message *ldb_msg_copy(void *mem_ctx, const struct ldb_message *msg); struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 43e6a3ecba..f5b50f5fc0 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -56,14 +56,14 @@ struct ldb_module { */ struct ldb_module_ops { const char *name; - int (*search)(struct ldb_module *, const char *, enum ldb_scope, + int (*search)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); - int (*search_bytree)(struct ldb_module *, const char *, enum ldb_scope, + int (*search_bytree)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope, struct ldb_parse_tree *, const char * const [], struct ldb_message ***); int (*add_record)(struct ldb_module *, const struct ldb_message *); int (*modify_record)(struct ldb_module *, const struct ldb_message *); - int (*delete_record)(struct ldb_module *, const char *); - int (*rename_record)(struct ldb_module *, const char *, const char *); + int (*delete_record)(struct ldb_module *, const struct ldb_dn *); + int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *); int (*named_lock)(struct ldb_module *, const char *); int (*named_unlock)(struct ldb_module *, const char *); const char * (*errstring)(struct ldb_module *); @@ -106,16 +106,6 @@ struct ldb_context { struct ldb_schema schema; }; -/* internal ldb exploded dn structures */ -struct ldb_dn_component { - char *name; - struct ldb_val value; -}; -struct ldb_dn { - int comp_num; - struct ldb_dn_component *components; -}; - /* the modules init function */ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]); @@ -132,19 +122,19 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, int ldb_load_modules(struct ldb_context *ldb, const char *options[]); int ldb_next_search(struct ldb_module *module, - const char *base, + const struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); int ldb_next_search_bytree(struct ldb_module *module, - const char *base, + const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_message ***res); int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); -int ldb_next_delete_record(struct ldb_module *module, const char *dn); -int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn); +int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn); +int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn); int ldb_next_named_lock(struct ldb_module *module, const char *lockname); int ldb_next_named_unlock(struct ldb_module *module, const char *lockname); const char *ldb_next_errstring(struct ldb_module *module); @@ -174,10 +164,10 @@ struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *optio struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); -int ldb_match_msg(struct ldb_context *ldb, +int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, struct ldb_parse_tree *tree, - const char *base, + const struct ldb_dn *base, enum ldb_scope scope); void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); @@ -188,15 +178,6 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb, unsigned num_handlers); int ldb_setup_wellknown_attributes(struct ldb_context *ldb); - -/* The following definitions come from lib/ldb/common/ldb_dn.c */ -struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); -char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); -int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); -int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); -struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn); - /* The following definitions come from lib/ldb/common/ldb_attributes.c */ const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); void ldb_subclass_remove(struct ldb_context *ldb, const char *class); -- cgit From ac90ddfdb28050912ecab0e998089b93216c5c35 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:18:48 +0000 Subject: r9392: Fix ldb_dn_compose to make build farm happy Add ldb_dn_string_compose so that you can build a dn starting from a struct ldb_dn base and a set of parameters to be composed in a format string with the same syntax of printf (This used to be commit 31c69d0655752cc8ea3bc5b7ea87792291302091) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13c9b72e6d..e7862522e4 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -371,7 +371,7 @@ struct ldb_dn *ldb_dn_make_child(void *mem_ctx, const struct ldb_dn_component *component, const struct ldb_dn *base); struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); -struct ldb_dn *ldb_dn_compose_string_dn(void *mem_ctx, const char *dn1, const struct ldb_dn *dn2); +struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...); struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ -- cgit From 7c7b93f6497737a09d3e76a626ee4f20284effde Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:27:09 +0000 Subject: r9393: Fix ldb standalone build (This used to be commit 796d0ea2fcf5132b157a397cc1a54aa26c042691) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e7862522e4..fc447102d6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -348,6 +348,11 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, unsigned num_handlers); /* The following definitions come from lib/ldb/common/ldb_dn.c */ + +#ifndef BOOL +typedef int BOOL; +#endif + BOOL ldb_dn_is_special(const struct ldb_dn *dn); BOOL ldb_dn_check_special(const struct ldb_dn *dn, const char *check); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -- cgit From f2ac4b8d6b24bec9aecfe00daf8c0b4ccf3964a6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:41:27 +0000 Subject: r9394: avoid to use BOOL in ldb (This used to be commit d2055849fba56e8620403621f3fb9684f24e853f) --- source4/lib/ldb/include/ldb.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fc447102d6..89e88fd4e9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -349,12 +349,8 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* The following definitions come from lib/ldb/common/ldb_dn.c */ -#ifndef BOOL -typedef int BOOL; -#endif - -BOOL ldb_dn_is_special(const struct ldb_dn *dn); -BOOL ldb_dn_check_special(const struct ldb_dn *dn, const char *check); +int ldb_dn_is_special(const struct ldb_dn *dn); +int ldb_dn_check_special(const struct ldb_dn *dn, const char *check); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); struct ldb_dn *ldb_dn_new(void *mem_ctx); struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); -- cgit From 69fb6840637e07318914d632571c8481f3573461 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 25 Aug 2005 19:02:03 +0000 Subject: r9621: Bunch of bug fixes. Add 'format' option to samba3dump (text,summary,ldif) (This used to be commit dc6aab8d4a6d0fe47756c90d3d311b6009d571ff) --- source4/lib/ldb/include/ldb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 89e88fd4e9..46b359b8ba 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -162,8 +162,7 @@ struct ldb_debug_ops { #define PRINTF_ATTRIBUTE(a,b) #endif - -/* structues for ldb_parse_tree handling code */ +/* structures for ldb_parse_tree handling code */ enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, -- cgit From a45c4fd5e24c8ae50bd86c6c84d1a3278e1bdab6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 25 Aug 2005 23:05:41 +0000 Subject: r9625: Get rid of "duplicate const" warning. (This used to be commit 0ec755cfa0499bf1f271584db3c028d87973f1af) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 46b359b8ba..66b0343891 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -268,7 +268,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co use talloc_free to free the ldb_message returned */ int ldb_search(struct ldb_context *ldb, - const const struct ldb_dn *base, + const struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); -- cgit From 8919d6bf9a88ce9ac43dae61989c33082c984b66 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 17 Sep 2005 19:25:50 +0000 Subject: r10299: remove the public (un)lock functions and introduce a transaction based private ldb API ldb_sqlite3 is already working with this model and ldb_tdb will do as soon as tridge finishes the tdb transaction code. currently the transactions are always implicit and wrap any single ldb API call except searching, the transaction functions are currently not made public on purpose. Simo. (This used to be commit 1da4ac2cdcb7e54076f85242a93784260dced918) --- source4/lib/ldb/include/ldb_private.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index f5b50f5fc0..e55a19c28c 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -64,8 +64,8 @@ struct ldb_module_ops { int (*modify_record)(struct ldb_module *, const struct ldb_message *); int (*delete_record)(struct ldb_module *, const struct ldb_dn *); int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *); - int (*named_lock)(struct ldb_module *, const char *); - int (*named_unlock)(struct ldb_module *, const char *); + int (*start_transaction)(struct ldb_module *); + int (*end_transaction)(struct ldb_module *, int); const char * (*errstring)(struct ldb_module *); }; @@ -135,8 +135,8 @@ int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *mes int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn); int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn); -int ldb_next_named_lock(struct ldb_module *module, const char *lockname); -int ldb_next_named_unlock(struct ldb_module *module, const char *lockname); +int ldb_next_start_trans(struct ldb_module *module); +int ldb_next_end_trans(struct ldb_module *module, int status); const char *ldb_next_errstring(struct ldb_module *module); /* The following definitions come from lib/ldb/common/ldb_debug.c */ -- cgit From eebe0c269e241404b69e385fbc135018acb5cb5e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 10:45:28 +0000 Subject: r10302: Introduce ldap like error codes (This used to be commit cbe438be6d9b1b7182ab3e63607a2e5b2d5456fb) --- source4/lib/ldb/include/ldb_errors.h | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 source4/lib/ldb/include/ldb_errors.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h new file mode 100644 index 0000000000..38c42280d0 --- /dev/null +++ b/source4/lib/ldb/include/ldb_errors.h @@ -0,0 +1,91 @@ +/* + ldb database library + + Copyright (C) Simo Sorce 2005 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb header + * + * Description: defines error codes following RFC 2251 ldap error codes + * + * Author: Simo Sorce + */ + +#ifndef _LDB_ERRORS_H_ +#define _LDB_ERRORS_H_ 1 + +/* + * Not all error codes make sense for ldb, + * but they are keept here for reference anyway + */ + +#define LDB_ERR_SUCCESS 0 +#define LDB_ERR_OPERATIONS_ERROR 1 +#define LDB_ERR_PROTOCOL_ERROR 2 +#define LDB_ERR_TIME_LIMIT_EXCEEDED 3 +#define LDB_ERR_SIZE_LIMIT_EXCEEDED 4 +#define LDB_ERR_COMPARE_FALSE 5 +#define LDB_ERR_COMPARE_TRUE 6 +#define LDB_ERR_AUTH_METHOD_NOT_SUPPORTED 7 +#define LDB_ERR_STRONG_AUTH_REQUIRED 8 +/* 9 RESERVED */ +#define LDB_ERR_REFERRAL 10 +#define LDB_ERR_ADMIN_LIMIT_EXCEEDED 11 +#define LDB_ERR_UNAVAILABLE_CRITICAL_EXTENSION 12 +#define LDB_ERR_CONFIDENTIALITY_REQUIRED 13 +#define LDB_ERR_SASL_BIND_IN_PROGRESS 14 +#define LDB_ERR_NO_SUCH_ATTRIBUTE 16 +#define LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE 17 +#define LDB_ERR_INAPPROPRIATE_MATCHING 18 +#define LDB_ERR_CONSTRAINT_VIOLAION 19 +#define LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS 20 +#define LDB_ERR_INVALID_ATTRIBUTE_SYNTAX 21 +/* 22-31 unused */ +#define LDB_ERR_NO_SUCH_OBJECT 32 +#define LDB_ERR_ALIAS_PROBLEM 33 +#define LDB_ERR_INVALID_DN_SYNTAX 34 +/* 53 RESERVED */ +#define LDB_ERR_ALIAS_DEREFERENCING_PROBLEM 36 +/* 37-47 unused */ +#define LDB_ERR_INAPPROPRIATE_AUTHENTICATION 48 +#define LDB_ERR_INVALID_CREDENTIALS 49 +#define LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS 50 +#define LDB_ERR_BUSY 51 +#define LDB_ERR_UNAVAILABLE 52 +#define LDB_ERR_UNWILLING_TO_PERFORM 53 +#define LDB_ERR_LOOP_DETECT 54 +/* 55-63 unused */ +#define LDB_ERR_NAMING_VIOLATION 64 +#define LDB_ERR_OBJECT_CLASS_VIOLATION 65 +#define LDB_ERR_NOT_ALLOWED_ON_NON_LEAF 66 +#define LDB_ERR_NOT_ALLOWED_ON_RDN 67 +#define LDB_ERR_ENTRY_ALREADY_EXISTS 68 +#define LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED 69 +/* 70 RESERVED FOR CLDAP */ +#define LDB_ERR_AFFECTS_MULTIPLE_DSAS 71 +/* 72-79 unused */ +#define LDB_ERR_OTHER 80 +/* 81-90 RESERVED for APIs */ + +#endif /* _LDB_ERRORS_H_ */ -- cgit From 46a8d809376cab59c579c654b0de5105727a9585 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 10:47:03 +0000 Subject: r10304: check for basic ldb_message sanity and return appropriate LDB_ERR_ value (This used to be commit 610f5646f0816820ac9342e81d46d139e26cc918) --- source4/lib/ldb/include/ldb.h | 3 +++ source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 66b0343891..008327eb05 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -3,6 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 + Copyright (C) Simo Sorce 2005 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -451,6 +452,8 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +int ldb_msg_sanity_check(const struct ldb_message *msg); + struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); /* diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e55a19c28c..96cd458920 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -3,7 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 - Copyright (C) Simo Sorce 2004 + Copyright (C) Simo Sorce 2004-2005 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released -- cgit From 16aff2a184f7fab64d718b356056070e305e99e9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 18:49:06 +0000 Subject: r10305: start implementing better error handling changed the prioivate modules API error string are now not spread over all modules but are kept in a single place. This allows a better control of memory and error reporting. (This used to be commit 3fc676ac1d6f59d08bedbbd9377986154cf84ce4) --- source4/lib/ldb/include/ldb_private.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 96cd458920..7eb2bca679 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -66,7 +66,6 @@ struct ldb_module_ops { int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *); int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *, int); - const char * (*errstring)(struct ldb_module *); }; @@ -104,6 +103,8 @@ struct ldb_context { } *opaque; struct ldb_schema schema; + + char *err_string; }; /* the modules init function */ @@ -137,7 +138,8 @@ int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn); int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn); int ldb_next_start_trans(struct ldb_module *module); int ldb_next_end_trans(struct ldb_module *module, int status); -const char *ldb_next_errstring(struct ldb_module *module); + +void ldb_set_errstring(struct ldb_module *module, char *err_string); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -- cgit From d78ea3e34abd30fb388c4cc39e12611e211416a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 04:16:46 +0000 Subject: r10406: added --nosync option to all ldb tools, so that you can control if transactions are synchronous or not on the command line. add LDB_FLG_NOSYNC flag to ldb_connect() so we can make our temporary ldb databases non-synchronous (This used to be commit dba41164e0c52f1e4351bd9057b16661cee3a822) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 008327eb05..f7abd920eb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -158,6 +158,7 @@ struct ldb_debug_ops { }; #define LDB_FLG_RDONLY 1 +#define LDB_FLG_NOSYNC 2 #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) -- cgit From 2ce3b5a00347cc3120efd12cd58d52a5c43305b3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 22 Sep 2005 09:06:37 +0000 Subject: r10419: Remove unused prototypes of locking functions (thanks Jelmer) omment about transactions (This used to be commit 33352507593875a147276841fdb70de8edd668f5) --- source4/lib/ldb/include/ldb.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f7abd920eb..0e794c6209 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -49,6 +49,7 @@ major restrictions as compared to tdb: - no explicit locking calls + UPDATE: we have transactions now, better than locking --SSS. */ @@ -302,16 +303,6 @@ int ldb_modify(struct ldb_context *ldb, */ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); -/* - create a named lock -*/ -int ldb_lock(struct ldb_context *ldb, const char *lockname); - -/* - release a named lock -*/ -int ldb_unlock(struct ldb_context *ldb, const char *lockname); - /* delete a record from the database */ -- cgit From 63b43dd12fb579aaaccedd07aaa630cb1cd7aa88 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 24 Sep 2005 15:42:15 +0000 Subject: r10477: expose transactions outside ldb and change the API once more do not autostart transactions on ldb operations if a transaction is already in place test transactions on winsdb all my tests passes so far tridge please confirm this is ok for you (This used to be commit c2bb2a36bdbe0ec7519697a9a9ba7526a0defac2) --- source4/lib/ldb/include/ldb.h | 15 +++++++++++++++ source4/lib/ldb/include/ldb_errors.h | 2 +- source4/lib/ldb/include/ldb_private.h | 8 ++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0e794c6209..f371c340cc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -308,6 +308,21 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +/* + start a transaction +*/ +int ldb_transaction_start(struct ldb_context *ldb); + +/* + commit a transaction +*/ +int ldb_transaction_commit(struct ldb_context *ldb); + +/* + cancel a transaction +*/ +int ldb_transaction_cancel(struct ldb_context *ldb); + /* return extended error information from the last call diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index 38c42280d0..f59b39f92a 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -40,7 +40,7 @@ * but they are keept here for reference anyway */ -#define LDB_ERR_SUCCESS 0 +#define LDB_SUCCESS 0 #define LDB_ERR_OPERATIONS_ERROR 1 #define LDB_ERR_PROTOCOL_ERROR 2 #define LDB_ERR_TIME_LIMIT_EXCEEDED 3 diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 7eb2bca679..2a9139df40 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -65,7 +65,8 @@ struct ldb_module_ops { int (*delete_record)(struct ldb_module *, const struct ldb_dn *); int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *); int (*start_transaction)(struct ldb_module *); - int (*end_transaction)(struct ldb_module *, int); + int (*end_transaction)(struct ldb_module *); + int (*del_transaction)(struct ldb_module *); }; @@ -105,6 +106,8 @@ struct ldb_context { struct ldb_schema schema; char *err_string; + + int transaction_active; }; /* the modules init function */ @@ -137,7 +140,8 @@ int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message * int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn); int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn); int ldb_next_start_trans(struct ldb_module *module); -int ldb_next_end_trans(struct ldb_module *module, int status); +int ldb_next_end_trans(struct ldb_module *module); +int ldb_next_del_trans(struct ldb_module *module); void ldb_set_errstring(struct ldb_module *module, char *err_string); -- cgit From 675f81eed3086682faeca34e56d441c6e38bd800 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Sep 2005 03:11:08 +0000 Subject: r10525: change from AC_CHECK_TYPES() to AC_CHECK_TYPE() for intptr_t, so the type is always available, which means we need less #ifdefs (This used to be commit d4af4b11ae69a63fa3b2048e6d576055d86d2bb4) --- source4/lib/ldb/include/includes.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 8b513e20c7..4372d6b3f9 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -26,9 +26,5 @@ #include "ldb_private.h" #include "talloc.h" -#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) #define discard_const(ptr) ((void *)((intptr_t)(ptr))) -#else -#define discard_const(ptr) ((void *)(ptr)) -#endif #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -- cgit From 0e90afb4e7737d60d902aee1df4cbeb85a7b693d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 Sep 2005 10:18:26 +0000 Subject: r10603: neaten up the ldb module initialisation code (This used to be commit 8e7c4c98a7b4fd814f298fba1b6b686cb58339f8) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f371c340cc..73bac2088a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -143,6 +143,10 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_module; +/* module initialisation function */ +typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); + + /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; -- cgit From 5fd031c97daaa1bf09a7ad80550753acd434075f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Oct 2005 05:24:46 +0000 Subject: r10753: don't require every ldb module to implement both a search_bytree() and a search() function, instead each module now only implements the bytree method, and the expression based search is handled generically by the modules code. This makes for more consistency and less code duplication. fixed the tdb backend to handle BASE searches much more efficiently. They now always only lookup one record, regardless of the search expression (This used to be commit 7e44f9153c5578624e2fca04cdc0a00af0fd9eb4) --- source4/lib/ldb/include/ldb_private.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 2a9139df40..9777ad0d92 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -56,8 +56,6 @@ struct ldb_module { */ struct ldb_module_ops { const char *name; - int (*search)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); int (*search_bytree)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope, struct ldb_parse_tree *, const char * const [], struct ldb_message ***); int (*add_record)(struct ldb_module *, const struct ldb_message *); @@ -126,10 +124,10 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, int ldb_load_modules(struct ldb_context *ldb, const char *options[]); int ldb_next_search(struct ldb_module *module, - const struct ldb_dn *base, - enum ldb_scope scope, - const char *expression, - const char * const *attrs, struct ldb_message ***res); + const struct ldb_dn *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, struct ldb_message ***res); int ldb_next_search_bytree(struct ldb_module *module, const struct ldb_dn *base, enum ldb_scope scope, -- cgit From a599edf04cbdeef9014923ba0d3713b8ff84f266 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:10:23 +0000 Subject: r10913: This patch isn't as big as it looks ... most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57) --- source4/lib/ldb/include/ldb.h | 44 ++++++++++++++++++++++------------- source4/lib/ldb/include/ldb_private.h | 2 ++ 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 73bac2088a..d75ca4fe86 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -182,24 +182,24 @@ struct ldb_parse_tree { struct ldb_parse_tree *child; } isnot; struct { - char *attr; + const char *attr; struct ldb_val value; } equality; struct { - char *attr; + const char *attr; int start_with_wildcard; int end_with_wildcard; struct ldb_val **chunks; } substring; struct { - char *attr; + const char *attr; } present; struct { - char *attr; + const char *attr; struct ldb_val value; } comparison; struct { - char *attr; + const char *attr; int dnAttributes; char *rule_id; struct ldb_val value; @@ -241,7 +241,10 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; -#define LDB_ATTR_FLAG_HIDDEN (1<<0) +#define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ + /* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ #define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12" @@ -383,7 +386,7 @@ struct ldb_dn *ldb_dn_make_child(void *mem_ctx, const struct ldb_dn_component *component, const struct ldb_dn *base); struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); -struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...); +struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ @@ -406,22 +409,19 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); /* add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_context *ldb, - struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); /* add a element to a ldb_message */ -int ldb_msg_add(struct ldb_context *ldb, - struct ldb_message *msg, +int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); -int ldb_msg_add_value(struct ldb_context *ldb, - struct ldb_message *msg, +int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val); -int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, +int ldb_msg_add_string(struct ldb_message *msg, const char *attr_name, const char *str); -int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, - const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5); +int ldb_msg_add_fmt(struct ldb_message *msg, + const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, @@ -485,4 +485,16 @@ void *ldb_get_opaque(struct ldb_context *ldb, const char *name); const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char *attrib); + +const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +int ldb_attr_in_list(const char * const *attrs, const char *attr); + + +void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, + const char *attr, + const char *replace); + +void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 9777ad0d92..2367d6c3f8 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -145,6 +145,8 @@ void ldb_set_errstring(struct ldb_module *module, char *err_string); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); +void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, + const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); -- cgit From 33da2fabe6c3b1e20a955d72e1ebd0e850751df0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:30:47 +0000 Subject: r10914: moved the ldap time string functions into ldb so they can be used by the time attribute handling functions (This used to be commit 93c296d52718e77f8b702e1721b548eaadc56c76) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d75ca4fe86..0af88f8427 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -497,4 +497,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); +time_t ldb_string_to_time(const char *s); + #endif -- cgit From 49cc13a8f0fbc4f68e14720b733329ce45135cec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 07:54:15 +0000 Subject: r10915: added a standard attribute handler for a ldap UTC time string (This used to be commit efd7dd1a775c06f21924f35760f7768b4e8db449) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0af88f8427..d346d0edac 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -251,6 +251,7 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" #define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27" #define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40" +#define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* @@ -452,6 +453,8 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, void ldb_msg_sort_elements(struct ldb_message *msg); +struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, + const struct ldb_message *msg); struct ldb_message *ldb_msg_copy(void *mem_ctx, const struct ldb_message *msg); -- cgit From 35720734911169acde6bf9f2c9a1f83336744f6f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 07:57:39 +0000 Subject: r10916: - finished the 'operational' ldb module - removed the timestamps module, replacing it with the operational module - added a ldb_msg_copy_shallow() function which should be used when a module wants to add new elements to a message on add/modify. This is needed because the caller might be using a constant structure, or may want to re-use the structure again - enabled the UTC time attribute syntaxes in the operational module (This used to be commit 61e8b010223ac6a0573185008f3719ba29574688) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 2367d6c3f8..e444b7235a 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -183,6 +183,8 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers); int ldb_setup_wellknown_attributes(struct ldb_context *ldb); +int ldb_set_attrib_handler_syntax(struct ldb_context *ldb, + const char *attr, const char *syntax); /* The following definitions come from lib/ldb/common/ldb_attributes.c */ const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); -- cgit From dc3e65b25295f68d0c7c5d3a7cc9bade638661f4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 08:11:45 +0000 Subject: r10917: copy the element name in a ldb_msg_rename_attr() and ldb_msg_copy_attr() to ensure that callers (like the ldap server) can talloc_steal the name (This used to be commit 9c914542cc346758c82f89990c80eb096a9c0959) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d346d0edac..3629d9ec47 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -497,7 +497,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, const char *attr, const char *replace); -void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); -- cgit From c8978cb1f15b1ddc0c420baa568bd11db080b744 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 08:51:12 +0000 Subject: r10918: - fixed standalone ldb build - added note about allowedAttributesEffective (will be needed for mmc) - fixed some more ldb warnings (This used to be commit e9e4d81b6976549db8a7668572a5da466fbec4a9) --- source4/lib/ldb/include/ldb.h | 6 +++--- source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3629d9ec47..adc8a3e061 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -453,7 +453,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, void ldb_msg_sort_elements(struct ldb_message *msg); -struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, +struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, const struct ldb_message *msg); struct ldb_message *ldb_msg_copy(void *mem_ctx, const struct ldb_message *msg); @@ -489,7 +489,7 @@ const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char *attrib); -const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); int ldb_attr_in_list(const char * const *attrs, const char *attr); @@ -500,7 +500,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); -char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); +char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e444b7235a..3fb73a93b7 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -165,7 +165,7 @@ int lsqlite3_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); -- cgit From 1307149624bcda8c45d538c33a46c4f3b9058afb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Oct 2005 14:58:14 +0000 Subject: r10924: we don't need this line twice metze (This used to be commit f1ee8d4b58d97888dc4c57af34c7604ee9dd2a73) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index adc8a3e061..fd3577a470 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -243,7 +243,6 @@ struct ldb_attrib_handler { #define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ #define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ /* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ -- cgit From d96f706bb0a6b41eddec9d467ef3d5f31bee41ab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 13 Oct 2005 04:24:49 +0000 Subject: r10953: Add a new function to form a canonicalName out of a DN to ldb_dn.c Use this new function in the client and server for the CrackNames case, where we particularly need it. Andrew Bartlett (This used to be commit 380037ee09ef8293bdb288d6c015e7c80f180a30) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fd3577a470..27313613ab 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -502,4 +502,6 @@ int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *rep char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); +char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); #endif -- cgit From 0fa924bb8f446e35a0fd543cda20b23c81e7dc9e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Oct 2005 05:04:16 +0000 Subject: r10954: added support for canonicalName in the operational module, using the dn->canonicalName function abartlet just committed (This used to be commit 197e8a27f0557869eacd17b74e1b14e0665883b1) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 27313613ab..c26229678e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -498,6 +498,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); -- cgit From be5a24b3c0279b5b90aa61f13cf2d50a45394674 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Oct 2005 11:27:03 +0000 Subject: r11110: make ldb_oom() also set the ldb error string (This used to be commit b6e8018a3b2326c3d1df4811a0581c5c0967bfd3) --- source4/lib/ldb/include/ldb_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3fb73a93b7..7b31bf1e31 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -118,7 +118,7 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, /* simplify out of memory handling */ -#define ldb_oom(ldb) ldb_debug(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) +#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) /* The following definitions come from lib/ldb/common/ldb_modules.c */ -- cgit From 804cf59a489dd41a83fda56acfec4e9f561b1245 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Oct 2005 07:05:32 +0000 Subject: r11364: added a ldb_attr_dn() function for testing if an attribute name is "dn" or "distinguishedName". This makes us a bit more consistent (This used to be commit b41b374b55f9a056c47ffa2ff88aa5272dbc42fc) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c26229678e..c4f877cf5f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -391,7 +391,8 @@ struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); -int ldb_attr_cmp(const char *dn1, const char *dn2); +int ldb_attr_cmp(const char *attr1, const char *attr2); +int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); /* create an empty message */ -- cgit From d3b91ae169b17881dfba4848a7cae30b95a97c70 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 5 Nov 2005 05:44:26 +0000 Subject: r11512: fix typo (This used to be commit 4143c22e3077bd5aecb3427ff0a8857dab799400) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c4f877cf5f..98a5113390 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -76,7 +76,7 @@ struct ldb_dn { struct ldb_dn_component *components; }; -/* these flags are used in ldd_message_element.flags fields. The +/* these flags are used in ldb_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify whether attributes are being added, deleted or modified */ #define LDB_FLAG_MOD_MASK 0x3 -- cgit From 5c9590587197dcb95007fdc54318187d5716c7c6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Nov 2005 00:11:45 +0000 Subject: r11567: Ldb API change patch. This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780) --- source4/lib/ldb/include/ldb.h | 63 +++++++++++++++++++++++++++++++++-- source4/lib/ldb/include/ldb_private.h | 22 ++---------- 2 files changed, 63 insertions(+), 22 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 98a5113390..86e6a021da 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -253,6 +253,65 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" +struct ldb_controls; +struct ldb_credentials; + +enum ldb_request_type { + LDB_REQ_SEARCH, + LDB_REQ_ADD, + LDB_REQ_MODIFY, + LDB_REQ_DELETE, + LDB_REQ_RENAME +}; + +struct ldb_result { + unsigned int count; + struct ldb_message **msgs; +}; + +struct ldb_search { + const struct ldb_dn *base; + enum ldb_scope scope; + struct ldb_parse_tree *tree; + const char * const *attrs; + struct ldb_result **res; +}; + +struct ldb_add { + const struct ldb_message *message; +}; + +struct ldb_modify { + const struct ldb_message *message; +}; + +struct ldb_delete { + const struct ldb_dn *dn; +}; + +struct ldb_rename { + const struct ldb_dn *olddn; + const struct ldb_dn *newdn; +}; + +struct ldb_request { + + int operation; + + union { + struct ldb_search search; + struct ldb_add add; + struct ldb_modify mod; + struct ldb_delete del; + struct ldb_rename rename; + } op; + + struct ldb_controls *controls; + struct ldb_credentials *creds; +}; + +int ldb_request(struct ldb_context *ldb, struct ldb_request *request); + /* initialise a ldb context */ @@ -281,7 +340,7 @@ int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, enum ldb_scope scope, const char *expression, - const char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_result **res); /* like ldb_search() but takes a parse tree @@ -290,7 +349,7 @@ int ldb_search_bytree(struct ldb_context *ldb, const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, - const char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_result **res); /* add a record to the database. Will fail if a record with the given class and key diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 7b31bf1e31..94ee10860b 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -56,12 +56,7 @@ struct ldb_module { */ struct ldb_module_ops { const char *name; - int (*search_bytree)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope, - struct ldb_parse_tree *, const char * const [], struct ldb_message ***); - int (*add_record)(struct ldb_module *, const struct ldb_message *); - int (*modify_record)(struct ldb_module *, const struct ldb_message *); - int (*delete_record)(struct ldb_module *, const struct ldb_dn *); - int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *); + int (*request)(struct ldb_module *, struct ldb_request *); int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); @@ -123,20 +118,7 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); -int ldb_next_search(struct ldb_module *module, - const struct ldb_dn *base, - enum ldb_scope scope, - const char *expression, - const char * const *attrs, struct ldb_message ***res); -int ldb_next_search_bytree(struct ldb_module *module, - const struct ldb_dn *base, - enum ldb_scope scope, - struct ldb_parse_tree *tree, - const char * const *attrs, struct ldb_message ***res); -int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message); -int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message); -int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn); -int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn); +int ldb_next_request(struct ldb_module *module, struct ldb_request *request); int ldb_next_start_trans(struct ldb_module *module); int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); -- cgit From 6eabad9c9d977c1c5c6ecf7494a0be42ad113d23 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 Nov 2005 12:34:03 +0000 Subject: r11958: - fixed memory leaks in the ldb_result handling in ldb operations - removed an unnecessary level of pointer in ldb_search structure (This used to be commit b8d4afb14a18dfd8bac79882a035e74d3ed312bd) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 86e6a021da..2fdf40b3bc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -274,7 +274,7 @@ struct ldb_search { enum ldb_scope scope; struct ldb_parse_tree *tree; const char * const *attrs; - struct ldb_result **res; + struct ldb_result *res; }; struct ldb_add { -- cgit From bceca723044e9cf5d835e8d732be3ab57906505e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 19 Dec 2005 07:07:11 +0000 Subject: r12361: Add a new function: ldb_binary_encode_string() This is for use on user-supplied arguments to printf style format strings which will become ldb filters. I have used it on LSA, SAMR and the auth/ code so far. Also add comments to cracknames code. Andrew Bartlett (This used to be commit 8308cf6e0472790c1c9d521d19322557907f4418) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2fdf40b3bc..9c3b033091 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,7 @@ struct ldb_parse_tree { struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); - +char *ldb_binary_encode_string(void *mem_ctx, const char *string); /* functions for controlling attribute handling -- cgit From 4ff20fcd31bef1df561e6ae513581202b259c1f0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 30 Dec 2005 08:50:47 +0000 Subject: r12600: Add a new module to sort the objectclass attribute on store. The module is perhaps not the most efficient, but I think it is reasonable. This should restore operation of MMC against Samba4 (broken by the templating fixes). Andrew Bartlett (This used to be commit 41948c4bdbfca1160a01a92994324f9e22422afe) --- source4/lib/ldb/include/dlinklist.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index 40f7f0a0c7..a39007375f 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -88,6 +88,8 @@ do { \ type tmp; \ for (tmp = (list1); tmp->next; tmp = tmp->next) ; \ tmp->next = (list2); \ - (list2)->prev = tmp; \ + if (list2) { \ + (list2)->prev = tmp; \ + } \ } \ } while (0) -- cgit From a326d6dba91637d80c5f88fa450fe2e02ba445cb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 30 Dec 2005 08:57:33 +0000 Subject: r12601: Syncronise both copies of dlinklist.h. Should we somehow link these, or just use the version in ldb? Andrew Bartlett (This used to be commit e98d14668e3fdee01b103adb5aec733790eee96d) --- source4/lib/ldb/include/dlinklist.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index a39007375f..176c138aaf 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -71,6 +71,20 @@ do { \ } \ } while (0) +/* insert 'p' after the given element 'el' in a list. If el is NULL then + this is the same as a DLIST_ADD() */ +#define DLIST_ADD_AFTER(list, p, el) \ +do { \ + if (!(list) || !(el)) { \ + DLIST_ADD(list, p); \ + } else { \ + p->prev = el; \ + p->next = el->next; \ + el->next = p; \ + if (p->next) p->next->prev = p; \ + }\ +} while (0) + /* demote an element to the end of the list, needs a tmp pointer */ #define DLIST_DEMOTE(list, p, tmp) \ do { \ -- cgit From 8d147a4dd30ab94ccd1d8faedc38fad5af69150a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 31 Dec 2005 03:43:36 +0000 Subject: r12632: Build fixes from Brad Hards Andrew Bartlett (This used to be commit 44b107d3150135ee4381c1ba4eac23bfd9cb16b9) --- source4/lib/ldb/include/ldb_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 94ee10860b..d0aec6e137 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -150,6 +150,7 @@ int lsqlite3_connect(struct ldb_context *ldb, struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]); int ldb_match_msg(struct ldb_context *ldb, -- cgit From c908d0b2aa111659e57a73efb8c33c413965c846 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 04:01:23 +0000 Subject: r12733: Merge ldap/ldb controls into main tree There's still lot of work to do but the patch is stable enough to be pushed into the main samba4 tree. Simo. (This used to be commit 77125feaff252cab44d26593093a9c211c846ce8) --- source4/lib/ldb/include/ldb.h | 57 +++++++++++++++++++++++++++++------ source4/lib/ldb/include/ldb_errors.h | 2 +- source4/lib/ldb/include/ldb_private.h | 18 ++++++++--- 3 files changed, 62 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9c3b033091..299a5d171e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -141,12 +141,6 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); -struct ldb_module; - -/* module initialisation function */ -typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); - - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -253,7 +247,41 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" -struct ldb_controls; +/* sorting helpers */ +typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); + +#define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +#define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529" +#define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473" +#define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" + +struct ldb_paged_control { + int size; + int cookie_len; + char *cookie; +}; + +struct ldb_extended_dn_control { + int type; +}; + +struct ldb_server_sort_control { + char *attributeName; + char *orderingRule; + int reverse; +}; + +struct ldb_sort_resp_control { + int result; + char *attr_desc; +}; + +struct ldb_control { + const char *oid; + int critical; + void *data; +}; + struct ldb_credentials; enum ldb_request_type { @@ -261,12 +289,14 @@ enum ldb_request_type { LDB_REQ_ADD, LDB_REQ_MODIFY, LDB_REQ_DELETE, - LDB_REQ_RENAME + LDB_REQ_RENAME, + LDB_REQ_REGISTER }; struct ldb_result { unsigned int count; struct ldb_message **msgs; + struct ldb_control **controls; }; struct ldb_search { @@ -294,6 +324,10 @@ struct ldb_rename { const struct ldb_dn *newdn; }; +struct ldb_register_control { + const char *oid; +}; + struct ldb_request { int operation; @@ -304,9 +338,10 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; + struct ldb_register_control reg; } op; - struct ldb_controls *controls; + struct ldb_control **controls; struct ldb_credentials *creds; }; @@ -427,6 +462,7 @@ int ldb_dn_check_special(const struct ldb_dn *dn, const char *check); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); struct ldb_dn *ldb_dn_new(void *mem_ctx); struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); +struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn); char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); @@ -565,4 +601,7 @@ time_t ldb_string_to_time(const char *s); char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); + + +void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index f59b39f92a..a93d3cd388 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -52,7 +52,7 @@ /* 9 RESERVED */ #define LDB_ERR_REFERRAL 10 #define LDB_ERR_ADMIN_LIMIT_EXCEEDED 11 -#define LDB_ERR_UNAVAILABLE_CRITICAL_EXTENSION 12 +#define LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION 12 #define LDB_ERR_CONFIDENTIALITY_REQUIRED 13 #define LDB_ERR_SASL_BIND_IN_PROGRESS 14 #define LDB_ERR_NO_SUCH_ATTRIBUTE 16 diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d0aec6e137..e8a4d1820a 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -104,7 +104,9 @@ struct ldb_context { }; /* the modules init function */ -typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]); +#define LDB_MODULES_INIT_STAGE_1 1 +#define LDB_MODULES_INIT_STAGE_2 2 +typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage, const char **); #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) @@ -147,10 +149,12 @@ int lsqlite3_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[]); int ldb_match_msg(struct ldb_context *ldb, @@ -179,4 +183,8 @@ int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, const struct ldb_val *v1, const struct ldb_val *v2); +/* The following definitions come from lib/ldb/common/ldb_controls.c */ +struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); +int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); +int check_critical_controls(struct ldb_control **controls); #endif -- cgit From dbef4d76de92c3388f4e1819a76d6febf90be290 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 16:12:45 +0000 Subject: r12743: Remove the ugly way we had to make a second stage init and introduce a second_stage_init private function for modules that need a second stage init. Simo. (This used to be commit 5e8b365fa2d93801a5de1d9ea76ce9d5546bd248) --- source4/lib/ldb/include/ldb_private.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e8a4d1820a..4ef7c5a96d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -60,6 +60,7 @@ struct ldb_module_ops { int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); + int (*second_stage_init)(struct ldb_module *); }; @@ -104,9 +105,7 @@ struct ldb_context { }; /* the modules init function */ -#define LDB_MODULES_INIT_STAGE_1 1 -#define LDB_MODULES_INIT_STAGE_2 2 -typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage, const char **); +typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) @@ -117,6 +116,9 @@ typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage, */ #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) +/* The following definitions come from lib/ldb/common/ldb.c */ +int ldb_second_stage_init(struct ldb_context *ldb); + /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); @@ -124,6 +126,7 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request); int ldb_next_start_trans(struct ldb_module *module); int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); +int ldb_next_second_stage_init(struct ldb_module *module); void ldb_set_errstring(struct ldb_module *module, char *err_string); @@ -149,12 +152,12 @@ int lsqlite3_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[]); -struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[]); -struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[]); -struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[]); -struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[]); -struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[]); +struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]); int ldb_match_msg(struct ldb_context *ldb, -- cgit From 4d1c5a023cf6680474bd8d8be73f576d155cfe81 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 10 Jan 2006 16:48:32 +0000 Subject: r12829: fix ldb headers, to not include '<...>' files in .c files this helps in getting symbol -fvisibility=hidden (GCC 4 feature) working later. metze (This used to be commit 380938e97f31c7860aed1e73cc0110c6e17b472e) --- source4/lib/ldb/include/includes.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 4372d6b3f9..15eb18a5e8 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -1,7 +1,17 @@ +#ifndef _LDB_PRIVATE_INCLUDES_H_ +#define _LDB_PRIVATE_INCLUDES_H_ /* a temporary includes file until I work on the ldb build system */ +#ifdef _SAMBA_BUILD_ + +#include "system/filesys.h" +#include "system/iconv.h" +#include "system/time.h" + +#else /*_SAMBA_BUILD_*/ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -22,9 +32,16 @@ #include #endif +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + +#include "talloc.h" + +#endif /*_SAMBA_BUILD_*/ + #include "ldb.h" +#include "ldb_errors.h" #include "ldb_private.h" -#include "talloc.h" +#include "dlinklist.h" -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#endif /*_LDB_PRIVATE_INCLUDES_H_*/ -- cgit From c07d16d2010873be96e13e5747b48bbc17459109 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 16:29:02 +0000 Subject: r12849: fix typo metze (This used to be commit 552e12c05d10ddad55bfc0997303096055ddecdd) --- source4/lib/ldb/include/ldb_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 4ef7c5a96d..d95abccc1b 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -29,7 +29,7 @@ * * Component: ldb private header * - * Description: defines internal ldb structures used by th esubsystem and modules + * Description: defines internal ldb structures used by the subsystem and modules * * Author: Andrew Tridgell * Author: Stefan Metzmacher -- cgit From 4a8656fd65b4bd9a02bf15a0fc46b1e4de35e905 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 16:31:57 +0000 Subject: r12850: - add Doxygen comments to ldb - 'make doxygen' generated the api documentation under apidocs/ Many thanks to Brad Hards for the patches! metze (This used to be commit e98d483174c555366e62dd27600e6b242cab7a7f) --- source4/lib/ldb/include/ldb.h | 600 +++++++++++++++++++++++++++++++---- source4/lib/ldb/include/ldb_errors.h | 228 ++++++++++++- 2 files changed, 758 insertions(+), 70 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 299a5d171e..2a718334fe 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -35,8 +35,17 @@ * Author: Stefan Metzmacher */ +/** + \file ldb.h Samba's ldb database + + This header file provides the main API for ldb. +*/ + #ifndef _LDB_H_ + +/*! \cond DOXYGEN_IGNORE */ #define _LDB_H_ 1 +/*! \endcond */ /* major restrictions as compared to normal LDAP: @@ -53,45 +62,85 @@ */ -/* - an individual lump of data in a result comes in this format. The - pointer will usually be to a UTF-8 string if the application is - sensible, but it can be to anything you like, including binary data - blobs of arbitrary size. -*/ #ifndef ldb_val +/** + Result value + + An individual lump of data in a result comes in this format. The + pointer will usually be to a UTF-8 string if the application is + sensible, but it can be to anything you like, including binary data + blobs of arbitrary size. + + \note the data is null (0x00) terminated, but the length does not + include the terminator. +*/ struct ldb_val { - uint8_t *data; - size_t length; + uint8_t *data; /*!< result data */ + size_t length; /*!< length of data */ }; #endif -/* internal ldb exploded dn structures */ +/** + internal ldb exploded dn structures +*/ struct ldb_dn_component { - char *name; + char *name; struct ldb_val value; }; + struct ldb_dn { int comp_num; struct ldb_dn_component *components; }; -/* these flags are used in ldb_message_element.flags fields. The - LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify - whether attributes are being added, deleted or modified */ +/** + There are a number of flags that are used with ldap_modify() in + ldb_message_element.flags fields. The LDA_FLAGS_MOD_ADD, + LDA_FLAGS_MOD_DELETE and LDA_FLAGS_MOD_REPLACE flags are used in + ldap_modify() calls to specify whether attributes are being added, + deleted or modified respectively. +*/ #define LDB_FLAG_MOD_MASK 0x3 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being added. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_ADD 1 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being replaced. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_REPLACE 2 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being deleted. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_DELETE 3 +/** + OID for logic AND comaprison. -/* - well known object IDs + This is the well known object ID for a logical AND comparitor. */ #define LDB_OID_COMPARATOR_AND "1.2.840.113556.1.4.803" + +/** + OID for logic OR comparison. + + This is the well known object ID for a logical OR comparitor. +*/ #define LDB_OID_COMPARATOR_OR "1.2.840.113556.1.4.804" -/* +/** results are given back as arrays of ldb_message_element */ struct ldb_message_element { @@ -102,7 +151,7 @@ struct ldb_message_element { }; -/* +/** a ldb_message represents all or part of a record. It can contain an arbitrary number of elements. */ @@ -120,12 +169,15 @@ enum ldb_changetype { LDB_CHANGETYPE_MODIFY }; -/* - a ldif record - from ldif_read +/** + LDIF record + + This structure contains a LDIF record, as returned from ldif_read() + and equivalent functions. */ struct ldb_ldif { - enum ldb_changetype changetype; - struct ldb_message *msg; + enum ldb_changetype changetype; /*!< The type of change */ + struct ldb_message *msg; /*!< The changes */ }; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, @@ -145,7 +197,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; -/* +/** the user can optionally supply a debug function. The function is based on the vfprintf() style of interface, but with the addition of a severity level @@ -156,14 +208,31 @@ struct ldb_debug_ops { void *context; }; +/** + Flag value for database connection mode. + + If LDB_FLG_RDONLY is used in ldb_connect, then the database will be + opened read-only, if possible. +*/ #define LDB_FLG_RDONLY 1 + +/** + Flag value for database connection mode. + + If LDB_FLG_NOSYNC is used in ldb_connect, then the database will be + opened without synchronous operations, if possible. +*/ #define LDB_FLG_NOSYNC 2 +/*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) #endif +/*! \endcond */ -/* structures for ldb_parse_tree handling code */ +/* + structures for ldb_parse_tree handling code +*/ enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, @@ -235,24 +304,106 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; -#define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ +/** + The attribute is not returned by default +*/ +#define LDB_ATTR_FLAG_HIDDEN (1<<0) +/** + The attribute is constructed from other attributes +*/ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) + +/** + LDAP attribute syntax for a DN + + This is the well-known LDAP attribute syntax for a DN. -/* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12" + +/** + LDAP attribute syntax for a Directory String + + This is the well-known LDAP attribute syntax for a Directory String. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" + +/** + LDAP attribute syntax for an integer + + This is the well-known LDAP attribute syntax for an integer. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27" + +/** + LDAP attribute syntax for an octet string + + This is the well-known LDAP attribute syntax for an octet string. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40" + +/** + LDAP attribute syntax for UTC time. + + This is the well-known LDAP attribute syntax for a UTC time. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" + #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* sorting helpers */ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); +/** + OID for the paged results control. This control is included in the + searchRequest and searchResultDone messages as part of the controls + field of the LDAPMessage, as defined in Section 4.1.12 of + LDAP v3. + + \sa RFC 2696. +*/ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" + +/** + OID for extended DN + + \sa Microsoft documentation of this OID +*/ #define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529" + +/** + OID for LDAP server sort result extension. + + This control is included in the searchRequest message as part of + the controls field of the LDAPMessage, as defined in Section 4.1.12 + of LDAP v3. The controlType is set to + "1.2.840.113556.1.4.473". The criticality MAY be either TRUE or + FALSE (where absent is also equivalent to FALSE) at the client's + option. + + \sa RFC 2891. +*/ #define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473" + +/** + OID for LDAP server sort result response extension. + + This control is included in the searchResultDone message as part of + the controls field of the LDAPMessage, as defined in Section 4.1.12 of + LDAP v3. + + \sa RFC 2891. +*/ #define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" struct ldb_paged_control { @@ -347,29 +498,60 @@ struct ldb_request { int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -/* - initialise a ldb context +/** + Initialise an ldb context + + This is required before any other LDB call. + + \param mem_ctx pointer to a talloc memory context. Pass NULL if there is + no suitable context available. + + \return pointer to ldb_context that should be free'd (using talloc_free()) + at the end of the program. */ struct ldb_context *ldb_init(void *mem_ctx); -/* - connect to a database. The URL can either be one of the following forms - ldb://path - ldapi://path +/** + Connect to a database. + + This is typically called soon after ldb_init(), and is required prior to + any search or database modification operations. + + The URL can be one of the following forms: + - tdb://path + - ldapi://path + - ldap://host + - sqlite3://path - flags is made up of LDB_FLG_* + \param ldb the context associated with the database (from ldb_init()) + \param url the URL of the database to connect to, as noted above + \param flags a combination of LDB_FLG_* to modify the connection behaviour + \param options backend specific options - passed uninterpreted to the backend - the options are passed uninterpreted to the backend, and are - backend specific + \return result code (LDB_SUCCESS on success, or a failure code) + + \note It is an error to connect to a database that does not exist in readonly mode + (that is, with LDB_FLG_RDONLY). However in read-write mode, the database will be + created if it does not exist. */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -/* - search the database given a LDAP-like search expression +/** + Search the database + + This function searches the database, and returns + records that match an LDAP-like search expression - return the number of records found, or -1 on error + \param ldb the context associated with the database (from ldb_init()) + \param base the Base Distinguished Name for the query (pass NULL for root DN) + \param scope the search scope for the query + \param expression the search expression to use for this query + \param attrs the search attributes for the query (pass NULL if none required) + \param res the return result - use talloc_free to free the ldb_message returned + \return result code (LDB_SUCCESS on success, or a failure code) + + \note use talloc_free() to free the ldb_result returned */ int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, @@ -386,71 +568,263 @@ int ldb_search_bytree(struct ldb_context *ldb, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_result **res); -/* - add a record to the database. Will fail if a record with the given class and key - already exists +/** + Add a record to the database. + + This function adds a record to the database. This function will fail + if a record with the specified class and key already exists in the + database. + + \param ldb the context associated with the database (from + ldb_init()) + \param message the message containing the record to add. + + \return result code (LDB_SUCCESS if the record was added, otherwise + a failure code) */ int ldb_add(struct ldb_context *ldb, const struct ldb_message *message); -/* - modify the specified attributes of a record +/** + Modify the specified attributes of a record + + This function modifies a record that is in the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param message the message containing the changes required. + + \return result code (LDB_SUCCESS if the record was modified as + requested, otherwise a failure code) */ int ldb_modify(struct ldb_context *ldb, const struct ldb_message *message); -/* - rename a record in the database +/** + Rename a record in the database + + This function renames a record in the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param olddn the DN for the record to be renamed. + \param newdn the new DN + + \return result code (LDB_SUCCESS if the record was renamed as + requested, otherwise a failure code) */ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); -/* - delete a record from the database +/** + Delete a record from the database + + This function deletes a record from the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param dn the DN for the record to be deleted. + + \return result code (LDB_SUCCESS if the record was deleted, + otherwise a failure code) */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); -/* +/** start a transaction */ int ldb_transaction_start(struct ldb_context *ldb); -/* +/** commit a transaction */ int ldb_transaction_commit(struct ldb_context *ldb); -/* +/** cancel a transaction */ int ldb_transaction_cancel(struct ldb_context *ldb); -/* +/** return extended error information from the last call */ const char *ldb_errstring(struct ldb_context *ldb); -/* - casefold a string (should be UTF8, but at the moment it isn't) +/** + Casefold a string + + \param mem_ctx the memory context to allocate the result string + memory from. + \param s the string that is to be folded + \return a copy of the string, converted to upper case + + \todo This function should be UTF8 aware, but currently is not. */ char *ldb_casefold(void *mem_ctx, const char *s); + +/** + Compare two strings, without regard to case. + + \param s1 the first string to compare + \param s2 the second string to compare + + \return 0 if the strings are the same, non-zero if there are any + differences except for case. + + \note This function is not UTF8 aware. +*/ int ldb_caseless_cmp(const char *s1, const char *s2); /* ldif manipulation functions */ +/** + Write an LDIF message + + This function writes an LDIF message using a caller supplied write + function. + + \param ldb the ldb context (from ldb_init()) + \param fprintf_fn a function pointer for the write function. This must take + a private data pointer, followed by a format string, and then a variable argument + list. + \param private_data pointer that will be provided back to the write + function. This is useful for maintaining state or context. + \param ldif the message to write out + + \return the total number of bytes written, or an error code as returned + from the write function. + + \sa ldb_ldif_write_file for a more convenient way to write to a + file stream. + + \sa ldb_ldif_read for the reader equivalent to this function. +*/ int ldb_ldif_write(struct ldb_context *ldb, int (*fprintf_fn)(void *, const char *, ...), void *private_data, const struct ldb_ldif *ldif); -void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); + +/** + Clean up an LDIF message + + This function cleans up a LDIF message read using ldb_ldif_read() + or related functions (such as ldb_ldif_read_string() and + ldb_ldif_read_file(). + + \param ldb the ldb context (from ldb_init()) + \param msg the message to clean up and free + +*/ +void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *msg); + +/** + Read an LDIF message + + This function creates an LDIF message using a caller supplied read + function. + + \param ldb the ldb context (from ldb_init()) + \param fgetc_fn a function pointer for the read function. This must + take a private data pointer, and must return a pointer to an + integer corresponding to the next byte read (or EOF if there is no + more data to be read). + \param private_data pointer that will be provided back to the read + function. This is udeful for maintaining state or context. + + \return the LDIF message that has been read in + + \note You must free the LDIF message when no longer required, using + ldb_ldif_read_free(). + + \sa ldb_ldif_read_file for a more convenient way to read from a + file stream. + + \sa ldb_ldif_read_string for a more convenient way to read from a + string (char array). + + \sa ldb_ldif_write for the writer equivalent to this function. +*/ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, int (*fgetc_fn)(void *), void *private_data); + +/** + Read an LDIF message from a file + + This function reads the next LDIF message from the contents of a + file stream. If you want to get all of the LDIF messages, you will + need to repeatedly call this function, until it returns NULL. + + \param ldb the ldb context (from ldb_init()) + \param f the file stream to read from (typically from fdopen()) + + \sa ldb_ldif_read_string for an equivalent function that will read + from a string (char array). + + \sa ldb_ldif_write_file for the writer equivalent to this function. + +*/ struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); + +/** + Read an LDIF message from a string + + This function reads the next LDIF message from the contents of a char + array. If you want to get all of the LDIF messages, you will need + to repeatedly call this function, until it returns NULL. + + \param ldb the ldb context (from ldb_init()) + \param s pointer to the char array to read from + + \sa ldb_ldif_read_file for an equivalent function that will read + from a file stream. + + \sa ldb_ldif_write for a more general (arbitrary read function) + version of this function. +*/ struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char **s); + +/** + Write an LDIF message to a file + + \param ldb the ldb context (from ldb_init()) + \param f the file stream to write to (typically from fdopen()) + \param msg the message to write out + + \return the total number of bytes written, or a negative error code + + \sa ldb_ldif_read_file for the reader equivalent to this function. +*/ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); + +/** + Base64 encode a buffer + + \param mem_ctx the memory context that the result is allocated + from. + \param buf pointer to the array that is to be encoded + \param len the number of elements in the array to be encoded + + \return pointer to an array containing the encoded data + + \note The caller is responsible for freeing the result +*/ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); + +/** + Base64 decode a buffer + + This function decodes a base64 encoded string in place. + + \param s the string to decode. + + \return the length of the returned (decoded) string. + + \note the string is null terminated, but the null terminator is not + included in the length. +*/ int ldb_base64_decode(char *s); + int ldb_attrib_add_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers); @@ -486,28 +860,67 @@ struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); + +/** + Compare two attributes + + This function compares to attribute names. Note that this is a + case-insensitive comparison. + + \param attr1 the first attribute name to compare + \param attr2 the second attribute name to compare + + \return 0 if the attribute names are the same, or only differ in + case; non-zero if there are any differences +*/ int ldb_attr_cmp(const char *attr1, const char *attr2); int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -/* create an empty message */ +/** + Create an empty message + + \param mem_ctx the memory context to create in. You can pass NULL + to get the top level context, however the ldb context (from + ldb_init()) may be a better choice +*/ struct ldb_message *ldb_msg_new(void *mem_ctx); -/* find an element within an message */ +/** + Find an element within an message +*/ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); -/* compare two ldb_val values - return 0 on match */ +/** + Compare two ldb_val values + + \param v1 first ldb_val structure to be tested + \param v2 second ldb_val structure to be tested + + \return 1 for a match, 0 if there is any difference +*/ int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2); -/* find a value within an ldb_message_element */ +/** + find a value within an ldb_message_element + + \param el the element to search + \param val the value to search for + + \note This search is case sensitive +*/ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); -/* add a new empty element to a ldb_message */ +/** + add a new empty element to a ldb_message +*/ int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); -/* add a element to a ldb_message */ +/** + add a element to a ldb_message +*/ int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); @@ -519,13 +932,19 @@ int ldb_msg_add_string(struct ldb_message *msg, int ldb_msg_add_fmt(struct ldb_message *msg, const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -/* compare two message elements - return 0 on match */ +/** + compare two message elements - return 0 on match +*/ int ldb_msg_element_compare(struct ldb_message_element *el1, struct ldb_message_element *el2); -/* find elements in a message and convert to a specific type, with +/** + Find elements in a message. + + This function finds elements and converts to a specific type, with a give default value if not found. Assumes that elements are - single valued */ + single valued. +*/ const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); int ldb_msg_find_int(const struct ldb_message *msg, const char *attr_name, @@ -561,11 +980,35 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +/** + Integrity check an ldb_message + + This function performs basic sanity / integrity checks on an + ldb_message. + + \param msg the message to check + + \return LDB_SUCCESS if the message is OK, or a non-zero error code + (one of LDB_ERR_INVALID_DN_SYNTAX, LDB_ERR_ENTRY_ALREADY_EXISTS or + LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a + message. +*/ int ldb_msg_sanity_check(const struct ldb_message *msg); +/** + Duplicate an ldb_val structure + + This function copies an ldb value structure. + + \param mem_ctx the memory context that the duplicated value will be + allocated from + \param v the ldb_val to be duplicated. + + \return the duplicated ldb_val structure. +*/ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); -/* +/** this allows the user to set a debug function for error reporting */ int ldb_set_debug(struct ldb_context *ldb, @@ -573,7 +1016,9 @@ int ldb_set_debug(struct ldb_context *ldb, const char *fmt, va_list ap), void *context); -/* this sets up debug to print messages on stderr */ +/** + this sets up debug to print messages on stderr +*/ int ldb_set_debug_stderr(struct ldb_context *ldb); /* control backend specific opaque values */ @@ -596,7 +1041,30 @@ int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *r int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); +/** + Convert a time structure to a string + + This function converts a time_t structure to an LDAP formatted time + string. + + \param mem_ctx the memory context to allocate the return string in + \param t the time structure to convert + + \return the formatted string, or NULL if the time structure could + not be converted +*/ char *ldb_timestring(void *mem_ctx, time_t t); + +/** + Convert a string to a time structure + + This function converts an LDAP formatted time string to a time_t + structure. + + \param s the string to convert + + \return the time structure, or 0 if the string cannot be converted +*/ time_t ldb_string_to_time(const char *s); char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index a93d3cd388..dbc6d16e2a 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -33,59 +33,279 @@ */ #ifndef _LDB_ERRORS_H_ + +/*! \cond DOXYGEN_IGNORE */ #define _LDB_ERRORS_H_ 1 +/*! \endcond */ -/* - * Not all error codes make sense for ldb, - * but they are keept here for reference anyway +/** + \file ldb_errors.h + + This header provides a set of result codes for LDB function calls. + + Many LDB function calls return an integer value (int). As shown in + the function documentation, those return values may indicate + whether the function call worked correctly (in which case it + returns LDB_SUCCESS) or some problem occurred (in which case some + other value will be returned). As a special case, + LDB_ERR_COMPARE_FALSE or LDB_ERR_COMPARE_TRUE may be returned, + which does not indicate an error. + + \note Not all error codes make sense for LDB, however they are + based on the LDAP error codes, and are kept for reference and to + avoid overlap. + + \note Some of this documentation is based on information in + the OpenLDAP documentation, as developed and maintained by the + The OpenLDAP Project. */ +/** + The function call succeeded. + + If a function returns LDB_SUCCESS, then that function, and the + underlying transactions that may have been required, completed + successfully. +*/ #define LDB_SUCCESS 0 + +/** + The function call failed for some non-specific reason. +*/ #define LDB_ERR_OPERATIONS_ERROR 1 + +/** + The function call failed because of a protocol violation. +*/ #define LDB_ERR_PROTOCOL_ERROR 2 + +/** + The function call failed because a time limit was exceeded. +*/ #define LDB_ERR_TIME_LIMIT_EXCEEDED 3 + +/** + The function call failed because a size limit was exceeded. +*/ #define LDB_ERR_SIZE_LIMIT_EXCEEDED 4 + +/** + The function was for value comparison, and the comparison operation + returned false. + + \note This is a status value, and doesn't normally indicate an + error. +*/ #define LDB_ERR_COMPARE_FALSE 5 + +/** + The function was for value comparison, and the comparison operation + returned true. + + \note This is a status value, and doesn't normally indicate an + error. +*/ #define LDB_ERR_COMPARE_TRUE 6 + +/** + The function used an authentication method that is not supported by + the database. +*/ #define LDB_ERR_AUTH_METHOD_NOT_SUPPORTED 7 + +/** + The function call required a underlying operation that required + strong authentication. + + This will normally only occur if you are using LDB with a LDAP + backend. +*/ #define LDB_ERR_STRONG_AUTH_REQUIRED 8 /* 9 RESERVED */ + +/** + The function resulted in a referral to another server. +*/ #define LDB_ERR_REFERRAL 10 + +/** + The function failed because an administrative / policy limit was + exceeded. +*/ #define LDB_ERR_ADMIN_LIMIT_EXCEEDED 11 + +/** + The function required an extension or capability that the + database cannot provide. +*/ #define LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION 12 + +/** + The function involved a transaction or database operation that + could not be performed without a secure link. +*/ #define LDB_ERR_CONFIDENTIALITY_REQUIRED 13 + +/** + This is an intermediate result code for SASL bind operations that + have more than one step. + + \note This is a result code that does not normally indicate an + error has occurred. +*/ #define LDB_ERR_SASL_BIND_IN_PROGRESS 14 + +/** + The function referred to an attribute type that is not present in + the entry. +*/ #define LDB_ERR_NO_SUCH_ATTRIBUTE 16 + +/** + The function referred to an attribute type that is invalid +*/ #define LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE 17 + +/** + The function required a filter type that is not available for the + specified attribute. +*/ #define LDB_ERR_INAPPROPRIATE_MATCHING 18 -#define LDB_ERR_CONSTRAINT_VIOLAION 19 + +/** + The function would have violated an attribute constraint. +*/ +#define LDB_ERR_CONSTRAINT_VIOLATION 19 + +/** + The function involved an attribute type or attribute value that + already exists in the entry. +*/ #define LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS 20 +/** + The function used an invalid (incorrect syntax) attribute value. +*/ #define LDB_ERR_INVALID_ATTRIBUTE_SYNTAX 21 + /* 22-31 unused */ + +/** + The function referred to an object that does not exist in the + database. +*/ #define LDB_ERR_NO_SUCH_OBJECT 32 + +/** + The function referred to an alias which points to a non-existant + object in the database. +*/ #define LDB_ERR_ALIAS_PROBLEM 33 + +/** + The function used a DN which was invalid (incorrect syntax). +*/ #define LDB_ERR_INVALID_DN_SYNTAX 34 + /* 53 RESERVED */ + +/** + The function required dereferencing of an alias, and something went + wrong during the dereferencing process. +*/ #define LDB_ERR_ALIAS_DEREFERENCING_PROBLEM 36 + /* 37-47 unused */ + +/** + The function passed in the wrong authentication method. +*/ #define LDB_ERR_INAPPROPRIATE_AUTHENTICATION 48 + +/** + The function passed in or referenced incorrect credentials during + authentication. +*/ #define LDB_ERR_INVALID_CREDENTIALS 49 + +/** + The function required access permissions that the user does not + possess. +*/ #define LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS 50 + +/** + The function required a transaction or call that the database could + not perform because it is busy. +*/ #define LDB_ERR_BUSY 51 + +/** + The function required a transaction or call to a database that is + not available. +*/ #define LDB_ERR_UNAVAILABLE 52 + +/** + The function required a transaction or call to a database that the + database declined to perform. +*/ #define LDB_ERR_UNWILLING_TO_PERFORM 53 + +/** + The function failed because it resulted in a loop being detected. +*/ #define LDB_ERR_LOOP_DETECT 54 + /* 55-63 unused */ + +/** + The function failed because it would have violated a naming rule. +*/ #define LDB_ERR_NAMING_VIOLATION 64 + +/** + The function failed because it would have violated the schema. +*/ #define LDB_ERR_OBJECT_CLASS_VIOLATION 65 + +/** + The function required an operation that is only allowed on leaf + objects, but the object is not a leaf. +*/ #define LDB_ERR_NOT_ALLOWED_ON_NON_LEAF 66 + +/** + The function required an operation that cannot be performed on a + Relative DN, but the object is a Relative DN. +*/ #define LDB_ERR_NOT_ALLOWED_ON_RDN 67 + +/** + The function failed because the entry already exists. +*/ #define LDB_ERR_ENTRY_ALREADY_EXISTS 68 + +/** + The function failed because modifications to an object class are + not allowable. +*/ #define LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED 69 + /* 70 RESERVED FOR CLDAP */ + +/** + The function failed because it needed to be applied to multiple + databases. +*/ #define LDB_ERR_AFFECTS_MULTIPLE_DSAS 71 + /* 72-79 unused */ + +/** + The function failed for unknown reasons. +*/ #define LDB_ERR_OTHER 80 + /* 81-90 RESERVED for APIs */ #endif /* _LDB_ERRORS_H_ */ -- cgit From 5db0c6b3042292e0f343ced3d45f2f7a8f97de12 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jan 2006 01:06:16 +0000 Subject: r12925: implement client side of ASQ control (This used to be commit dd386bdc6ca6fe0b25705d5a375d29e6940b437f) --- source4/lib/ldb/include/ldb.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2a718334fe..569bf9d6a5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -406,6 +406,15 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" +/** + OID for LDAP Attribute Scoped Query extension. + + This control is include in SearchRequest or SearchResponse + messages as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" + + struct ldb_paged_control { int size; int cookie_len; @@ -427,6 +436,13 @@ struct ldb_sort_resp_control { char *attr_desc; }; +struct ldb_asq_control { + int request; + char *source_attribute; + int src_attr_len; + int result; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 3b447ab4a131509491b42a1843c52ba69bab5e11 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 17 Jan 2006 04:04:57 +0000 Subject: r12977: Some code to implement the client side of the Dirsync control Still investigating how it works. Simo. (This used to be commit bebd403523e581606505e05e7cb621efbc22fa36) --- source4/lib/ldb/include/ldb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 569bf9d6a5..09f4723f7b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -414,6 +414,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" +/** + OID for LDAPrectory Sync extension. + + This control is include in SearchRequest or SearchResponse + messages as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841" + struct ldb_paged_control { int size; @@ -443,6 +451,13 @@ struct ldb_asq_control { int result; }; +struct ldb_dirsync_control { + int flags; + int max_attributes; + int cookie_len; + char *cookie; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 828ee2bc6fa4f757c63a31054a0046fe09f8c26e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Jan 2006 18:56:04 +0000 Subject: r12984: add parse code and ldbsearch cmdline code for NOTIFICATION LDAP Controls http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_notification_oid.asp this doesn't work yet, but it shows that we need to extend ldb to correctly handle async requests... metze (This used to be commit 1fe67189490c9faf499b68a28071a6294a53db0e) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 09f4723f7b..770d23c638 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -374,6 +374,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +/** + OID for notification + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_NOTIFICATION_OID "1.2.840.113556.1.4.528" + /** OID for extended DN -- cgit From 0e7fed29ec24f5de1709a41f64998a90b51a1ec7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 24 Jan 2006 18:40:53 +0000 Subject: r13114: remove 'const' and make clear what the parameters are for metze (This used to be commit 317a3eefeef6b9da565a215ba152d829059c6f14) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 770d23c638..9a637ff9d5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -362,7 +362,7 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* sorting helpers */ -typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); +typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); /** OID for the paged results control. This control is included in the -- cgit From d346794a8d962de209cc3a111c73e23553c9a767 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 26 Jan 2006 16:37:37 +0000 Subject: r13166: Patches form Brad Hards (This used to be commit 335050b30d832f529fb8fdd4f96e4bb3de93f38c) --- source4/lib/ldb/include/ldb.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9a637ff9d5..087790ac68 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -276,7 +276,37 @@ struct ldb_parse_tree { struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); + +/** + Encode a binary blob + + This function encodes a binary blob using the encoding rules in RFC + 2254 (Section 4). This function also escapes any non-printable + characters. + + \param ctx the memory context to allocate the return string in. + \param val the (potentially) binary data to be encoded + + \return the encoded data as a null terminated string + + \sa RFC 2252. +*/ char *ldb_binary_encode(void *ctx, struct ldb_val val); + +/** + Encode a string + + This function encodes a string using the encoding rules in RFC 2254 + (Section 4). This function also escapes any non-printable + characters. + + \param mem_ctx the memory context to allocate the return string in. + \param string the string to be encoded + + \return the encoded data as a null terminated string + + \sa RFC 2252. +*/ char *ldb_binary_encode_string(void *mem_ctx, const char *string); /* @@ -328,7 +358,7 @@ struct ldb_attrib_handler { This is the well-known LDAP attribute syntax for a Directory String. - See RFC 2252, Section 4.3.2 + \sa RFC 2252, Section 4.3.2 */ #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" @@ -532,7 +562,7 @@ struct ldb_request { struct ldb_control **controls; struct ldb_credentials *creds; -}; +}; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -- cgit From ffa41a12642445bc89ba0a6e12c0c97e118b121a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 27 Jan 2006 05:10:20 +0000 Subject: r13181: Fix standalone ldb build (This used to be commit e9059ea0c56c1fd9886eb038df5455efe11962f8) --- source4/lib/ldb/include/ldb_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d95abccc1b..6871d8d552 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -158,6 +158,7 @@ struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]); +struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[]); int ldb_match_msg(struct ldb_context *ldb, -- cgit From feb1c8ea82645ae361099ce992cff3c2d45abcdc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 31 Jan 2006 23:37:56 +0000 Subject: r13268: fixed typo noticed by Aaron Seigo (This used to be commit a49d024f3d4866655d4436a5c42b3c228374594b) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 087790ac68..9139e6d2f5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -589,7 +589,7 @@ struct ldb_context *ldb_init(void *mem_ctx); - tdb://path - ldapi://path - ldap://host - - sqlite3://path + - sqlite://path \param ldb the context associated with the database (from ldb_init()) \param url the URL of the database to connect to, as noted above -- cgit From f5ebc8e404f4397c0ef2c8b838984df1767c955c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 00:38:48 +0000 Subject: r13324: From now on check attribute names obey rfc2251 Also add a way to provide utf8 compliant functions by registering them with ldb_set_utf8_fns() Next comes code to register samba internal utf8 functions. Simo. (This used to be commit ac9b8a41ffca8e06c5e849d544d3203a665b8e0d) --- source4/lib/ldb/include/ldb.h | 36 +++++++++++++++++++++++++++++++---- source4/lib/ldb/include/ldb_private.h | 7 +++++++ 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9139e6d2f5..a8c2d176b5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -208,6 +208,16 @@ struct ldb_debug_ops { void *context; }; +/** + The user can optionally supply a custom utf8 functions, + to handle comparisons and casefolding. +*/ +struct ldb_utf8_fns { + void *context; + int (*caseless_cmp)(void *context, const char *s1, const char *s2); + char *(*casefold)(void *context, void *mem_ctx, const char *s); +}; + /** Flag value for database connection mode. @@ -718,30 +728,48 @@ int ldb_transaction_cancel(struct ldb_context *ldb); */ const char *ldb_errstring(struct ldb_context *ldb); +/** + setup the default utf8 functions + FIXME: these functions do not yet handle utf8 +*/ +void ldb_set_utf8_default(struct ldb_context *ldb); + /** Casefold a string + \param ldb the ldb context \param mem_ctx the memory context to allocate the result string memory from. \param s the string that is to be folded \return a copy of the string, converted to upper case - \todo This function should be UTF8 aware, but currently is not. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(void *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); /** Compare two strings, without regard to case. + \param ldb the ldb context \param s1 the first string to compare \param s2 the second string to compare \return 0 if the strings are the same, non-zero if there are any differences except for case. - \note This function is not UTF8 aware. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() +*/ +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); + +/** + Check the attribute name is valid according to rfc2251 + \param s tthe string to check + + \return 1 if the name is ok */ -int ldb_caseless_cmp(const char *s1, const char *s2); +int ldb_valid_attr_name(const char *s); /* ldif manipulation functions diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 6871d8d552..fffda77ff8 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -90,6 +90,9 @@ struct ldb_context { /* debugging operations */ struct ldb_debug_ops debug_ops; + /* custom utf8 functions */ + struct ldb_utf8_fns utf8_fns; + /* backend specific opaque parameters */ struct ldb_opaque { struct ldb_opaque *next; @@ -191,4 +194,8 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); int check_critical_controls(struct ldb_control **controls); + +/* The following definitions come from lib/ldb/common/ldb_utf8.c */ +char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); +int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2); #endif -- cgit From 48d8eee7522e1c1c45a9353ab77c96c20321f143 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 01:27:47 +0000 Subject: r13325: let samba register it's own utf8 aware functions in ldb (This used to be commit 12faf556833807d3f2aa4360c54e10583ac77fed) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a8c2d176b5..7c39aeeeb9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1112,6 +1112,14 @@ int ldb_set_debug(struct ldb_context *ldb, const char *fmt, va_list ap), void *context); +/** + this allows the user to set custom utf8 function for error reporting +*/ +void ldb_set_utf8_fns(struct ldb_context *ldb, + void *context, + int (*cmp)(void *, const char *, const char *), + char *(*casefold)(void *, void *, const char *)); + /** this sets up debug to print messages on stderr */ -- cgit From 88279373abc07fa50a969135eb5ecf58d6c40cc7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 05:59:48 +0000 Subject: r13328: After the attribute name check cleanup it turned up ldb_caseless_cmp() was used just in one places and by mistake, as there we should have been using ldb_attr_cmp() Remove ldb_caseless_cmp() ... going on with the cleanup and utf8 compliance effort. Simo. (This used to be commit afda68d7bf655a9145648856d29e6e64b9f21aa3) --- source4/lib/ldb/include/ldb.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7c39aeeeb9..0e192c2e31 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,6 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -748,21 +747,6 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); -/** - Compare two strings, without regard to case. - - \param ldb the ldb context - \param s1 the first string to compare - \param s2 the second string to compare - - \return 0 if the strings are the same, non-zero if there are any - differences except for case. - - \note The default function is not yet UTF8 aware. Provide your own - set of functions through ldb_set_utf8_fns() -*/ -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); - /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1117,7 +1101,6 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** -- cgit From 04396c36d3ee8300b2b73ea8b43a45ea1b250828 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 06:57:28 +0000 Subject: r13333: revert previous commit I will use ldb_caseless_cmp in attrib_handlers to correctly support utf8 comparisons add an ldb_attr_Casefold function for attribute names and use it instead of casefold in the right places (This used to be commit 3b4eb2413bbce059dde69f35c03cdc3cc2ba85c5) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0e192c2e31..7c39aeeeb9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,6 +214,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; + int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -747,6 +748,21 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); +/** + Compare two strings, without regard to case. + + \param ldb the ldb context + \param s1 the first string to compare + \param s2 the second string to compare + + \return 0 if the strings are the same, non-zero if there are any + differences except for case. + + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() +*/ +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); + /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1101,6 +1117,7 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, + int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** -- cgit From 3ba24e4a35156a36f900cdbdbbef770861e9c7eb Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 07:57:57 +0000 Subject: r13335: Fix the build and add an utf8 safe ldb_hadler_fold function based on ldb_casefold (This used to be commit 6104f900863c688707809d42c5429a42d654d5fb) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7c39aeeeb9..4e457b028f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -970,6 +970,7 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); case; non-zero if there are any differences */ int ldb_attr_cmp(const char *attr1, const char *attr2); +char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -- cgit From 76036d37b42d0c77e57b288af410b931c51fea81 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 18:30:30 +0000 Subject: r13349: In the end I could not use ldb_caseless_cmp in attrib_handler.c functions remove it again Simo (This used to be commit 513ff499071e6cb5e608a82430718021f72997bd) --- source4/lib/ldb/include/ldb.h | 17 ----------------- source4/lib/ldb/include/ldb_private.h | 1 - 2 files changed, 18 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4e457b028f..44f2f5840c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,6 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -748,21 +747,6 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); -/** - Compare two strings, without regard to case. - - \param ldb the ldb context - \param s1 the first string to compare - \param s2 the second string to compare - - \return 0 if the strings are the same, non-zero if there are any - differences except for case. - - \note The default function is not yet UTF8 aware. Provide your own - set of functions through ldb_set_utf8_fns() -*/ -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); - /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1118,7 +1102,6 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index fffda77ff8..90632744ed 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -197,5 +197,4 @@ int check_critical_controls(struct ldb_control **controls); /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); -int ldb_caseless_cmp_default(void *context, const char *s1, const char *s2); #endif -- cgit From 338c410fec8dbd902485e56567f6aecf256cdba2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Feb 2006 01:21:17 +0000 Subject: r13361: initial implementation of the vlv control seem still buggy, can't make w2k3 to like it yet (This used to be commit e1318383e91f6f6db39e3e3c9946fbb089753947) --- source4/lib/ldb/include/ldb.h | 48 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 44f2f5840c..a6cec7f774 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -455,20 +455,36 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); /** OID for LDAP Attribute Scoped Query extension. - This control is include in SearchRequest or SearchResponse + This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. */ #define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" /** - OID for LDAPrectory Sync extension. + OID for LDAP Directory Sync extension. - This control is include in SearchRequest or SearchResponse + This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. */ #define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841" +/** + OID for LDAP Virtual List View Request extension. + + This control is included in SearchRequest messages + as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_VLV_REQ_OID "2.16.840.1.113730.3.4.9" + +/** + OID for LDAP Virtual List View Response extension. + + This control is included in SearchResponse messages + as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" + struct ldb_paged_control { int size; int cookie_len; @@ -504,6 +520,32 @@ struct ldb_dirsync_control { char *cookie; }; +struct ldb_vlv_req_control { + int beforeCount; + int afterCount; + int type; + union { + struct { + int offset; + int contentCount; + } byOffset; + struct { + int value_len; + char *value; + } gtOrEq; + } match; + int ctxid_len; + char *contextId; +}; + +struct ldb_vlv_resp_control { + int targetPosition; + int contentCount; + int vlv_result; + int ctxid_len; + char *contextId; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 00fe70e5b917769418f68eaa255d3a06a9a08ce7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Feb 2006 01:31:35 +0000 Subject: r13609: Get in the initial work on making ldb async Currently only ldb_ildap is async, the plan is to first make all backend support the async calls, and then remove the sync functions from backends and keep the only in the API. Modules will need to be transformed along the way. Simo (This used to be commit 1e2c13b2d52de7c534493dd79a2c0596a3e8c1f5) --- source4/lib/ldb/include/ldb.h | 46 +++++++++++++++++++++++++++++++++++ source4/lib/ldb/include/ldb_private.h | 3 +++ 2 files changed, 49 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a6cec7f774..4a40e34363 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -560,15 +560,51 @@ enum ldb_request_type { LDB_REQ_MODIFY, LDB_REQ_DELETE, LDB_REQ_RENAME, + LDB_ASYNC_SEARCH, + LDB_ASYNC_ADD, + LDB_ASYNC_MODIFY, + LDB_ASYNC_DELETE, + LDB_ASYNC_RENAME, + LDB_REQ_REGISTER }; +enum ldb_reply_type { + LDB_REPLY_ENTRY, + LDB_REPLY_REFERRAL, + LDB_REPLY_DONE +}; + +enum ldb_async_wait_type { + LDB_WAIT_ALL, + LDB_WAIT_NONE +}; + +enum ldb_async_state { + LDB_ASYNC_PENDING, + LDB_ASYNC_DONE +}; + struct ldb_result { unsigned int count; struct ldb_message **msgs; + char **refs; struct ldb_control **controls; }; +struct ldb_async_result { + enum ldb_reply_type type; + struct ldb_message *message; + char *referral; + struct ldb_control **controls; +}; + +struct ldb_async_handle { + int status; + enum ldb_async_state state; + void *private_data; +}; + struct ldb_search { const struct ldb_dn *base; enum ldb_scope scope; @@ -613,10 +649,20 @@ struct ldb_request { struct ldb_control **controls; struct ldb_credentials *creds; + + struct { + void *context; + int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + + time_t timeout; + struct ldb_async_handle *handle; + } async; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); +int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); + /** Initialise an ldb context diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 90632744ed..db34b58858 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -105,6 +105,8 @@ struct ldb_context { char *err_string; int transaction_active; + + int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); }; /* the modules init function */ @@ -132,6 +134,7 @@ int ldb_next_del_trans(struct ldb_module *module); int ldb_next_second_stage_init(struct ldb_module *module); void ldb_set_errstring(struct ldb_module *module, char *err_string); +void ldb_reset_err_string(struct ldb_context *ldb); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -- cgit From d590dea10b3abf93fcc8138189291e8b66bae7d7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Feb 2006 05:21:43 +0000 Subject: r13615: Make ldb_set_errstring get ldb instead of module as parameter. The module was just used to get to the ldb so it was meningless. Also add LDB_WAIT_ONCE e relative code in ldb_ildap.c (This used to be commit d5b467b7c132b0bd4d23918ba7bf3370b1afcce8) --- source4/lib/ldb/include/ldb.h | 2 ++ source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4a40e34363..8a9e8bea76 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -577,10 +577,12 @@ enum ldb_reply_type { enum ldb_async_wait_type { LDB_WAIT_ALL, + LDB_WAIT_ONCE, LDB_WAIT_NONE }; enum ldb_async_state { + LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE }; diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index db34b58858..24967faeea 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -133,7 +133,7 @@ int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); int ldb_next_second_stage_init(struct ldb_module *module); -void ldb_set_errstring(struct ldb_module *module, char *err_string); +void ldb_set_errstring(struct ldb_context *ldb, char *err_string); void ldb_reset_err_string(struct ldb_context *ldb); /* The following definitions come from lib/ldb/common/ldb_debug.c */ -- cgit From 98c0767677156ff31791bd93f473ac11f856c75a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Feb 2006 09:28:58 +0000 Subject: r13616: Add new ldb functions: ldb_msg_add_steal_string() and ldb_msg_add_steal_value(). These try to maintain the talloc heirachy, which must be correct otherwise talloc_steal operations of entire attribute lists fails. This fixes the currentTime value, found by using Microsoft's dcdiag tool (before this commit, it pointed to invalid memory, due to the changes in -r 13606) Andrew Bartlett (This used to be commit 424df1bb369fddcfd358cf26dd0da9d3851d181e) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8a9e8bea76..488f782c9b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1098,6 +1098,11 @@ int ldb_msg_add(struct ldb_message *msg, int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val); +int ldb_msg_add_steal_value(struct ldb_message *msg, + const char *attr_name, + struct ldb_val *val); +int ldb_msg_add_steal_string(struct ldb_message *msg, + const char *attr_name, char *str); int ldb_msg_add_string(struct ldb_message *msg, const char *attr_name, const char *str); int ldb_msg_add_fmt(struct ldb_message *msg, -- cgit From 57d5f19b3f032dfcecde9883651c6df8b18a8b58 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Feb 2006 00:39:26 +0000 Subject: r13700: added highestCommittedUSN, uSNChanged and uSNCreated support, using the @BASEINFO sequenceNumber (simo, I changed the function pointer to a structure element as you preferred) (This used to be commit 68c9ac38c7eed221b44499ee3d74597063dfe7a1) --- source4/lib/ldb/include/ldb_private.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 24967faeea..3f9be357a7 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -107,6 +107,9 @@ struct ldb_context { int transaction_active; int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); + + /* a backend supplied highestCommittedUSN function */ + uint64_t (*sequence_number)(struct ldb_context *); }; /* the modules init function */ -- cgit From e1380d63a0d85120ebf25d228b1bf6f8c6604d99 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 28 Feb 2006 04:38:53 +0000 Subject: r13744: Make ldb_ldap async (This used to be commit ec833b409c1fff4ab908fe194579e701d2e950b0) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 488f782c9b..f5bca965ad 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -656,7 +656,7 @@ struct ldb_request { void *context; int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); - time_t timeout; + int timeout; struct ldb_async_handle *handle; } async; }; -- cgit From 26af14c39b88b0e7eb53657b89be65d865804688 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 2 Mar 2006 16:32:53 +0000 Subject: r13786: [merge] Add registration functions for LDB modules Applications that use LDB modules will now have to run ldb_global_init() before they can use LDB. The next step will be adding support for loading LDB modules from .so files. This will also allow us to use one LDB without difference between the standalone and the Samba-specific build (This used to be commit 52a235650514039bf8ffee99a784bbc1b6ae6b92) --- source4/lib/ldb/include/includes.h | 2 ++ source4/lib/ldb/include/ldb.h | 9 +++++++++ source4/lib/ldb/include/ldb_private.h | 25 ++++++++++--------------- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 15eb18a5e8..b10f329a2d 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -10,6 +10,8 @@ #include "system/iconv.h" #include "system/time.h" +#include "build.h" + #else /*_SAMBA_BUILD_*/ #ifndef _GNU_SOURCE diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f5bca965ad..13e69282ca 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -665,6 +665,15 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *request); int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); +/** + Initialise ldbs' global information + + This is required before any other LDB call + + \return 0 if initialisation succeeded, -1 otherwise +*/ +int ldb_global_init(void); + /** Initialise an ldb context diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3f9be357a7..d4cba9797c 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -56,11 +56,11 @@ struct ldb_module { */ struct ldb_module_ops { const char *name; + int (*init_context) (struct ldb_module *); int (*request)(struct ldb_module *, struct ldb_request *); int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); - int (*second_stage_init)(struct ldb_module *); }; @@ -112,9 +112,6 @@ struct ldb_context { uint64_t (*sequence_number)(struct ldb_context *); }; -/* the modules init function */ -typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); - #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) #endif @@ -124,9 +121,6 @@ typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char */ #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) -/* The following definitions come from lib/ldb/common/ldb.c */ -int ldb_second_stage_init(struct ldb_context *ldb); - /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); @@ -134,11 +128,13 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request); int ldb_next_start_trans(struct ldb_module *module); int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); -int ldb_next_second_stage_init(struct ldb_module *module); +int ldb_next_init(struct ldb_module *module); void ldb_set_errstring(struct ldb_context *ldb, char *err_string); void ldb_reset_err_string(struct ldb_context *ldb); +int ldb_register_module(const struct ldb_module_ops *); + /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, @@ -161,14 +157,13 @@ int lsqlite3_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]); -struct ldb_module *asq_module_init(struct ldb_context *ldb, const char *options[]); +int ldb_objectclass_init(void); +int ldb_operational_init(void); +int ldb_paged_results_init(void); +int ldb_rdn_name_init(void); +int ldb_schema_init(void); +int ldb_sort_init(void); int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, -- cgit From 2debfc918cc19e798f996f64dc5fe079b0c538cf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 3 Mar 2006 08:15:29 +0000 Subject: r13809: move ldb specific define metze (This used to be commit 6f47fcbd44ae83e7268aedf91ac56fff4189c763) --- source4/lib/ldb/include/includes.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index b10f329a2d..57c207bd74 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -12,6 +12,9 @@ #include "build.h" +/* tell ldb we have the internal ldap code */ +#define HAVE_ILDAP 1 + #else /*_SAMBA_BUILD_*/ #ifndef _GNU_SOURCE -- cgit From 509814bd037a3c73fea4ab92b531c25964f34dfa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 3 Mar 2006 20:01:19 +0000 Subject: r13823: make async_wait part of the modules ops (This used to be commit b4202cf030d5f154f0f94f5f501ecd648ba5c48f) --- source4/lib/ldb/include/ldb_private.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d4cba9797c..ba6823559f 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -61,6 +61,7 @@ struct ldb_module_ops { int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); + int (*async_wait)(struct ldb_module *, struct ldb_async_handle *, enum ldb_async_wait_type); }; @@ -106,8 +107,6 @@ struct ldb_context { int transaction_active; - int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); - /* a backend supplied highestCommittedUSN function */ uint64_t (*sequence_number)(struct ldb_context *); }; -- cgit From 5d0aa16dfcf3047a52d3dd7e12ffb704a9725e83 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 5 Mar 2006 16:05:26 +0000 Subject: r13839: Use registration mechanism for backends as well (in the same sense my previous patch added it for modules). This is the next step towards LDB backends and modules as run-time loadable .so files. (This used to be commit fb2f70de4f6c4a9b13ad590cb4d3a9c858cede49) --- source4/lib/ldb/include/ldb_private.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index ba6823559f..52ea0f833d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -64,6 +64,7 @@ struct ldb_module_ops { int (*async_wait)(struct ldb_module *, struct ldb_async_handle *, enum ldb_async_wait_type); }; +typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); /* schema related information needed for matching rules @@ -133,6 +134,7 @@ void ldb_set_errstring(struct ldb_context *ldb, char *err_string); void ldb_reset_err_string(struct ldb_context *ldb); int ldb_register_module(const struct ldb_module_ops *); +int ldb_register_backend(const char *url_prefix, ldb_connect_fn); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); @@ -142,27 +144,16 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); -int ltdb_connect(struct ldb_context *ldb, const char *url, - unsigned int flags, - const char *options[]); -int lldb_connect(struct ldb_context *ldb, const char *url, - unsigned int flags, - const char *options[]); -int ildb_connect(struct ldb_context *ldb, - const char *url, - unsigned int flags, - const char *options[]); -int lsqlite3_connect(struct ldb_context *ldb, - const char *url, - unsigned int flags, - const char *options[]); - int ldb_objectclass_init(void); int ldb_operational_init(void); int ldb_paged_results_init(void); int ldb_rdn_name_init(void); int ldb_schema_init(void); int ldb_sort_init(void); +int ldb_ldap_init(void); +int ldb_ildap_init(void); +int ldb_tdb_init(void); +int ldb_sqlite3_init(void); int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, -- cgit From e814354e437ee5019b74f854acfd513adb9c6454 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 7 Mar 2006 12:58:21 +0000 Subject: r13934: these are only needed for a standalone build metze (This used to be commit 0db8351b149e5c3d91bf7f2d36ceed329462133c) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 52ea0f833d..e241674e4f 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -144,6 +144,7 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); +#ifndef _SAMBA_BUILD_ int ldb_objectclass_init(void); int ldb_operational_init(void); int ldb_paged_results_init(void); @@ -154,6 +155,7 @@ int ldb_ldap_init(void); int ldb_ildap_init(void); int ldb_tdb_init(void); int ldb_sqlite3_init(void); +#endif int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, -- cgit From 49e6945ca838737423939272e532221323b22128 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 21:02:11 +0000 Subject: r13990: Fix issues with function renaming. (This used to be commit 988ea27e22e3c0f4daf118151f90db5bb243bffc) --- source4/lib/ldb/include/includes.h | 2 -- source4/lib/ldb/include/ldb_private.h | 2 -- 2 files changed, 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 57c207bd74..c85ffadb6d 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -10,8 +10,6 @@ #include "system/iconv.h" #include "system/time.h" -#include "build.h" - /* tell ldb we have the internal ldap code */ #define HAVE_ILDAP 1 diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e241674e4f..52ea0f833d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -144,7 +144,6 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); -#ifndef _SAMBA_BUILD_ int ldb_objectclass_init(void); int ldb_operational_init(void); int ldb_paged_results_init(void); @@ -155,7 +154,6 @@ int ldb_ldap_init(void); int ldb_ildap_init(void); int ldb_tdb_init(void); int ldb_sqlite3_init(void); -#endif int ldb_match_msg(struct ldb_context *ldb, struct ldb_message *msg, -- cgit From 7b82c4beb93375f79b6c06fc86bb31873baa187b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 7 Mar 2006 21:08:09 +0000 Subject: r13992: change the way ldb_async_wait() works. I think I should change the name of this function to ldb_async_process(), any opinions ? (This used to be commit 3347322d1327cfa975ee9dccd4f2774e6e14fbcb) --- source4/lib/ldb/include/ldb.h | 1 + source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13e69282ca..b3ea17d85d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -605,6 +605,7 @@ struct ldb_async_handle { int status; enum ldb_async_state state; void *private_data; + struct ldb_module *module; }; struct ldb_search { diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 52ea0f833d..27b6883c3d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -61,7 +61,7 @@ struct ldb_module_ops { int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); - int (*async_wait)(struct ldb_module *, struct ldb_async_handle *, enum ldb_async_wait_type); + int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); }; typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -- cgit From 257598424e63c2cfa118b5ea84b7dc719d1dc5aa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 7 Mar 2006 21:16:35 +0000 Subject: r13996: simplify ldb_async_wait() some more (This used to be commit ef1b3e6368179fe86ae07b8d00e4668090175551) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b3ea17d85d..dbe929246b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -664,7 +664,7 @@ struct ldb_request { int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); /** Initialise ldbs' global information -- cgit From 6e74d8356578c42c8081498094f2c834c6d439b4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 10 Mar 2006 15:50:47 +0000 Subject: r14163: Remove LDB_WAIT_ONCE, we can hardly guarante we get anything if not waiting for all, keeping this value may just lead to false expectations. You either make blocking call waiting for ALL results transforming this in a sync call, or either you loop expecting from 0 to all results being returned at any time on any of these loops. It should be clear also that when you may receive results at any time as soon as you call ldb_request. Your callback may have received all results even before calling ldb_async_wait the first time. Simo. (This used to be commit 6f041068b50caf919cd971812bdb8e3e810565fb) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dbe929246b..6abce5d9b9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -577,7 +577,6 @@ enum ldb_reply_type { enum ldb_async_wait_type { LDB_WAIT_ALL, - LDB_WAIT_ONCE, LDB_WAIT_NONE }; -- cgit From 7a121583b496a8fc0c1fcf44504d814700273e40 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Mar 2006 22:36:07 +0000 Subject: r14349: Kill proto.h! Prototypes are now spread over multiple headers, usually one per subsystem. This change is required to allow proper header dependencies later on, without recompiling Samba each time the mtime of any source file changes. (This used to be commit 3da79bf909f801386a52e6013db399c384d0401c) --- source4/lib/ldb/include/includes.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index c85ffadb6d..d8e2125eaa 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -38,6 +38,7 @@ #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#include "lib/ldb/samba/ldif_handlers.h" #include "talloc.h" #endif /*_SAMBA_BUILD_*/ -- cgit From 72a1d08cfe1a7a5477c291e2058d62bcfa1c427f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 20 Mar 2006 21:28:56 +0000 Subject: r14590: Fix ldb standalone build... (This used to be commit 3a6ed4e2df26936202cba8f7739ed39e0d119d1a) --- source4/lib/ldb/include/includes.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index d8e2125eaa..c85ffadb6d 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -38,7 +38,6 @@ #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -#include "lib/ldb/samba/ldif_handlers.h" #include "talloc.h" #endif /*_SAMBA_BUILD_*/ -- cgit From bb1909e15e7a9f3cd79da2ce8b8ef90f1a557376 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 20 Mar 2006 21:44:59 +0000 Subject: r14592: Add support for loading shared modules to LDB. (This used to be commit f10fae23f0685b2d9c6174596e1c66d799f02c52) --- source4/lib/ldb/include/includes.h | 3 +++ source4/lib/ldb/include/ldb_private.h | 1 + 2 files changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index c85ffadb6d..26309df381 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -34,6 +34,9 @@ #ifdef HAVE_STDINT_H #include #endif +#ifdef HAVE_DLFCN_H +#include +#endif #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 27b6883c3d..0ea6c4e9de 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -135,6 +135,7 @@ void ldb_reset_err_string(struct ldb_context *ldb); int ldb_register_module(const struct ldb_module_ops *); int ldb_register_backend(const char *url_prefix, ldb_connect_fn); +int ldb_try_load_dso(struct ldb_context *ldb, const char *name); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -- cgit From 7dbbc960a05ec0cbf3c3a655c08858acaf6bf499 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 13 Apr 2006 04:19:27 +0000 Subject: r15065: Remove duplicate prototype. (This used to be commit 9d9df34d94842ea9f4be3fa51b197fb4bb918488) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6abce5d9b9..589bb4b6a1 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1055,7 +1055,6 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *attr1, const char *attr2); char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); -char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); /** Create an empty message -- cgit From cfbcb93d7c84ef08ae759ee55723366b37516474 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 16 Apr 2006 06:02:13 +0000 Subject: r15096: Fix typo. (This used to be commit 85de6e32b833db9ca601b3e979d08444e0702c27) --- source4/lib/ldb/include/ldb_errors.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index dbc6d16e2a..3b04c7c17f 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -206,7 +206,7 @@ */ #define LDB_ERR_INVALID_DN_SYNTAX 34 -/* 53 RESERVED */ +/* 35 RESERVED */ /** The function required dereferencing of an alias, and something went -- cgit From 859817e30ff809bda972e208e89191f53e097674 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 17 Apr 2006 23:25:25 +0000 Subject: r15113: Add a ldb_strerror() function. (This used to be commit 456a1de2b9cd54337066c9ba24ad1c46aafcd072) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 589bb4b6a1..a6a13fc39c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -826,6 +826,11 @@ int ldb_transaction_cancel(struct ldb_context *ldb); */ const char *ldb_errstring(struct ldb_context *ldb); +/** + return a string explaining what a ldb error constant meancs +*/ +const char *ldb_strerror(int ldb_err); + /** setup the default utf8 functions FIXME: these functions do not yet handle utf8 -- cgit From 8c653b5b54514f1f5e2279ed05f863c4578f1f5a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 25 Apr 2006 16:08:55 +0000 Subject: r15245: forgot one header (This used to be commit 32da3f5d22cc38f72961ca65c85c49d03f64b05c) --- source4/lib/ldb/include/ldb.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a6a13fc39c..43dde8675b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -233,6 +233,15 @@ struct ldb_utf8_fns { */ #define LDB_FLG_NOSYNC 2 +/** + Flag value to specify autoreconnect mode. + + If LDB_FLG_RECONNECT is used in ldb_connect, then the backend will + be opened in a way that makes it try to auto reconnect if the + connection is dropped (actually make sense only with ldap). +*/ +#define LDB_FLG_RECONNECT 3 + /*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) -- cgit From d562cac5c4a54cc4efe8a6c876faba5274730948 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 Apr 2006 16:21:56 +0000 Subject: r15246: flags need to represented as bits 0x01,0x02,0x04,0x08,0x10,... metze (This used to be commit 96da29263b5b7a78e75b46ab9cf6e6e1729e05d4) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 43dde8675b..af3aed24c6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -240,7 +240,7 @@ struct ldb_utf8_fns { be opened in a way that makes it try to auto reconnect if the connection is dropped (actually make sense only with ldap). */ -#define LDB_FLG_RECONNECT 3 +#define LDB_FLG_RECONNECT 4 /*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE -- cgit From 172a83d72491f90f6191be1040ef8b2e1789bd2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:14:12 +0000 Subject: r15573: Fix build of systems that have iconv headers in non-standard locations Split of system/locale.h header from system/iconv.h Previously, iconv wasn't being used on these systems (This used to be commit aa6d66fda69779d1c2948a1aca85dbd5208f1cba) --- source4/lib/ldb/include/includes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 26309df381..827290342f 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -7,7 +7,7 @@ #ifdef _SAMBA_BUILD_ #include "system/filesys.h" -#include "system/iconv.h" +#include "system/locale.h" #include "system/time.h" /* tell ldb we have the internal ldap code */ -- cgit From aa7a02d45fefad3640f273b1d3bfe535a1e6b88c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 13 May 2006 21:08:37 +0000 Subject: r15582: Commit some forgotten stuff that have been setting on my private tree fro long (This used to be commit 7c050b541e98cd442a0c9ed0ddadb3e573cd1304) --- source4/lib/ldb/include/ldb.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index af3aed24c6..866b062d06 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -625,11 +625,11 @@ struct ldb_search { }; struct ldb_add { - const struct ldb_message *message; + struct ldb_message *message; }; struct ldb_modify { - const struct ldb_message *message; + struct ldb_message *message; }; struct ldb_delete { @@ -1178,6 +1178,10 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +int ldb_msg_check_string_attribute(const struct ldb_message *msg, + const char *name, + const char *value); + /** Integrity check an ldb_message -- cgit From 6d0969aa1adff4c7f134bd6e3e42997e72b41cf6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 20 May 2006 19:37:21 +0000 Subject: r15761: Fix-as-you-go ... Testing various async paths and uncovering bugs (This used to be commit 099d873ea596ece18efe63b06bc64e7f97a96f82) --- source4/lib/ldb/include/ldb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 866b062d06..9f0613feaa 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -619,17 +619,17 @@ struct ldb_async_handle { struct ldb_search { const struct ldb_dn *base; enum ldb_scope scope; - struct ldb_parse_tree *tree; + const struct ldb_parse_tree *tree; const char * const *attrs; struct ldb_result *res; }; struct ldb_add { - struct ldb_message *message; + const struct ldb_message *message; }; struct ldb_modify { - struct ldb_message *message; + const struct ldb_message *message; }; struct ldb_delete { @@ -647,7 +647,7 @@ struct ldb_register_control { struct ldb_request { - int operation; + enum ldb_request_type operation; union { struct ldb_search search; -- cgit From 3a4d7eb2c08a06fac89c34d132f1c32751ce7ad5 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 29 May 2006 01:30:02 +0000 Subject: r15927: Optimize ldb module traverse while keeping the API intact. I was sick of jumping inot each module for each request, even the ones not handle by that module. (This used to be commit 7d65105e885a28584e8555453b90232c43a92bf7) --- source4/lib/ldb/include/ldb_private.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 0ea6c4e9de..d8f9aa417d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -57,7 +57,12 @@ struct ldb_module { struct ldb_module_ops { const char *name; int (*init_context) (struct ldb_module *); - int (*request)(struct ldb_module *, struct ldb_request *); + int (*search)(struct ldb_module *, struct ldb_request *); /* search */ + int (*add)(struct ldb_module *, struct ldb_request *); /* add */ + int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */ + int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ + int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ + int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); -- cgit From 03703a58d7fe441ec5dcbe1814cea3f55544de55 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 29 May 2006 11:57:09 +0000 Subject: r15932: Remove per request creds They have never benn used and make little sense too imo (This used to be commit f0c1d08d50f8a3e25650ac85b178ec7a43e433d9) --- source4/lib/ldb/include/ldb.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9f0613feaa..8f21aec046 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -561,8 +561,6 @@ struct ldb_control { void *data; }; -struct ldb_credentials; - enum ldb_request_type { LDB_REQ_SEARCH, LDB_REQ_ADD, @@ -659,7 +657,6 @@ struct ldb_request { } op; struct ldb_control **controls; - struct ldb_credentials *creds; struct { void *context; -- cgit From 0c7b82e5f6063de4114de21cf854ac67346e31f6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 29 May 2006 23:46:43 +0000 Subject: r15942: Remove the sync internal ldb calls altogether. This means that some modules have been disabled as well as they have not been ported to the async interface One of them is the ugly objectclass module. I hope that the change in samldb module will make the MMC happy without the need of this crappy module, we need proper handling in a decent schema module. proxy and ldb_map have also been disabled ldb_sqlite3 need to be ported as well (currenlty just broken). (This used to be commit 51083de795bdcbf649de926e86969adc20239b6d) --- source4/lib/ldb/include/ldb.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8f21aec046..8e61ccd73c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -562,11 +562,6 @@ struct ldb_control { }; enum ldb_request_type { - LDB_REQ_SEARCH, - LDB_REQ_ADD, - LDB_REQ_MODIFY, - LDB_REQ_DELETE, - LDB_REQ_RENAME, LDB_ASYNC_SEARCH, LDB_ASYNC_ADD, LDB_ASYNC_MODIFY, -- cgit From 2d19dca9c80a5e3990296dde67163fce36ac883d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 30 May 2006 00:33:52 +0000 Subject: r15944: rename LDB_ASYNC_ADD -> LDB_ADD, LDB_ASYNC_MODIFY -> LDB_MODIFY, etc... (This used to be commit 55d97ef88f377ef1dbf7b1774a15cf9035e2f320) --- source4/lib/ldb/include/ldb.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8e61ccd73c..56eed3ab24 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -562,11 +562,11 @@ struct ldb_control { }; enum ldb_request_type { - LDB_ASYNC_SEARCH, - LDB_ASYNC_ADD, - LDB_ASYNC_MODIFY, - LDB_ASYNC_DELETE, - LDB_ASYNC_RENAME, + LDB_SEARCH, + LDB_ADD, + LDB_MODIFY, + LDB_DELETE, + LDB_RENAME, LDB_REQ_REGISTER }; -- cgit From ca5accf224dc3ef998235603797b519866b57b1c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 4 Jun 2006 05:28:13 +0000 Subject: r16036: Add a couple of new functions to corretly deal with timeouts. Check timeouts are correctly verified. Some minor fixed and removal of unused code. (This used to be commit b52e5d6a0cb1a32e62759eaa49ce3e4cc804cc92) --- source4/lib/ldb/include/ldb.h | 4 ++++ source4/lib/ldb/include/ldb_private.h | 2 ++ 2 files changed, 6 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 56eed3ab24..644f74385f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -658,6 +658,7 @@ struct ldb_request { int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); int timeout; + time_t starttime; struct ldb_async_handle *handle; } async; }; @@ -666,6 +667,9 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *request); int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); +int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); + /** Initialise ldbs' global information diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d8f9aa417d..14f0403697 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -113,6 +113,8 @@ struct ldb_context { int transaction_active; + int default_timeout; + /* a backend supplied highestCommittedUSN function */ uint64_t (*sequence_number)(struct ldb_context *); }; -- cgit From 247af0d569594512a24e83156e257b8d4d356883 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 7 Jun 2006 21:03:38 +0000 Subject: r16083: Make it possible to initialise a backend module, without it setting up the whole ldb structure. Because the sequence number was a fn pointer on the main ldb context, turn it into a full request (currently sync). Andrew Bartlett (This used to be commit fbe7d0ca9031e292b2d2fae263233c973982980a) --- source4/lib/ldb/include/ldb.h | 14 ++++++++++++-- source4/lib/ldb/include/ldb_private.h | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 644f74385f..033a9c1f39 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -567,8 +567,8 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, - - LDB_REQ_REGISTER + LDB_REQ_REGISTER, + LDB_SEQUENCE_NUMBER }; enum ldb_reply_type { @@ -638,6 +638,10 @@ struct ldb_register_control { const char *oid; }; +struct ldb_sequence_number { + uint64_t seq_num; +}; + struct ldb_request { enum ldb_request_type operation; @@ -649,6 +653,7 @@ struct ldb_request { struct ldb_delete del; struct ldb_rename rename; struct ldb_register_control reg; + struct ldb_sequence_number seq_num; } op; struct ldb_control **controls; @@ -810,6 +815,11 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +/** + Obtain current database sequence number +*/ +int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num); + /** start a transaction */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 14f0403697..6d017d5cc1 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -67,9 +67,11 @@ struct ldb_module_ops { int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); + int (*sequence_number)(struct ldb_module *, struct ldb_request *); }; -typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); +typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], + struct ldb_module **module); /* schema related information needed for matching rules -- cgit From c79f37fa1aa0b7414d184ddb14f2db168cbd2568 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 7 Jun 2006 22:03:06 +0000 Subject: r16084: Add private prototype for new ldb_connect_backend() function. Andrew Bartlett (This used to be commit 684126223046d88d1ff446767ab6783f6391b50c) --- source4/lib/ldb/include/ldb_private.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 6d017d5cc1..a10c343352 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -130,6 +130,11 @@ struct ldb_context { */ #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) +/* The following definitions come from lib/ldb/common/ldb.c */ + +int ldb_connect_backend(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], + struct ldb_module **backend_module); + /* The following definitions come from lib/ldb/common/ldb_modules.c */ int ldb_load_modules(struct ldb_context *ldb, const char *options[]); -- cgit From f77c4100842f8c5357fa90822e04319810a04b8d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 15 Jun 2006 18:04:24 +0000 Subject: r16264: Add, but do not yet enable, the partitions module. This required changes to the rootDSE module, to allow registration of partitions. In doing so I renamed the 'register' operation to 'register_control' and 'register_partition', which changed a few more modules. Due to the behaviour of certain LDAP servers, we create the baseDN entry in two parts: Firstly, we allow the admin to export a simple LDIF file to add to their server. Then we perform a modify to add the remaining attributes. To delete all users in partitions, we must now search and delete all objects in the partition, rather than a simple search from the root. Against LDAP, this might not delete all objects, so we allow this to fail. In testing, we found that the 'Domain Controllers' container was misnamed, and should be 'CN=', rather than 'OU='. To avoid the Templates being found in default searches, they have been moved to CN=Templates from CN=Templates,${BASEDN}. Andrew Bartlett (This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a) --- source4/lib/ldb/include/ldb.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 033a9c1f39..b684b03ef4 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -567,7 +567,8 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, - LDB_REQ_REGISTER, + LDB_REQ_REGISTER_CONTROL, + LDB_REQ_REGISTER_PARTITION, LDB_SEQUENCE_NUMBER }; @@ -638,6 +639,10 @@ struct ldb_register_control { const char *oid; }; +struct ldb_register_partition { + const struct ldb_dn *dn; +}; + struct ldb_sequence_number { uint64_t seq_num; }; @@ -652,7 +657,8 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; - struct ldb_register_control reg; + struct ldb_register_control reg_control; + struct ldb_register_partition reg_partition; struct ldb_sequence_number seq_num; } op; @@ -1245,6 +1251,7 @@ const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); -- cgit From 44e6f21393ea6f2531c6d1e789a0a01582bc6dca Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 6 Jul 2006 05:08:30 +0000 Subject: r16825: Make ldb_sainity_check() set an error string. This makes it much easier to chase down what modules or application code gets wrong. Ensure not to leave memory allocated on failure in ldb_search() Andrew Bartlett (This used to be commit 0828739951ed879640f8ed6e4700d8ca6b8221b8) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b684b03ef4..2f0464b953 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1207,7 +1207,8 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg, LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a message. */ -int ldb_msg_sanity_check(const struct ldb_message *msg); +int ldb_msg_sanity_check(struct ldb_context *ldb, + const struct ldb_message *msg); /** Duplicate an ldb_val structure -- cgit From 32ab51876728577375b954a04103f71ddd4d93dc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 12 Jul 2006 04:59:41 +0000 Subject: r16972: Replace the sequence_number function pointer in ldb with the ldb flags. The function pointer was meant to be unused, this patch fixes partition.c to use ldb_sequence_number(). (No backend provided the pointer any more). Set the flags onto the ldb structure, so that all backends opened by the partitions module inherit the flags. Set the read-ony flag when accessed as the global catalog Modify the LDAP server to track that this query is for the global catalog (by incoming port), and set a opqaue pointer. Next step is to read that opaque pointer in the partitions module. Andrew Bartlett (This used to be commit a1161cb30e4ffa09657a89e03ca85dd6efd4feba) --- source4/lib/ldb/include/ldb_private.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index a10c343352..2f2df1a970 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -117,8 +117,7 @@ struct ldb_context { int default_timeout; - /* a backend supplied highestCommittedUSN function */ - uint64_t (*sequence_number)(struct ldb_context *); + unsigned int flags; }; #ifndef ARRAY_SIZE @@ -132,7 +131,7 @@ struct ldb_context { /* The following definitions come from lib/ldb/common/ldb.c */ -int ldb_connect_backend(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], +int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[], struct ldb_module **backend_module); /* The following definitions come from lib/ldb/common/ldb_modules.c */ -- cgit From c93817b36d3ff7f44cb7b3e1d1a29e37ec12affe Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 16:56:33 +0000 Subject: r17185: Oh, I wanted to do this for sooo long time. Finally acknowledge that ldb is inherently async and does not have a dual personality anymore Rename all ldb_async_XXX functions to ldb_XXX except for ldb_async_result, it is now ldb_reply to reflect the real function of this structure. Simo. (This used to be commit 25fc7354049d62efeba17681ef1cdd326bc3f2ef) --- source4/lib/ldb/include/ldb.h | 16 ++++++++-------- source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2f0464b953..885842ff9c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -578,12 +578,12 @@ enum ldb_reply_type { LDB_REPLY_DONE }; -enum ldb_async_wait_type { +enum ldb_wait_type { LDB_WAIT_ALL, LDB_WAIT_NONE }; -enum ldb_async_state { +enum ldb_state { LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE @@ -596,16 +596,16 @@ struct ldb_result { struct ldb_control **controls; }; -struct ldb_async_result { +struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; char *referral; struct ldb_control **controls; }; -struct ldb_async_handle { +struct ldb_handle { int status; - enum ldb_async_state state; + enum ldb_state state; void *private_data; struct ldb_module *module; }; @@ -666,17 +666,17 @@ struct ldb_request { struct { void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); int timeout; time_t starttime; - struct ldb_async_handle *handle; + struct ldb_handle *handle; } async; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 2f2df1a970..1360602000 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -66,7 +66,7 @@ struct ldb_module_ops { int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); - int (*async_wait)(struct ldb_async_handle *, enum ldb_async_wait_type); + int (*wait)(struct ldb_handle *, enum ldb_wait_type); int (*sequence_number)(struct ldb_module *, struct ldb_request *); }; -- cgit From 49f68caed20d2a7d1850e493005bdf85929d6365 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 17:21:59 +0000 Subject: r17186: "async" word abuse clean-up part 2 (This used to be commit c6aa60c7e69abf1f83efc150b1c3ed02751c45fc) --- source4/lib/ldb/include/ldb.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 885842ff9c..68c2272adf 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -664,14 +664,12 @@ struct ldb_request { struct ldb_control **controls; - struct { - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); - - int timeout; - time_t starttime; - struct ldb_handle *handle; - } async; + void *context; + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); + + int timeout; + time_t starttime; + struct ldb_handle *handle; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -- cgit From e248caed12f5d20d3abedfaf84aa18cdff46c95c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 21:16:01 +0000 Subject: r17195: Start thinking how to implement extended operations. Ad supports three extended operations: - start tls - dynamic objects - fast binds none of these are a priority. (This used to be commit 523e8f3ed4bf5fcf9dc0c9e2100e4ac3b8032be7) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ source4/lib/ldb/include/ldb_private.h | 1 + 2 files changed, 18 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 68c2272adf..6e3f69f607 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -494,6 +494,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_STATRT_TLS_OID "1.3.6.1.4.1.1466.20037" + struct ldb_paged_control { int size; int cookie_len; @@ -567,6 +575,7 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, + LDB_EXTENDED, LDB_REQ_REGISTER_CONTROL, LDB_REQ_REGISTER_PARTITION, LDB_SEQUENCE_NUMBER @@ -575,6 +584,7 @@ enum ldb_request_type { enum ldb_reply_type { LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL, + LDB_REPLY_EXTENDED, LDB_REPLY_DONE }; @@ -596,9 +606,16 @@ struct ldb_result { struct ldb_control **controls; }; +struct ldb_extended { + const char *oid; + const char *value; + int value_len; +}; + struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; + struct ldb_extended *response; char *referral; struct ldb_control **controls; }; diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 1360602000..b862daec86 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -63,6 +63,7 @@ struct ldb_module_ops { int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ + int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */ int (*start_transaction)(struct ldb_module *); int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); -- cgit From e3df3cd55ffd03a337ac769540d1cd80e25a7ef6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Jul 2006 03:41:32 +0000 Subject: r17225: Fix the build by fixing the spelling of START-TLS. Andrew Bartlett (This used to be commit 4827a6b171d7b007f1641ef422d23449fb5a1606) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6e3f69f607..d017861b05 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -500,7 +500,7 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); This Extended operation is used to start a new TLS channel on top of a clear text channel. */ -#define LDB_EXTENDED_STATRT_TLS_OID "1.3.6.1.4.1.1466.20037" +#define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" struct ldb_paged_control { int size; -- cgit From b1b9617d1c1833da2efa93b011733060c6670976 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 1 Aug 2006 03:22:02 +0000 Subject: r17350: Avoid a couple of memleaks, unnecessary code and use a more linear style (This used to be commit 97c4d41a30a5d85145abb781cb7001b502bc7dcb) --- source4/lib/ldb/include/ldb.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d017861b05..08bb2dd2f6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -502,6 +502,22 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_DYNAMIC_OID "1.3.6.1.4.1.1466.101.119.1" + +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" + struct ldb_paged_control { int size; int cookie_len; -- cgit From f685635e87923807c9fde843f57c02ded16caf09 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 1 Aug 2006 22:46:49 +0000 Subject: r17368: Add 'const' to ldb_match_msg(). Andrew Bartlett (This used to be commit 54eda4b85975c44c993a7dc45f6caa898076f163) --- source4/lib/ldb/include/ldb_private.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index b862daec86..f442202ee3 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -171,8 +171,8 @@ int ldb_tdb_init(void); int ldb_sqlite3_init(void); int ldb_match_msg(struct ldb_context *ldb, - struct ldb_message *msg, - struct ldb_parse_tree *tree, + const struct ldb_message *msg, + const struct ldb_parse_tree *tree, const struct ldb_dn *base, enum ldb_scope scope); -- cgit From b4028ca1041fc8e0266de2f5c858dd40e660aafb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 10:26:23 +0000 Subject: r17418: add client support for the LDAP_SERVER_SD_FLAGS control metze (This used to be commit 23759a1e9b05c4fde475a9016cb0b7447656d7e7) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 08bb2dd2f6..6730824fdd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -422,6 +422,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +/** + OID for specifying the returned elements of the ntSecurityDescriptor + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" + /** OID for notification @@ -518,6 +525,16 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" +struct ldb_sd_flags_control { + /* + * request the owner 0x00000001 + * request the group 0x00000002 + * request the DACL 0x00000004 + * request the SACL 0x00000008 + */ + unsigned secinfo_flags; +}; + struct ldb_paged_control { int size; int cookie_len; -- cgit From 817610f38540fb99595f6e3b77b9f6696f9e3b3f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:18:14 +0000 Subject: r17419: add client support for the LDAP_SERVER_SEARCH_OPTIONS support. with this you can limit a search to a specific partitions or a search over all partitions without getting referrals. (Witch is the default behavior on the Global Catalog Port) metze (This used to be commit 4ccd0f8171f3748ee6efe1abd3f894d2cdf46bf4) --- source4/lib/ldb/include/ldb.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6730824fdd..4a04c3df44 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -429,6 +429,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" +/** + OID for specifying an advanced scope for a search + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SEARCH_OPTIONS_OID "1.2.840.113556.1.4.1340" + /** OID for notification @@ -535,6 +542,23 @@ struct ldb_sd_flags_control { unsigned secinfo_flags; }; +struct ldb_search_options_control { + /* + * DOMAIN_SCOPE 0x00000001 + * this limits the search to one partition, + * and no referrals will be returned. + * (Note this doesn't limit the entries by there + * objectSid belonging to a domain! Builtin and Foreign Sids + * are still returned) + * + * PHANTOM_ROOT 0x00000002 + * this search on the whole tree on a domain controller + * over multiple partitions without referrals. + * (This is the default behavior on the Global Catalog Port) + */ + unsigned search_options; +}; + struct ldb_paged_control { int size; int cookie_len; -- cgit From 8ac0237eba1831c8ba6d01c2b9d8402636a21bb2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:38:50 +0000 Subject: r17420: add client support for the LDAP_SERVER_DOMAIN_SCOPE control metze (This used to be commit 84e74a759cfa49ebc8b4ba1b8e729d6d920fc55a) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4a04c3df44..13ad473b0b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -429,6 +429,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" +/** + OID for specifying an advanced scope for the search (one partition) + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_DOMAIN_SCOPE_OID "1.2.840.113556.1.4.1339" + /** OID for specifying an advanced scope for a search -- cgit From 12050962f6dd37819e58e1e0b572c159f0406f7a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:35:00 +0000 Subject: r17429: implement the LDAP_SERVER_SHOW_DELETED control in the client metze (This used to be commit 40dc7c1787c16bfc15ac87fee81d2d2d1f3d2fde) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13ad473b0b..05cc1e3494 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -450,6 +450,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_NOTIFICATION_OID "1.2.840.113556.1.4.528" +/** + OID for getting deleted objects + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SHOW_DELETED_OID "1.2.840.113556.1.4.417" + /** OID for extended DN -- cgit From 3a083f8f53b998b6aabf69e845fd0fbdf86b6499 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:50:58 +0000 Subject: r17430: implement the LDAP_SERVER_PERMISSIVE_MODIFY control in the client metze (This used to be commit 96259f0f24b114e505241c9d2deb702a8b40f1b6) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 05cc1e3494..5a49ae357f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -522,6 +522,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" +/** + OID to let modifies don't give an error when adding an existing + attribute with the same value or deleting an nonexisting one attribute + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_PERMISSIVE_MODIFY_OID "1.2.840.113556.1.4.1413" + /** OID for LDAP Extended Operation START_TLS. -- cgit From ecfdd5fc6cd704eaf496f4d31c18b6db97589fb3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 10 Aug 2006 01:51:27 +0000 Subject: r17474: Allow the partitions module to load modules for specific backends. Andrew Bartlett (This used to be commit c016db2187120991e8ad779b9df35480d7c19400) --- source4/lib/ldb/include/ldb_private.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index f442202ee3..97e2828371 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -137,7 +137,10 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op /* The following definitions come from lib/ldb/common/ldb_modules.c */ +const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string); +int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out); int ldb_load_modules(struct ldb_context *ldb, const char *options[]); +int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module); int ldb_next_request(struct ldb_module *module, struct ldb_request *request); int ldb_next_start_trans(struct ldb_module *module); int ldb_next_end_trans(struct ldb_module *module); -- cgit From 39018ab9022d8bd2cc58a52cf4834c5ce7c5455f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 12 Aug 2006 15:20:06 +0000 Subject: r17503: Add a useful function to search for a DN (This used to be commit 8c6efd7b55e4ad45e1bd10519a1b91285a4e0347) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5a49ae357f..e560068d0c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1269,6 +1269,10 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); +struct ldb_dn *ldb_msg_find_dn(void *mem_ctx, + const struct ldb_message *msg, + const char *attr_name); + void ldb_msg_sort_elements(struct ldb_message *msg); struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, -- cgit From faed8175063b16df94d5332581baf1af0562bb09 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 13 Aug 2006 07:33:57 +0000 Subject: r17514: Simplify the way to set ldb errors and add another helper function to set them. (This used to be commit 260868bae56194fcb98d55afc22fc66d96a303df) --- source4/lib/ldb/include/ldb_private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 97e2828371..99b9f99fb3 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -147,7 +147,8 @@ int ldb_next_end_trans(struct ldb_module *module); int ldb_next_del_trans(struct ldb_module *module); int ldb_next_init(struct ldb_module *module); -void ldb_set_errstring(struct ldb_context *ldb, char *err_string); +void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); +void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...); void ldb_reset_err_string(struct ldb_context *ldb); int ldb_register_module(const struct ldb_module_ops *); -- cgit From a23b63a8e54db7d0ec98ad95cdca11dd4d039e17 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 13 Aug 2006 08:00:36 +0000 Subject: r17516: Change helper function names to make more clear what they are meant to do (This used to be commit ad75cf869550af66119d0293503024d41d834e02) --- source4/lib/ldb/include/ldb.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e560068d0c..e756a9b00b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1250,28 +1250,28 @@ int ldb_msg_element_compare(struct ldb_message_element *el1, single valued. */ const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); -int ldb_msg_find_int(const struct ldb_message *msg, - const char *attr_name, - int default_value); -unsigned int ldb_msg_find_uint(const struct ldb_message *msg, - const char *attr_name, - unsigned int default_value); -int64_t ldb_msg_find_int64(const struct ldb_message *msg, - const char *attr_name, - int64_t default_value); -uint64_t ldb_msg_find_uint64(const struct ldb_message *msg, +int ldb_msg_find_attr_as_int(const struct ldb_message *msg, const char *attr_name, - uint64_t default_value); -double ldb_msg_find_double(const struct ldb_message *msg, - const char *attr_name, - double default_value); -const char *ldb_msg_find_string(const struct ldb_message *msg, - const char *attr_name, - const char *default_value); - -struct ldb_dn *ldb_msg_find_dn(void *mem_ctx, - const struct ldb_message *msg, - const char *attr_name); + int default_value); +unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg, + const char *attr_name, + unsigned int default_value); +int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg, + const char *attr_name, + int64_t default_value); +uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, + const char *attr_name, + uint64_t default_value); +double ldb_msg_find_attr_as_double(const struct ldb_message *msg, + const char *attr_name, + double default_value); +const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, + const char *attr_name, + const char *default_value); + +struct ldb_dn *ldb_msg_find_attr_as_dn(void *mem_ctx, + const struct ldb_message *msg, + const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); -- cgit From 9f7da6fea0bc9a330f8620d100e27d4eabbae253 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Aug 2006 01:52:24 +0000 Subject: r17579: make ldb build g++ friendly (This used to be commit 403cbd335594112e0c58fd68d20f0e3faad7d186) --- source4/lib/ldb/include/ldb_private.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 99b9f99fb3..754e4bc859 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -191,9 +191,9 @@ int ldb_set_attrib_handler_syntax(struct ldb_context *ldb, const char *attr, const char *syntax); /* The following definitions come from lib/ldb/common/ldb_attributes.c */ -const char **ldb_subclass_list(struct ldb_context *ldb, const char *class); -void ldb_subclass_remove(struct ldb_context *ldb, const char *class); -int ldb_subclass_add(struct ldb_context *ldb, const char *class, const char *subclass); +const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname); +void ldb_subclass_remove(struct ldb_context *ldb, const char *classname); +int ldb_subclass_add(struct ldb_context *ldb, const char *classname, const char *subclass); int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, const struct ldb_val *in, struct ldb_val *out); -- cgit From 7de75a991bda653497a0989de93608310b55894a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 17 Aug 2006 08:31:19 +0000 Subject: r17580: Add a new tools to convert back from AD-like schema to OpenLDAP. Add attribute syntax mapping to the existing OpenLDAP -> AD tool. Andrew Bartlett (This used to be commit ba1c652bae700a82acde166e70035d61c320e233) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e756a9b00b..2e659b5307 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1265,6 +1265,9 @@ uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, double ldb_msg_find_attr_as_double(const struct ldb_message *msg, const char *attr_name, double default_value); +int ldb_msg_find_attr_as_bool(const struct ldb_message *msg, + const char *attr_name, + int default_value); const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); -- cgit From 10d8142e5db9fab0e169d73772f9d8715c294a5b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 22 Aug 2006 20:49:58 +0000 Subject: r17720: in standalone ldb build, some systems need sys/stat.h and a defn of comparison_fn_t (This used to be commit 99915268e60f6f877b639f1788ebdcf8105d6073) --- source4/lib/ldb/include/includes.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 827290342f..76870aca6d 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #ifdef HAVE_STDINT_H #include @@ -40,6 +42,9 @@ #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#ifndef HAVE_COMPARISON_FN_T +typedef int (*comparison_fn_t)(const void *, const void *); +#endif #include "talloc.h" -- cgit From d95354300c4fb33317860e5143ab67c01745981d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 23 Aug 2006 05:19:42 +0000 Subject: r17741: tru64 uses inttypes.h not stdint.h. ain't standards wonderful? (This used to be commit 5eb59e5be09cd16bb0796b55575aa92dfd22650a) --- source4/lib/ldb/include/includes.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 76870aca6d..31997d6008 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -36,6 +36,9 @@ #ifdef HAVE_STDINT_H #include #endif +#ifdef HAVE_INTTYPES_H +#include +#endif #ifdef HAVE_DLFCN_H #include #endif -- cgit From 0749ab04002f2288cddd994b830163c107230f31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Aug 2006 09:19:19 +0000 Subject: r17743: fix compiler warnings metze (This used to be commit 694a56b0ae0125594d6a23d8465249f011b6284e) --- source4/lib/ldb/include/ldb.h | 18 +++++++++--------- source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e659b5307..b07cdd964c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -80,6 +80,12 @@ struct ldb_val { }; #endif +/*! \cond DOXYGEN_IGNORE */ +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif +/*! \endcond */ + /** internal ldb exploded dn structures */ @@ -204,7 +210,7 @@ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, */ struct ldb_debug_ops { void (*debug)(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap); + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); void *context; }; @@ -242,12 +248,6 @@ struct ldb_utf8_fns { */ #define LDB_FLG_RECONNECT 4 -/*! \cond DOXYGEN_IGNORE */ -#ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a,b) -#endif -/*! \endcond */ - /* structures for ldb_parse_tree handling code */ @@ -1000,7 +1000,7 @@ int ldb_valid_attr_name(const char *s); \sa ldb_ldif_read for the reader equivalent to this function. */ int ldb_ldif_write(struct ldb_context *ldb, - int (*fprintf_fn)(void *, const char *, ...), + int (*fprintf_fn)(void *, const char *, ...) PRINTF_ATTRIBUTE(2,3), void *private_data, const struct ldb_ldif *ldif); @@ -1329,7 +1329,7 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); */ int ldb_set_debug(struct ldb_context *ldb, void (*debug)(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap), + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0), void *context); /** diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 754e4bc859..d66b6f1cc7 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -148,7 +148,7 @@ int ldb_next_del_trans(struct ldb_module *module); int ldb_next_init(struct ldb_module *module); void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); -void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...); +void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); void ldb_reset_err_string(struct ldb_context *ldb); int ldb_register_module(const struct ldb_module_ops *); -- cgit From a2ca0b5e3cf2e1ac485f7046d67de9fc4e5171f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Aug 2006 06:41:37 +0000 Subject: r17821: changed ldb_search() and the ldbsearch command line utility to automatically work out the basedn when basedn==NULL. The basedn is fetched from the rootDSE defaultNamingContext value (if there is one) This means we don't have to have the defaultNamingContext logic in lots of places. It makes a lot of sense to me to have basedn==NULL mean "use the default, as given by the database" Note that explicitly specifing a basedn of '' is not the same thing, and will not trigger this code The baseDN is cached in a ldb opaque, so we only have to fetch it once (This used to be commit 5d1b66b68fc517ce684f75e466ed5f25e46857d5) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b07cdd964c..415eacbf61 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -822,6 +822,11 @@ struct ldb_context *ldb_init(void *mem_ctx); */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); +/* + return an automatic baseDN from the defaultNamingContext of the rootDSE +*/ +const struct ldb_dn *ldb_auto_basedn(struct ldb_context *ldb); + /** Search the database -- cgit From 88b04ab6e65137079b2dad76d1cea07e7ea9ab80 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 25 Aug 2006 12:59:03 +0000 Subject: r17830: Set the default_basedn (hey, it comes from the "default" naming contex :-) once at connection time, after modules have been loaded. Introduce a function to retrieve the value where needed. (This used to be commit 0caf6a44e03393c645030a9288e7dfd31e97c98b) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 415eacbf61..124cba9b66 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -824,8 +824,9 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co /* return an automatic baseDN from the defaultNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time */ -const struct ldb_dn *ldb_auto_basedn(struct ldb_context *ldb); +const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** Search the database -- cgit From 38fdde5d9bf15b10caa60ee216d278ba8d870c2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4) --- source4/lib/ldb/include/includes.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 31997d6008..0a73f7728f 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -6,19 +6,19 @@ #ifdef _SAMBA_BUILD_ -#include "system/filesys.h" -#include "system/locale.h" -#include "system/time.h" - /* tell ldb we have the internal ldap code */ #define HAVE_ILDAP 1 -#else /*_SAMBA_BUILD_*/ +#else +#include "config.h" +#endif /*_SAMBA_BUILD_*/ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include "config.h" +#ifdef HAVE_REPLACE_H +#include "replace.h" +#endif #include #include #include @@ -51,8 +51,6 @@ typedef int (*comparison_fn_t)(const void *, const void *); #include "talloc.h" -#endif /*_SAMBA_BUILD_*/ - #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" -- cgit From 58316b88e52c0f7a7a7224ab9fc735091dd55948 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 00:06:30 +0000 Subject: r18112: really make use of libreplace in ldb (This used to be commit 2057159c7575479c9808aeffe711fc861e53f3c8) --- source4/lib/ldb/include/includes.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 0a73f7728f..636f01223f 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -5,20 +5,14 @@ */ #ifdef _SAMBA_BUILD_ - /* tell ldb we have the internal ldap code */ #define HAVE_ILDAP 1 - -#else -#include "config.h" -#endif /*_SAMBA_BUILD_*/ +#endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#ifdef HAVE_REPLACE_H #include "replace.h" -#endif #include #include #include -- cgit From 6d2dd5a2383410e3f50a9765b45c364a2d75a984 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 00:20:08 +0000 Subject: r18115: comparison_fn_t is defined in libreplace now (This used to be commit e9ee8b1053875fd3ddc950e3b21feb106eb3850c) --- source4/lib/ldb/include/includes.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 636f01223f..f761d358c9 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -39,9 +39,6 @@ #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -#ifndef HAVE_COMPARISON_FN_T -typedef int (*comparison_fn_t)(const void *, const void *); -#endif #include "talloc.h" -- cgit From a983b06d37c3b87a02444d9a9862777b88629344 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 04:44:32 +0000 Subject: r18129: moved the system includes into libreplace - this gives much more isolation of our portability environment from the main code, and also simplifies the includes system (no separate #ifdef _SAMBA_BUILD for tdb. ldb etc now) (This used to be commit 77d1a468e06290aba789e2f3affc769fc5159a21) --- source4/lib/ldb/include/includes.h | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index f761d358c9..800ffdf568 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -9,39 +9,14 @@ #define HAVE_ILDAP 1 #endif -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include "replace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_DLFCN_H -#include -#endif - #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#include "replace.h" +#include "system/filesys.h" +#include "system/network.h" +#include "system/time.h" #include "talloc.h" - #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" -- cgit From 8d1b32083eb9f35b5e3de3354480aa5e0e8a76d1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Sep 2006 06:14:32 +0000 Subject: r18777: add helper functions to create an ldb_request structure (This used to be commit bcbe82873f2f0a4e2552ed27eb171028de4560a7) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 124cba9b66..78d701689d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -743,6 +743,7 @@ struct ldb_sequence_number { uint64_t seq_num; }; +typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *); struct ldb_request { enum ldb_request_type operation; @@ -761,7 +762,7 @@ struct ldb_request { struct ldb_control **controls; void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); + ldb_request_callback_t callback; int timeout; time_t starttime; -- cgit From 77db3973c417cc934485dbd6bf1a8a1c84c1b30b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Sep 2006 06:44:12 +0000 Subject: r18781: Move the usnCreated and usnChanged handling around again. This moves these attributes from objectguid into an optional backend (objectguid), used by ltdb. For OpenLDAP, the entryUUID module converts entryCSN into usnChanged. This also changes the sequence number API, and uses 'time based' sequence numbers, when an LDAP or similar backend is detected. To assist this, we also store the last modified time in the TDB, whenever we change a value. Andrew Bartlett (This used to be commit 72858f859483c0c532dddb2c146d6bd7b9be5072) --- source4/lib/ldb/include/ldb.h | 11 ++++++----- source4/lib/ldb/include/ldb_private.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 78d701689d..cf4a1f282b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -740,7 +740,13 @@ struct ldb_register_partition { }; struct ldb_sequence_number { + enum ldb_sequence_type { + LDB_SEQ_HIGHEST_SEQ, + LDB_SEQ_HIGHEST_TIMESTAMP, + LDB_SEQ_NEXT + } type; uint64_t seq_num; + uint32_t flags; }; typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *); @@ -922,11 +928,6 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); -/** - Obtain current database sequence number -*/ -int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num); - /** start a transaction */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d66b6f1cc7..96b71ff3b4 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -207,4 +207,14 @@ int check_critical_controls(struct ldb_control **controls); /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); + +/** + Obtain current/next database sequence number +*/ +int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); + +#define LDB_SEQ_GLOBAL_SEQUENCE 0x01 +#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 + + #endif -- cgit From 58619eebc10cf3e1828f8ecad1362d98ca4e9845 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Sep 2006 23:22:39 +0000 Subject: r18831: minor build changes for samba3. The logging changes will be removed when the tdb api is updated (This used to be commit 6ace943fac101839e35cbc83dc54fde2068f704b) --- source4/lib/ldb/include/dlinklist.h | 2 ++ source4/lib/ldb/include/includes.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index 176c138aaf..3779a4cc61 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -37,6 +37,7 @@ do { \ } while (0) /* remove an element from a list - element doesn't have to be in list. */ +#ifndef DLIST_REMOVE #define DLIST_REMOVE(list, p) \ do { \ if ((p) == (list)) { \ @@ -48,6 +49,7 @@ do { \ } \ if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \ } while (0) +#endif /* promote an element to the top of the list */ #define DLIST_PROMOTE(list, p) \ diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 800ffdf568..ce0d40e101 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -4,11 +4,20 @@ a temporary includes file until I work on the ldb build system */ -#ifdef _SAMBA_BUILD_ +#if (_SAMBA_BUILD_ >= 4) /* tell ldb we have the internal ldap code */ #define HAVE_ILDAP 1 #endif +#if (_SAMBA_BUILD_ <= 3) +/* allow forbidden string functions - should be replaced with _m functions */ +#undef strcasecmp +#undef strncasecmp +#define dyn_MODULESDIR dyn_LIBDIR +#endif + + + #define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -- cgit From 4c3b07b654f4eb9041da0e9a84bc60d667901fe5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 Sep 2006 05:57:41 +0000 Subject: r18942: add a ldb_set_create_perms() function in ldb. I didn't call it ldb_set_umask() (which is what we had discussed) as it doesn't actually set the umask (in effect it sets the inverse of the umask - the perms to be used for the file) (This used to be commit 7e2ec875908c112d5c3b0f6d18f9a8bbacf33539) --- source4/lib/ldb/include/ldb.h | 1 + source4/lib/ldb/include/ldb_private.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index cf4a1f282b..82da9df0dd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -781,6 +781,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); +void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); /** Initialise ldbs' global information diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 96b71ff3b4..3cacd5e292 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -119,6 +119,8 @@ struct ldb_context { int default_timeout; unsigned int flags; + + unsigned int create_perms; }; #ifndef ARRAY_SIZE -- cgit From bbc056e067e1b721dc2ef6958ab653c1eddec3a1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Oct 2006 09:56:13 +0000 Subject: r19196: merge from samba3: pass always a mem_ctx to functions and a ldb_context where needed metze (This used to be commit 67a6a41ba3af840cd8226de73576a90ecf602caa) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 82da9df0dd..d2f3bd53d3 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1146,11 +1146,11 @@ struct ldb_dn *ldb_dn_new(void *mem_ctx); struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn); char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); -char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); +char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn); int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); -struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn); +struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, const char *dn); struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el); struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn); struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn); -- cgit From 0cf42c464ea240c4e57cc5b0c31227a0c5f684d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Oct 2006 05:50:01 +0000 Subject: r19365: fixed a memory leak in the ldb attribute handling (This used to be commit d7e07685164141f8fb2c2a6258e1fcb46ff9d06c) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d2f3bd53d3..0af734eb13 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -357,6 +357,9 @@ struct ldb_attrib_handler { */ #define LDB_ATTR_FLAG_HIDDEN (1<<0) +/* the attribute handler name should be freed when released */ +#define LDB_ATTR_FLAG_ALLOCATED (1<<1) + /** The attribute is constructed from other attributes */ -- cgit From 21e63dca9b6503d377c5605384341cd7079b868b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 22 Oct 2006 21:16:22 +0000 Subject: r19453: Expose helper functions (This used to be commit ee86e88e4f523d67900b52b5a4d4040a76360c61) --- source4/lib/ldb/include/ldb.h | 141 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0af734eb13..62e8039a2c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -839,6 +839,145 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co */ const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); + +/** + The Default iasync search callback function + + \param ldb the context associated with the database (from ldb_init()) + \param context the callback context + \param ares a single reply from the async core + + \return result code (LDB_SUCCESS on success, or a failure code) + + \note this function expects the context to always be an struct ldb_result pointer + AND a talloc context, this function will steal on the context each message + from the ares reply passed on by the async core so that in the end all the + messages will be in the context (ldb_result) memory tree. + Freeing the passed context (ldb_result tree) will free all the resources + (the request need to be freed separately and the result doe not depend on the + request that can be freed as sson as the search request is finished) +*/ + +int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); + +/** + Helper function to build a search request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) + \param scope the search scope for the query + \param expression the search expression to use for this query + \param attrs the search attributes for the query (pass NULL if none required) + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_search_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build an add request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param message contains the entry to be added + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_add_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_message *message, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a modify request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param message contains the entry to be modified + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_mod_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_message *message, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a delete request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param dn the DN to be deleted + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_del_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *dn, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a rename request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param olddn the old DN + \param newdn the new DN + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_rename_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *olddn, + const struct ldb_dn *newdn, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + /** Search the database @@ -846,7 +985,7 @@ const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); records that match an LDAP-like search expression \param ldb the context associated with the database (from ldb_init()) - \param base the Base Distinguished Name for the query (pass NULL for root DN) + \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) \param scope the search scope for the query \param expression the search expression to use for this query \param attrs the search attributes for the query (pass NULL if none required) -- cgit From 002338283fe2fae7d6271dff7f78b537810af5f3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 22 Oct 2006 21:17:30 +0000 Subject: r19455: forgot this (This used to be commit 2b770885cd234027f92ba543706df5d55f16f739) --- source4/lib/ldb/include/ldb_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3cacd5e292..3902bb2fc2 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -170,6 +170,7 @@ int ldb_operational_init(void); int ldb_paged_results_init(void); int ldb_rdn_name_init(void); int ldb_schema_init(void); +int ldb_asq_init(void); int ldb_sort_init(void); int ldb_ldap_init(void); int ldb_ildap_init(void); -- cgit From 7f833458ca0083654e34cbfde1c6c6510cab1826 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 25 Oct 2006 01:42:59 +0000 Subject: r19489: Change ldb_msg_add_value and ldb_msg_add_empty to take a foruth argument. This is a pointer to an element pointer. If it is not null it will be filled with the pointer of the manipulated element. Will avoid double searches on the elements list in some cases. (This used to be commit 0fa5d4bc225b83e9f63ac6d75bffc4c08eb6b620) --- source4/lib/ldb/include/ldb.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 62e8039a2c..aa8b9447b2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1366,7 +1366,10 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, /** add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_message *msg, + const char *attr_name, + int flags, + struct ldb_message_element **return_el); /** add a element to a ldb_message @@ -1375,8 +1378,9 @@ int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); int ldb_msg_add_value(struct ldb_message *msg, - const char *attr_name, - const struct ldb_val *val); + const char *attr_name, + const struct ldb_val *val, + struct ldb_message_element **return_el); int ldb_msg_add_steal_value(struct ldb_message *msg, const char *attr_name, struct ldb_val *val); -- cgit From b7774527faf095f612eb1de48efacec6bd710a87 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 1 Nov 2006 23:31:26 +0000 Subject: r19531: Make struct ldb_dn opaque and local to ldb_dn.c (This used to be commit 889fb983ba1cf8a11424a8b3dc3a5ef76e780082) --- source4/lib/ldb/include/ldb.h | 62 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index aa8b9447b2..17a2ec7556 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -3,7 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-2006 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -86,18 +86,9 @@ struct ldb_val { #endif /*! \endcond */ -/** - internal ldb exploded dn structures -*/ -struct ldb_dn_component { - char *name; - struct ldb_val value; -}; - -struct ldb_dn { - int comp_num; - struct ldb_dn_component *components; -}; +/* opaque ldb_dn structures, see ldb_dn.c for internals */ +struct ldb_dn_component; +struct ldb_dn; /** There are a number of flags that are used with ldap_modify() in @@ -193,12 +184,6 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1, struct ldb_context; -/* - the fuction type for the callback used in traversing the database -*/ -typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); - - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -333,22 +318,25 @@ char *ldb_binary_encode_string(void *mem_ctx, const char *string); typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); +/* + attribute handler structure + + attr -> The attribute name + flags -> LDB_ATTR_FLAG_* + ldif_read_fn -> convert from ldif to binary format + ldif_write_fn -> convert from binary to ldif format + canonicalise_fn -> canonicalise a value, for use by indexing and dn construction + comparison_fn -> compare two values +*/ + struct ldb_attrib_handler { - const char *attr; - /* LDB_ATTR_FLAG_* */ + const char *attr; unsigned flags; - /* convert from ldif to binary format */ ldb_attr_handler_t ldif_read_fn; - - /* convert from binary to ldif format */ ldb_attr_handler_t ldif_write_fn; - - /* canonicalise a value, for use by indexing and dn construction */ ldb_attr_handler_t canonicalise_fn; - - /* compare two values */ ldb_attr_comparison_t comparison_fn; }; @@ -1295,18 +1283,25 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const str struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, const char *dn); struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el); struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn); +struct ldb_dn *ldb_dn_copy_rebase(void *mem_ctx, const struct ldb_dn *old, const struct ldb_dn *old_base, const struct ldb_dn *new_base); struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn); struct ldb_dn_component *ldb_dn_build_component(void *mem_ctx, const char *attr, const char *val); struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr, const char * value, const struct ldb_dn *base); -struct ldb_dn *ldb_dn_make_child(void *mem_ctx, - const struct ldb_dn_component *component, - const struct ldb_dn *base); struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); -struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); +int ldb_dn_get_comp_num(const struct ldb_dn *dn); +const char *ldb_dn_get_component_name(const struct ldb_dn *dn, unsigned int num); +const struct ldb_val *ldb_dn_get_component_val(const struct ldb_dn *dn, unsigned int num); +const char *ldb_dn_get_rdn_name(const struct ldb_dn *dn); +const struct ldb_val *ldb_dn_get_rdn_val(const struct ldb_dn *dn); +int ldb_dn_set_component(struct ldb_dn *dn, int num, const char *name, const struct ldb_val val); + + /* useful functions for ldb_message structure manipulation */ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); @@ -1546,9 +1541,6 @@ char *ldb_timestring(void *mem_ctx, time_t t); */ time_t ldb_string_to_time(const char *s); -char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); - void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif -- cgit From adae413042e15e7228bcc25321913b38ae61358a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 16 Nov 2006 09:16:17 +0000 Subject: r19731: Modify the ldb_map infrustructure to always map from requested attributes to backend (remote) attributes. We can't do a reverse mapping safely where the remote attribute may be a source for multiple local attributes. (We end up with the wrong attributes returned). In doing this, I've modified the samba3sam.js test to be more realistic, and fixed some failures in the handling of primaryGroupID. I've added a new (private) helper function ldb_msg_remove_element() to avoid a double lookup of the element name. I've also re-formatted many of the function headers, to fit into standard editor widths. Andrew Bartlett (This used to be commit 186766e3095e71ba716c69e681592e217a3bc420) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3902bb2fc2..f4049188ad 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -211,6 +211,8 @@ int check_critical_controls(struct ldb_control **controls); /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); +void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); + /** Obtain current/next database sequence number */ -- cgit From 4889eb9f7aae9349e426d0f6d2217adff67eaebd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 00:59:34 +0000 Subject: r19831: Big ldb_dn optimization and interfaces enhancement patch This patch changes a lot of the code in ldb_dn.c, and also removes and add a number of manipulation functions around. The aim is to avoid validating a dn if not necessary as the validation code is necessarily slow. This is mainly to speed up internal operations where input is not user generated and so we can assume the DNs need no validation. The code is designed to keep the data as a string if possible. The code is not yet 100% perfect, but pass all the tests so far. A memleak is certainly present, I'll work on that next. Simo. (This used to be commit a580c871d3784602a9cce32d33419e63c8236e63) --- source4/lib/ldb/include/ldb.h | 94 ++++++++++++++++++----------------- source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 50 insertions(+), 46 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 17a2ec7556..46894cd3c0 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -698,7 +698,7 @@ struct ldb_handle { }; struct ldb_search { - const struct ldb_dn *base; + struct ldb_dn *base; enum ldb_scope scope; const struct ldb_parse_tree *tree; const char * const *attrs; @@ -714,12 +714,12 @@ struct ldb_modify { }; struct ldb_delete { - const struct ldb_dn *dn; + struct ldb_dn *dn; }; struct ldb_rename { - const struct ldb_dn *olddn; - const struct ldb_dn *newdn; + struct ldb_dn *olddn; + struct ldb_dn *newdn; }; struct ldb_register_control { @@ -727,7 +727,7 @@ struct ldb_register_control { }; struct ldb_register_partition { - const struct ldb_dn *dn; + struct ldb_dn *dn; }; struct ldb_sequence_number { @@ -825,7 +825,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co return an automatic baseDN from the defaultNamingContext of the rootDSE This value have been set in an opaque pointer at connection time */ -const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); +struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** @@ -868,7 +868,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l int ldb_build_search_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, @@ -937,7 +937,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *dn, + struct ldb_dn *dn, struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -960,8 +960,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *olddn, - const struct ldb_dn *newdn, + struct ldb_dn *olddn, + struct ldb_dn *newdn, struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -984,7 +984,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req, \note use talloc_free() to free the ldb_result returned */ int ldb_search(struct ldb_context *ldb, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_result **res); @@ -993,7 +993,7 @@ int ldb_search(struct ldb_context *ldb, like ldb_search() but takes a parse tree */ int ldb_search_bytree(struct ldb_context *ldb, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_result **res); @@ -1043,7 +1043,7 @@ int ldb_modify(struct ldb_context *ldb, \return result code (LDB_SUCCESS if the record was renamed as requested, otherwise a failure code) */ -int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); +int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *newdn); /** Delete a record from the database @@ -1057,7 +1057,7 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct \return result code (LDB_SUCCESS if the record was deleted, otherwise a failure code) */ -int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); /** start a transaction @@ -1269,38 +1269,41 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* The following definitions come from lib/ldb/common/ldb_dn.c */ -int ldb_dn_is_special(const struct ldb_dn *dn); -int ldb_dn_check_special(const struct ldb_dn *dn, const char *check); +struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...); +bool ldb_dn_validate(struct ldb_dn *dn); + char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -struct ldb_dn *ldb_dn_new(void *mem_ctx); -struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); -struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn); -char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn); -char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn); -int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); -int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); -struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn); -struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, const char *dn); -struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el); -struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn); -struct ldb_dn *ldb_dn_copy_rebase(void *mem_ctx, const struct ldb_dn *old, const struct ldb_dn *old_base, const struct ldb_dn *new_base); -struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn); -struct ldb_dn_component *ldb_dn_build_component(void *mem_ctx, const char *attr, - const char *val); -struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr, - const char * value, - const struct ldb_dn *base); -struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); -struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); -char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); -int ldb_dn_get_comp_num(const struct ldb_dn *dn); -const char *ldb_dn_get_component_name(const struct ldb_dn *dn, unsigned int num); -const struct ldb_val *ldb_dn_get_component_val(const struct ldb_dn *dn, unsigned int num); -const char *ldb_dn_get_rdn_name(const struct ldb_dn *dn); -const struct ldb_val *ldb_dn_get_rdn_val(const struct ldb_dn *dn); +char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn); +const char *ldb_dn_get_linearized(struct ldb_dn *dn); +const char *ldb_dn_get_casefold(struct ldb_dn *dn); + +int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); +int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); + +bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base); +bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...); +bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child); +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); +bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); + +struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_string(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, struct ldb_dn *dn); +int ldb_dn_get_comp_num(struct ldb_dn *dn); +const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num); +const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num); +const char *ldb_dn_get_rdn_name(struct ldb_dn *dn); +const struct ldb_val *ldb_dn_get_rdn_val(struct ldb_dn *dn); int ldb_dn_set_component(struct ldb_dn *dn, int num, const char *name, const struct ldb_val val); +bool ldb_dn_is_valid(struct ldb_dn *dn); +bool ldb_dn_is_special(struct ldb_dn *dn); +bool ldb_dn_check_special(struct ldb_dn *dn, const char *check); +bool ldb_dn_is_null(struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ @@ -1422,9 +1425,10 @@ const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); -struct ldb_dn *ldb_msg_find_attr_as_dn(void *mem_ctx, +struct ldb_dn *ldb_msg_find_attr_as_dn(struct ldb_context *ldb, + void *mem_ctx, const struct ldb_message *msg, - const char *attr_name); + const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index f4049188ad..d597f30232 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -180,7 +180,7 @@ int ldb_sqlite3_init(void); int ldb_match_msg(struct ldb_context *ldb, const struct ldb_message *msg, const struct ldb_parse_tree *tree, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope); void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); -- cgit From a9e31b33b55a873c2f01db5e348560176adf863d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 02:05:19 +0000 Subject: r19832: better prototypes for the linearization functions: - ldb_dn_get_linearized returns a const string - ldb_dn_alloc_linearized allocs astring with the linearized dn (This used to be commit 3929c086d5d0b3f08b1c4f2f3f9602c3f4a9a4bd) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 46894cd3c0..c44c1d6ee7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1274,10 +1274,10 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn); const char *ldb_dn_get_linearized(struct ldb_dn *dn); const char *ldb_dn_get_casefold(struct ldb_dn *dn); +char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn); int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); -- cgit From c05c41d3521e8782be01b0413f3551d10487a1ac Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 25 Nov 2006 15:43:56 +0000 Subject: r19888: make it possible to use default attrib handlers from extensions list more DN attributes as part of samba attribute handlers (nCName moved here) (This used to be commit 627ed8b5165c9a1cc0e2c67329b364f9cd8a1726) --- source4/lib/ldb/include/ldb_handlers.h | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 source4/lib/ldb/include/ldb_handlers.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_handlers.h b/source4/lib/ldb/include/ldb_handlers.h new file mode 100644 index 0000000000..e340fe7367 --- /dev/null +++ b/source4/lib/ldb/include/ldb_handlers.h @@ -0,0 +1,68 @@ +/* + ldb database library + + Copyright (C) Simo Sorce 2005 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb header + * + * Description: defines attribute handlers + * + * Author: Simo Sorce + */ + + +int ldb_handler_copy( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out); + +int ldb_handler_fold( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out); + +int ldb_canonicalise_Integer( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out); + +int ldb_comparison_Integer( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_comparison_binary( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_comparison_fold( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_canonicalise_dn( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out); + +int ldb_comparison_dn( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_comparison_objectclass( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_comparison_utctime( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *v1, const struct ldb_val *v2); + +int ldb_canonicalise_utctime( struct ldb_context *ldb, void *mem_ctx, + const struct ldb_val *in, struct ldb_val *out); + -- cgit From 4f8b4a8ef19da2bcbeea1ae79e9ebbdb8de08169 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Nov 2006 04:39:17 +0000 Subject: r19906: ldb_attr_cmp is used a lot remove unneded overhead of a function call (This used to be commit 3ca25867621af049c6cc52e919fa46dd26c31918) --- source4/lib/ldb/include/ldb.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c44c1d6ee7..9d48810078 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1320,8 +1320,12 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); \return 0 if the attribute names are the same, or only differ in case; non-zero if there are any differences + + attribute names are restricted by rfc2251 so using + strcasecmp and toupper here is ok. + return 0 for match */ -int ldb_attr_cmp(const char *attr1, const char *attr2); +#define ldb_attr_cmp(a, b) strcasecmp(a, b) char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); -- cgit From ea212eb00fd358e7335648b9cd556227e53df367 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 5 Dec 2006 04:25:27 +0000 Subject: r20034: Start using ldb_search_exp_fmt() (This used to be commit 4f07542143ddf5066f0360d965f26a8470504047) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9d48810078..dfa447b534 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,6 +989,9 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_result **res); +int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, + struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...); /* like ldb_search() but takes a parse tree */ -- cgit From dec69975f5d62d4c2d038ad22d405e5cb183d78b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 5 Dec 2006 16:20:39 +0000 Subject: r20046: Add ldb_search_exp_fmt and port comment to 4 (This used to be commit 879dfed8d8356aae6a11352b89bdc0f2d9f28970) --- source4/lib/ldb/include/ldb.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dfa447b534..eb1f505099 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,9 +989,16 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_result **res); -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, - struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...); +/* + * a useful search function where you can easily define the expression and + * that takes a memory context where results are allocated +*/ + +int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, + struct ldb_result **result, struct ldb_dn *base, + enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...); + /* like ldb_search() but takes a parse tree */ -- cgit From e55ff42229d67c1447f2c811191b79137b1ce8cc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Dec 2006 10:03:21 +0000 Subject: r20168: start separating attributes and syntaxes metze (This used to be commit 8dda4342f648aa71878ac9eeb7941710e2813aee) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ source4/lib/ldb/include/ldb_private.h | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index eb1f505099..3db334d341 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -340,6 +340,14 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; +struct ldb_schema_syntax { + const char *name; + ldb_attr_handler_t ldif_read_fn; + ldb_attr_handler_t ldif_write_fn; + ldb_attr_handler_t canonicalise_fn; + ldb_attr_comparison_t comparison_fn; +}; + /** The attribute is not returned by default */ diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d597f30232..02fb370e16 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -184,8 +184,8 @@ int ldb_match_msg(struct ldb_context *ldb, enum ldb_scope scope); void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); -const struct ldb_attrib_handler *ldb_attrib_handler_syntax(struct ldb_context *ldb, - const char *syntax); +const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, + const char *syntax); int ldb_set_attrib_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers); -- cgit From c69717755abeaf8bf93e76255d0912e3a24b7cb0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Dec 2006 13:08:57 +0000 Subject: r20184: change ldb_attrib_handler into ldb_schema_attribute, which has a pointer to a ldb_schema_syntax struct. the default attribute handler is now registered dynamicly as "*" attribute, instead of having its own code path. ldb_schema_attribute's can be added to the ldb_schema given a ldb_schema_syntax struct or the syntax name we may also need to introduce a ldb_schema_matching_rule, and add a pointer to a default ldb_schema_matching_rule in the ldb_schema_syntax. metze (This used to be commit b97b8f5dcbce006f005e53ca79df3330e62f117b) --- source4/lib/ldb/include/ldb.h | 26 ++++++++------------------ source4/lib/ldb/include/ldb_private.h | 23 ++++++++++++++--------- 2 files changed, 22 insertions(+), 27 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3db334d341..853adb82c6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -329,25 +329,23 @@ typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const comparison_fn -> compare two values */ -struct ldb_attrib_handler { - - const char *attr; - unsigned flags; - +struct ldb_schema_syntax { + const char *name; ldb_attr_handler_t ldif_read_fn; ldb_attr_handler_t ldif_write_fn; ldb_attr_handler_t canonicalise_fn; ldb_attr_comparison_t comparison_fn; }; -struct ldb_schema_syntax { +struct ldb_schema_attribute { const char *name; - ldb_attr_handler_t ldif_read_fn; - ldb_attr_handler_t ldif_write_fn; - ldb_attr_handler_t canonicalise_fn; - ldb_attr_comparison_t comparison_fn; + unsigned flags; + const struct ldb_schema_syntax *syntax; }; +const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_context *ldb, + const char *name); + /** The attribute is not returned by default */ @@ -1281,10 +1279,6 @@ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); */ int ldb_base64_decode(char *s); -int ldb_attrib_add_handlers(struct ldb_context *ldb, - const struct ldb_attrib_handler *handlers, - unsigned num_handlers); - /* The following definitions come from lib/ldb/common/ldb_dn.c */ struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); @@ -1524,10 +1518,6 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); -const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, - const char *attrib); - - const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 02fb370e16..81993efaef 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -79,8 +79,8 @@ typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigne */ struct ldb_schema { /* attribute handling table */ - unsigned num_attrib_handlers; - struct ldb_attrib_handler *attrib_handlers; + unsigned num_attributes; + struct ldb_schema_attribute *attributes; /* objectclass information */ unsigned num_classes; @@ -183,17 +183,22 @@ int ldb_match_msg(struct ldb_context *ldb, struct ldb_dn *base, enum ldb_scope scope); -void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib); const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, const char *syntax); -int ldb_set_attrib_handlers(struct ldb_context *ldb, - const struct ldb_attrib_handler *handlers, - unsigned num_handlers); -int ldb_setup_wellknown_attributes(struct ldb_context *ldb); -int ldb_set_attrib_handler_syntax(struct ldb_context *ldb, - const char *attr, const char *syntax); /* The following definitions come from lib/ldb/common/ldb_attributes.c */ + +int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, + const char *name, + unsigned flags, + const struct ldb_schema_syntax *syntax); +int ldb_schema_attribute_add(struct ldb_context *ldb, + const char *name, + unsigned flags, + const char *syntax); +void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); +int ldb_setup_wellknown_attributes(struct ldb_context *ldb); + const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname); void ldb_subclass_remove(struct ldb_context *ldb, const char *classname); int ldb_subclass_add(struct ldb_context *ldb, const char *classname, const char *subclass); -- cgit From a3c0f3035d338b5bf00ecd436cb0ebfcbdc7345d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Dec 2006 20:22:17 +0000 Subject: r20189: remove unused struct element metze (This used to be commit d20d1872d5ed1176928b85ef9811c6a5177d0148) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 853adb82c6..b00bb0fd46 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -156,7 +156,6 @@ struct ldb_message { struct ldb_dn *dn; unsigned int num_elements; struct ldb_message_element *elements; - void *private_data; /* private to the backend */ }; enum ldb_changetype { -- cgit From 525447821e70e089d03713ff92d0ad0f2860b38f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 16:53:12 +0000 Subject: r20316: fix compiler warning metze (This used to be commit 58cbbaa4b49bfed6d4e9c5802af988864e06675f) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b00bb0fd46..3f9ba67170 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1002,7 +1002,7 @@ int ldb_search(struct ldb_context *ldb, int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...); + const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); /* like ldb_search() but takes a parse tree -- cgit From c65b5a6f87dd1f859a8ccbdc709565ac7841006b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 17:26:09 +0000 Subject: r20319: fix compiler warnings metze (This used to be commit 3769270a6a22dd29845e889b0601fcdf7c46acb5) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3f9ba67170..0438b88bbb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1281,7 +1281,7 @@ int ldb_base64_decode(char *s); /* The following definitions come from lib/ldb/common/ldb_dn.c */ struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); -struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...); +struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); @@ -1294,9 +1294,9 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base); -bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...); +bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...) PRINTF_ATTRIBUTE(2,3); bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child); -bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...); +bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...) PRINTF_ATTRIBUTE(2,3); bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num); bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); -- cgit From 6f68945f7dc88814a5ed587512c7d29d18de5f34 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 17:27:07 +0000 Subject: r20320: add missing prototypes metze (This used to be commit b9d0ea3954e3f76436e976555540dd29dacd621d) --- source4/lib/ldb/include/ldb.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0438b88bbb..1e2a6b0bbd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -826,13 +826,30 @@ struct ldb_context *ldb_init(void *mem_ctx); */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); +/* + return an automatic basedn from the rootDomainNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_root_basedn(struct ldb_context *ldb); + +/* + return an automatic basedn from the configurationNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_config_basedn(struct ldb_context *ldb); + +/* + return an automatic basedn from the schemaNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_schema_basedn(struct ldb_context *ldb); + /* return an automatic baseDN from the defaultNamingContext of the rootDSE This value have been set in an opaque pointer at connection time */ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); - /** The Default iasync search callback function -- cgit From 71bc79caab7f9510151b31846755cc4db7b81ec0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Jan 2007 10:59:38 +0000 Subject: r20462: add functions to handle UTCTime strings metze (This used to be commit 49c7da812c290e23bb65b98a2710fb90c4a0ece2) --- source4/lib/ldb/include/ldb.h | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1e2a6b0bbd..4f8ee1f941 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1550,9 +1550,9 @@ void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); /** Convert a time structure to a string - This function converts a time_t structure to an LDAP formatted time - string. - + This function converts a time_t structure to an LDAP formatted + GeneralizedTime string. + \param mem_ctx the memory context to allocate the return string in \param t the time structure to convert @@ -1564,8 +1564,8 @@ char *ldb_timestring(void *mem_ctx, time_t t); /** Convert a string to a time structure - This function converts an LDAP formatted time string to a time_t - structure. + This function converts an LDAP formatted GeneralizedTime string + to a time_t structure. \param s the string to convert @@ -1573,6 +1573,32 @@ char *ldb_timestring(void *mem_ctx, time_t t); */ time_t ldb_string_to_time(const char *s); +/** + Convert a time structure to a string + + This function converts a time_t structure to an LDAP formatted + UTCTime string. + + \param mem_ctx the memory context to allocate the return string in + \param t the time structure to convert + + \return the formatted string, or NULL if the time structure could + not be converted +*/ +char *ldb_timestring_utc(void *mem_ctx, time_t t); + +/** + Convert a string to a time structure + + This function converts an LDAP formatted UTCTime string + to a time_t structure. + + \param s the string to convert + + \return the time structure, or 0 if the string cannot be converted +*/ +time_t ldb_string_utc_to_time(const char *s); + void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif -- cgit From f29ea516f99a250765c8a718d7212577167f7931 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:03:28 +0000 Subject: r20581: - the ldb modules have explicit hooks for extended operations so call them - reorder the request operations first all with explixit hooks metze (This used to be commit aababcbb05ad476507bba35723eaef01d18b4d4e) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4f8ee1f941..8a31720eea 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -651,9 +651,9 @@ enum ldb_request_type { LDB_DELETE, LDB_RENAME, LDB_EXTENDED, + LDB_SEQUENCE_NUMBER, LDB_REQ_REGISTER_CONTROL, - LDB_REQ_REGISTER_PARTITION, - LDB_SEQUENCE_NUMBER + LDB_REQ_REGISTER_PARTITION }; enum ldb_reply_type { -- cgit From bc4821a4ce06317219a6c801f99f3fe9a470f1ce Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:25:54 +0000 Subject: r20582: use void *data in the ldb_extended struct to match what we have in ldb_control add a request element for extended requests metze (This used to be commit 530b3cd2501efb7763cbb7d3301ff0550689effe) --- source4/lib/ldb/include/ldb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8a31720eea..63cfb04fdd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -683,8 +683,7 @@ struct ldb_result { struct ldb_extended { const char *oid; - const char *value; - int value_len; + void *data; }; struct ldb_reply { @@ -714,7 +713,7 @@ struct ldb_add { const struct ldb_message *message; }; -struct ldb_modify { +struct ldb_modify { const struct ldb_message *message; }; @@ -756,9 +755,10 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; + struct ldb_extended extended; + struct ldb_sequence_number seq_num; struct ldb_register_control reg_control; struct ldb_register_partition reg_partition; - struct ldb_sequence_number seq_num; } op; struct ldb_control **controls; -- cgit From b5eb73280e82905bafbe827e781481386c98cc82 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:49:29 +0000 Subject: r20583: implement the frontend calls for extended operations metze (This used to be commit cfcd05adc03effeaf85dc776c2d5bb5244f0d6d4) --- source4/lib/ldb/include/ldb.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 63cfb04fdd..78d5bba06e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -674,18 +674,19 @@ enum ldb_state { LDB_ASYNC_DONE }; +struct ldb_extended { + const char *oid; + void *data; +}; + struct ldb_result { unsigned int count; struct ldb_message **msgs; char **refs; + struct ldb_extended *extended; struct ldb_control **controls; }; -struct ldb_extended { - const char *oid; - void *data; -}; - struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; -- cgit From b931e6683508ddbd77a34725913f706870ed8eb7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 7 Jan 2007 15:26:35 +0000 Subject: r20596: add prototypes for the ldb_extended functions metze (This used to be commit 8d3a3117c313c2950381e8d21eb92469a82c3afe) --- source4/lib/ldb/include/ldb.h | 64 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 78d5bba06e..7b37b50468 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -852,10 +852,10 @@ struct ldb_dn *ldb_get_schema_basedn(struct ldb_context *ldb); struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** - The Default iasync search callback function + The default async search callback function \param ldb the context associated with the database (from ldb_init()) - \param context the callback context + \param context the callback context (struct ldb_result *) \param ares a single reply from the async core \return result code (LDB_SUCCESS on success, or a failure code) @@ -1092,6 +1092,66 @@ int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *new */ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); +/** + The default async extended operation callback function + + \param ldb the context associated with the database (from ldb_init()) + \param context the callback context (struct ldb_result *) + \param ares a single reply from the async core + + \return result code (LDB_SUCCESS on success, or a failure code) + + \note this function expects the context to always be an struct ldb_result pointer + AND a talloc context, this function will steal on the context each message + from the ares reply passed on by the async core so that in the end all the + messages will be in the context (ldb_result) memory tree. + Freeing the passed context (ldb_result tree) will free all the resources + (the request need to be freed separately and the result doe not depend on the + request that can be freed as sson as the search request is finished) +*/ +int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); + +/** + Helper function to build a extended request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param oid the OID of the extended operation. + \param data void pointer a the extended operation specific parameters + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ +int ldb_build_extended_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const char *oid, + void *data, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + call an extended operation + + This function deletes a record from the database. + + \param ldb the context associated with the database (from ldb_init()) + \param oid the OID of the extended operation. + \param data void pointer a the extended operation specific parameters + \param res the result of the extended operation + + \return result code (LDB_SUCCESS if the extended operation returned fine, + otherwise a failure code) +*/ +int ldb_extended(struct ldb_context *ldb, + const char *oid, + void *data, + struct ldb_result **res); + /** start a transaction */ -- cgit From 22f473b22bc2b2aae2b53a180b78c2e891ab956e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 7 Jan 2007 19:04:40 +0000 Subject: r20598: add comments and make clear that the void *data element for extended operations needs to be NULL or a valid talloc pointer as talloc_get_type() will be called on it. metze (This used to be commit 5731617ea9103eaaef2c5591aab89d59ded35fd8) --- source4/lib/ldb/include/ldb.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7b37b50468..62afbfb609 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -676,7 +676,7 @@ enum ldb_state { struct ldb_extended { const char *oid; - void *data; + void *data; /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ }; struct ldb_result { @@ -1118,7 +1118,8 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct \param ldb the context associated with the database (from ldb_init()) \param mem_ctx a talloc emmory context (used as parent of ret_req) \param oid the OID of the extended operation. - \param data void pointer a the extended operation specific parameters + \param data a void pointer a the extended operation specific parameters, + it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param controls an array of controls \param context the callback function context \param the callback function to handle the async replies @@ -1129,7 +1130,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, const char *oid, - void *data, + void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -1141,7 +1142,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req, \param ldb the context associated with the database (from ldb_init()) \param oid the OID of the extended operation. - \param data void pointer a the extended operation specific parameters + \param data a void pointer a the extended operation specific parameters, + it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param res the result of the extended operation \return result code (LDB_SUCCESS if the extended operation returned fine, @@ -1149,7 +1151,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req, */ int ldb_extended(struct ldb_context *ldb, const char *oid, - void *data, + void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_result **res); /** -- cgit From 0c29f6d56da1ce9b01a54be6a8d3a48cf6b2e27f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 14 Jan 2007 13:43:09 +0000 Subject: r20761: let ldb modules call ldb_set_default_dns() metze (This used to be commit 224a31cdbf12a555b8c46786c9f83fec8e839c5a) --- source4/lib/ldb/include/ldb_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 81993efaef..3c6fb828a2 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -136,6 +136,7 @@ struct ldb_context { int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[], struct ldb_module **backend_module); +void ldb_set_default_dns(struct ldb_context *ldb); /* The following definitions come from lib/ldb/common/ldb_modules.c */ -- cgit From fb9dabe39e18ff9cfd3abb4160ba19971ca33795 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Jan 2007 16:10:33 +0000 Subject: r20852: add a function to add a ldb control to a ldb_request metze (This used to be commit f0bf86ed66f7f9995df35db55f2f3875e7dbacbe) --- source4/lib/ldb/include/ldb.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 62afbfb609..9cc5904348 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,6 +989,18 @@ int ldb_build_rename_req(struct ldb_request **ret_req, void *context, ldb_request_callback_t callback); +/** + Add a ldb_control to a ldb_request + + \param req the request struct where to add the control + \param oid the object identifier of the control as string + \param ciritical whether the control should be critical or not + \param data a talloc pointer to the control specific data + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ +int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data); + /** Search the database -- cgit From 7dc7156bd76425df129102a42dd29a85fd8c7ebc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Feb 2007 01:54:40 +0000 Subject: r21496: A number of ldb control and LDAP changes, surrounding the 'phantom_root' flag in the search_options control - Add in support for LDB controls to the js layer - Test the behaviour - Implement support for the 'phantom_root' flag in the partitions module - Make the LDAP server set the 'phantom_root' flag in the search_options control - This replaces the global_catalog flag passed down as an opaque pointer - Rework the string-format control parsing function into ldb_parse_control_strings(), returning errors by ldb_errorstring() method, rather than with printf to stderr - Rework some of the ldb_control handling logic Andrew Bartlett (This used to be commit 2b3df7f38d7790358dbb4de1b8609bf794a351fb) --- source4/lib/ldb/include/ldb.h | 60 +++++++++++++++++++++++------------ source4/lib/ldb/include/ldb_private.h | 3 ++ 2 files changed, 42 insertions(+), 21 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9cc5904348..3e09cf1506 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -535,18 +535,10 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); #define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" /** - OID for LDAP Extended Operation START_TLS. - - This Extended operation is used to start a new TLS - channel on top of a clear text channel. */ #define LDB_EXTENDED_DYNAMIC_OID "1.3.6.1.4.1.1466.101.119.1" /** - OID for LDAP Extended Operation START_TLS. - - This Extended operation is used to start a new TLS - channel on top of a clear text channel. */ #define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" @@ -560,20 +552,24 @@ struct ldb_sd_flags_control { unsigned secinfo_flags; }; +/* + * DOMAIN_SCOPE 0x00000001 + * this limits the search to one partition, + * and no referrals will be returned. + * (Note this doesn't limit the entries by there + * objectSid belonging to a domain! Builtin and Foreign Sids + * are still returned) + * + * PHANTOM_ROOT 0x00000002 + * this search on the whole tree on a domain controller + * over multiple partitions without referrals. + * (This is the default behavior on the Global Catalog Port) + */ + +#define LDB_SEARCH_OPTION_DOMAIN_SCOPE 0x00000001 +#define LDB_SEARCH_OPTION_PHANTOM_ROOT 0x00000002 + struct ldb_search_options_control { - /* - * DOMAIN_SCOPE 0x00000001 - * this limits the search to one partition, - * and no referrals will be returned. - * (Note this doesn't limit the entries by there - * objectSid belonging to a domain! Builtin and Foreign Sids - * are still returned) - * - * PHANTOM_ROOT 0x00000002 - * this search on the whole tree on a domain controller - * over multiple partitions without referrals. - * (This is the default behavior on the Global Catalog Port) - */ unsigned search_options; }; @@ -1001,6 +997,15 @@ int ldb_build_rename_req(struct ldb_request **ret_req, */ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data); +/** + check if a control with the specified "oid" exist and return it + \param req the request struct where to add the control + \param oid the object identifier of the control as string + + \return the control, NULL if not found +*/ +struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid); + /** Search the database @@ -1676,4 +1681,17 @@ time_t ldb_string_utc_to_time(const char *s); void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); + + +/** + Convert an array of string represention of a control into an array of ldb_control structures + + \param ldb LDB context + \param mem_ctx TALLOC context to return result on, and to allocate error_string on + \param control_strings Array of string-formatted controls + + \return array of ldb_control elements +*/ +struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings); + #endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3c6fb828a2..9e4f7be202 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -224,6 +224,9 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element */ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); + +/* Parse controls from the format used on the command line and in ejs */ + #define LDB_SEQ_GLOBAL_SEQUENCE 0x01 #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 -- cgit From e2aa39b0247508df60e719dd01c19bfecae3bcb6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 27 Feb 2007 02:19:16 +0000 Subject: r21553: Remove bogus comment. (This used to be commit 7c5529729b95f170508b9fe4f04bd33d6f000b1e) --- source4/lib/ldb/include/ldb_private.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 9e4f7be202..3c6fb828a2 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -224,9 +224,6 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element */ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); - -/* Parse controls from the format used on the command line and in ejs */ - #define LDB_SEQ_GLOBAL_SEQUENCE 0x01 #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 -- cgit From dec40d3463383fa525a97f0463010c87f5375a86 Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 2 Apr 2007 17:03:30 +0000 Subject: r22028: Fix include path for the srcidr != builddir case. (This used to be commit a6141d40b15d52d40998c6206d632a27122a0060) --- source4/lib/ldb/include/includes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index ce0d40e101..a04f7a0e97 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -25,7 +25,7 @@ #include "system/filesys.h" #include "system/network.h" #include "system/time.h" -#include "talloc.h" +#include "talloc/talloc.h" #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" -- cgit From bb36705c8d360a2ba865a3d8118c52afa1e46f4e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 15 Apr 2007 21:13:13 +0000 Subject: r22226: move discard_const macros to librelace metze (This used to be commit c2cfee6d25718fac35bd4ed982c7424f1c3ed0b7) --- source4/lib/ldb/include/includes.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index a04f7a0e97..85f99280da 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -16,11 +16,6 @@ #define dyn_MODULESDIR dyn_LIBDIR #endif - - -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) - #include "replace.h" #include "system/filesys.h" #include "system/network.h" -- cgit From f239b809b44fb776cb55ae470cdff2521b485489 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 May 2007 22:05:48 +0000 Subject: r22642: Allow standalone build to work without tdb or talloc checked out, but provided by the system. (This used to be commit bdde74055121ac538f6006750c94b514e962619d) --- source4/lib/ldb/include/includes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h index 85f99280da..e2bcca2b04 100644 --- a/source4/lib/ldb/include/includes.h +++ b/source4/lib/ldb/include/includes.h @@ -20,7 +20,7 @@ #include "system/filesys.h" #include "system/network.h" #include "system/time.h" -#include "talloc/talloc.h" +#include "talloc.h" #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" -- cgit From 52fb06edc25e8538c413df1aaabba18c859a00cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 May 2007 18:50:56 +0000 Subject: r22681: Fix standalone ldb build when parent directory name != ldb. (This used to be commit 1093875d59f1ea9b8bd82277d4f9d8366e584952) --- source4/lib/ldb/include/includes.h | 29 ----------------------------- source4/lib/ldb/include/ldb_includes.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 source4/lib/ldb/include/includes.h create mode 100644 source4/lib/ldb/include/ldb_includes.h (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/includes.h b/source4/lib/ldb/include/includes.h deleted file mode 100644 index e2bcca2b04..0000000000 --- a/source4/lib/ldb/include/includes.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _LDB_PRIVATE_INCLUDES_H_ -#define _LDB_PRIVATE_INCLUDES_H_ -/* - a temporary includes file until I work on the ldb build system -*/ - -#if (_SAMBA_BUILD_ >= 4) -/* tell ldb we have the internal ldap code */ -#define HAVE_ILDAP 1 -#endif - -#if (_SAMBA_BUILD_ <= 3) -/* allow forbidden string functions - should be replaced with _m functions */ -#undef strcasecmp -#undef strncasecmp -#define dyn_MODULESDIR dyn_LIBDIR -#endif - -#include "replace.h" -#include "system/filesys.h" -#include "system/network.h" -#include "system/time.h" -#include "talloc.h" -#include "ldb.h" -#include "ldb_errors.h" -#include "ldb_private.h" -#include "dlinklist.h" - -#endif /*_LDB_PRIVATE_INCLUDES_H_*/ diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h new file mode 100644 index 0000000000..e2bcca2b04 --- /dev/null +++ b/source4/lib/ldb/include/ldb_includes.h @@ -0,0 +1,29 @@ +#ifndef _LDB_PRIVATE_INCLUDES_H_ +#define _LDB_PRIVATE_INCLUDES_H_ +/* + a temporary includes file until I work on the ldb build system +*/ + +#if (_SAMBA_BUILD_ >= 4) +/* tell ldb we have the internal ldap code */ +#define HAVE_ILDAP 1 +#endif + +#if (_SAMBA_BUILD_ <= 3) +/* allow forbidden string functions - should be replaced with _m functions */ +#undef strcasecmp +#undef strncasecmp +#define dyn_MODULESDIR dyn_LIBDIR +#endif + +#include "replace.h" +#include "system/filesys.h" +#include "system/network.h" +#include "system/time.h" +#include "talloc.h" +#include "ldb.h" +#include "ldb_errors.h" +#include "ldb_private.h" +#include "dlinklist.h" + +#endif /*_LDB_PRIVATE_INCLUDES_H_*/ -- cgit From d89e6c774bbf6738183459c52acbd3220482d58a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Jun 2007 12:44:04 +0000 Subject: r23364: add LDB_FLG_NOMMAP flag (This used to be commit 0c3442c68b01b6804f3fd966fc1fe9097eb863aa) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3e09cf1506..10b9b4c8ce 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -232,6 +232,11 @@ struct ldb_utf8_fns { */ #define LDB_FLG_RECONNECT 4 +/** + Flag to tell backends not to use mmap +*/ +#define LDB_FLG_NOMMAP 8 + /* structures for ldb_parse_tree handling code */ -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/ldb/include/dlinklist.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index 3779a4cc61..d3252751db 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* To use these macros you must have a structure containing a next and -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/ldb/include/ldb.h | 2 +- source4/lib/ldb/include/ldb_errors.h | 2 +- source4/lib/ldb/include/ldb_handlers.h | 2 +- source4/lib/ldb/include/ldb_private.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 10b9b4c8ce..295fb3af4c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -12,7 +12,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index 3b04c7c17f..45747948dc 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/ldb/include/ldb_handlers.h b/source4/lib/ldb/include/ldb_handlers.h index e340fe7367..7e9c64837d 100644 --- a/source4/lib/ldb/include/ldb_handlers.h +++ b/source4/lib/ldb/include/ldb_handlers.h @@ -10,7 +10,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 3c6fb828a2..31cf474e04 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -12,7 +12,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/ldb/include/ldb.h | 3 +-- source4/lib/ldb/include/ldb_errors.h | 3 +-- source4/lib/ldb/include/ldb_handlers.h | 3 +-- source4/lib/ldb/include/ldb_private.h | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 295fb3af4c..8f693309c5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -20,8 +20,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* diff --git a/source4/lib/ldb/include/ldb_errors.h b/source4/lib/ldb/include/ldb_errors.h index 45747948dc..9362233fd5 100644 --- a/source4/lib/ldb/include/ldb_errors.h +++ b/source4/lib/ldb/include/ldb_errors.h @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* diff --git a/source4/lib/ldb/include/ldb_handlers.h b/source4/lib/ldb/include/ldb_handlers.h index 7e9c64837d..e1c14e679b 100644 --- a/source4/lib/ldb/include/ldb_handlers.h +++ b/source4/lib/ldb/include/ldb_handlers.h @@ -18,8 +18,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 31cf474e04..cac665b5bb 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -20,8 +20,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* -- cgit From ed2a1c718ae4fb56fdfe73da6f63ddb7fb15d9fd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 11 Sep 2007 15:42:19 +0000 Subject: r25081: Add modules_dir member to ldb_context that is used rather than a global modulesdir setting. Samba always sets this to lp_modulesdir()/ldb (This used to be commit e672380d2156cf0421108a9c34f04f096c2afeed) --- source4/lib/ldb/include/ldb.h | 13 +++++++------ source4/lib/ldb/include/ldb_private.h | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8f693309c5..e4c43b45e7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -779,6 +779,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); +void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); /** Initialise ldbs' global information @@ -876,7 +877,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) \param scope the search scope for the query \param expression the search expression to use for this query @@ -904,7 +905,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param message contains the entry to be added \param controls an array of controls \param context the callback function context @@ -926,7 +927,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param message contains the entry to be modified \param controls an array of controls \param context the callback function context @@ -948,7 +949,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param dn the DN to be deleted \param controls an array of controls \param context the callback function context @@ -970,7 +971,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param olddn the old DN \param newdn the new DN \param controls an array of controls @@ -1137,7 +1138,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param oid the OID of the extended operation. \param data a void pointer a the extended operation specific parameters, it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index cac665b5bb..e07083bef7 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -120,6 +120,8 @@ struct ldb_context { unsigned int flags; unsigned int create_perms; + + char *modules_dir; }; #ifndef ARRAY_SIZE -- cgit From 68a9ab6b012b69a97f2ffa13d2db0f822e51694d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Oct 2007 23:02:07 +0000 Subject: r25540: Remove prototypes for already removed functions. (This used to be commit 042dff55b4cd42b9bedbf574168cc52de3d1dda4) --- source4/lib/ldb/include/ldb.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e4c43b45e7..41d23b5d10 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1044,15 +1044,6 @@ int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, enum ldb_scope scope, const char * const *attrs, const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); -/* - like ldb_search() but takes a parse tree -*/ -int ldb_search_bytree(struct ldb_context *ldb, - struct ldb_dn *base, - enum ldb_scope scope, - struct ldb_parse_tree *tree, - const char * const *attrs, struct ldb_result **res); - /** Add a record to the database. @@ -1419,9 +1410,6 @@ bool ldb_dn_check_special(struct ldb_dn *dn, const char *check); bool ldb_dn_is_null(struct ldb_dn *dn); -/* useful functions for ldb_message structure manipulation */ -int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); - /** Compare two attributes -- cgit From b09047b78e981af8ade6a72d426bfcb0e742995b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 Oct 2007 20:24:37 +0200 Subject: r25624: Remove ipv4_addr hack. Only causes 4 extra includes of system/network.h because we stripped down includes. (This used to be commit 262c1c23a61f1f4fae13e0a61179fe98b682cecf) --- source4/lib/ldb/include/ldb.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 41d23b5d10..301db4dadc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -735,12 +735,14 @@ struct ldb_register_partition { struct ldb_dn *dn; }; +enum ldb_sequence_type { + LDB_SEQ_HIGHEST_SEQ, + LDB_SEQ_HIGHEST_TIMESTAMP, + LDB_SEQ_NEXT +}; + struct ldb_sequence_number { - enum ldb_sequence_type { - LDB_SEQ_HIGHEST_SEQ, - LDB_SEQ_HIGHEST_TIMESTAMP, - LDB_SEQ_NEXT - } type; + enum ldb_sequence_type type; uint64_t seq_num; uint32_t flags; }; -- cgit From e7cf933d4168fc9c9aafb57c532868162c48a70d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 7 Nov 2007 01:32:25 +0100 Subject: r25887: Build Samba-specific ldb modules as dso's. (This used to be commit 9d73becbb24fbde2e319e18e84af35d9efaeefda) --- source4/lib/ldb/include/ldb_private.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e07083bef7..f88c55664d 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -73,6 +73,8 @@ struct ldb_module_ops { typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], struct ldb_module **module); +const char *ldb_default_modules_dir(void); + /* schema related information needed for matching rules */ -- cgit From 6b62805ce7db000420752f56b0544d2aecc51833 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Nov 2007 15:50:08 +0100 Subject: r26066: Use TALLOC_CTX consistently for talloc contexts rather than void \* (it was already being used for some). (This used to be commit d8b175016570d628bb075008149d32a0d538ce95) --- source4/lib/ldb/include/ldb.h | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 301db4dadc..59f5f67fd2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - char *(*casefold)(void *context, void *mem_ctx, const char *s); + char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s); }; /** @@ -280,8 +280,8 @@ struct ldb_parse_tree { } u; }; -struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); -char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); +struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); +char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); /** Encode a binary blob @@ -297,7 +297,7 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); \sa RFC 2252. */ -char *ldb_binary_encode(void *ctx, struct ldb_val val); +char *ldb_binary_encode(TALLOC_CTX *mem_ctx, struct ldb_val val); /** Encode a string @@ -313,13 +313,13 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); \sa RFC 2252. */ -char *ldb_binary_encode_string(void *mem_ctx, const char *string); +char *ldb_binary_encode_string(TALLOC_CTX *mem_ctx, const char *string); /* functions for controlling attribute handling */ -typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); -typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); +typedef int (*ldb_attr_handler_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_comparison_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, const struct ldb_val *); /* attribute handler structure @@ -803,7 +803,7 @@ int ldb_global_init(void); \return pointer to ldb_context that should be free'd (using talloc_free()) at the end of the program. */ -struct ldb_context *ldb_init(void *mem_ctx); +struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx); /** Connect to a database. @@ -893,7 +893,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l int ldb_build_search_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *base, enum ldb_scope scope, const char *expression, @@ -918,7 +918,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, int ldb_build_add_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, @@ -940,7 +940,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, int ldb_build_mod_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, @@ -962,7 +962,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct ldb_control **controls, void *context, @@ -985,7 +985,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *olddn, struct ldb_dn *newdn, struct ldb_control **controls, @@ -1143,7 +1143,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct */ int ldb_build_extended_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const char *oid, void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_control **controls, @@ -1213,7 +1213,7 @@ void ldb_set_utf8_default(struct ldb_context *ldb); \note The default function is not yet UTF8 aware. Provide your own set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); /** Check the attribute name is valid according to rfc2251 @@ -1357,7 +1357,7 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif \note The caller is responsible for freeing the result */ -char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); +char *ldb_base64_encode(TALLOC_CTX *mem_ctx, const char *buf, int len); /** Base64 decode a buffer @@ -1375,15 +1375,15 @@ int ldb_base64_decode(char *s); /* The following definitions come from lib/ldb/common/ldb_dn.c */ -struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); -struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); +struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); bool ldb_dn_validate(struct ldb_dn *dn); -char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); +char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value); const char *ldb_dn_get_linearized(struct ldb_dn *dn); const char *ldb_dn_get_casefold(struct ldb_dn *dn); -char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_alloc_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +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 ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); @@ -1395,10 +1395,10 @@ bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...) PRINTF_ bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num); bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); -struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn); -struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_canonical_string(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_copy(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_get_parent(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); int ldb_dn_get_comp_num(struct ldb_dn *dn); const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num); const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num); @@ -1429,7 +1429,7 @@ bool ldb_dn_is_null(struct ldb_dn *dn); return 0 for match */ #define ldb_attr_cmp(a, b) strcasecmp(a, b) -char *ldb_attr_casefold(void *mem_ctx, const char *s); +char *ldb_attr_casefold(TALLOC_CTX *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); /** @@ -1439,7 +1439,7 @@ int ldb_attr_dn(const char *attr); to get the top level context, however the ldb context (from ldb_init()) may be a better choice */ -struct ldb_message *ldb_msg_new(void *mem_ctx); +struct ldb_message *ldb_msg_new(TALLOC_CTX *mem_ctx); /** Find an element within an message @@ -1533,15 +1533,15 @@ const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *default_value); struct ldb_dn *ldb_msg_find_attr_as_dn(struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *msg, const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); -struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, +struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, const struct ldb_message *msg); -struct ldb_message *ldb_msg_copy(void *mem_ctx, +struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx, const struct ldb_message *msg); struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, @@ -1583,7 +1583,7 @@ int ldb_msg_sanity_check(struct ldb_context *ldb, \return the duplicated ldb_val structure. */ -struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); +struct ldb_val ldb_val_dup(TALLOC_CTX *mem_ctx, const struct ldb_val *v); /** this allows the user to set a debug function for error reporting @@ -1609,8 +1609,8 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); -const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); -const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); +const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy_add(TALLOC_CTX *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); @@ -1634,7 +1634,7 @@ void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); \return the formatted string, or NULL if the time structure could not be converted */ -char *ldb_timestring(void *mem_ctx, time_t t); +char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); /** Convert a string to a time structure @@ -1660,7 +1660,7 @@ time_t ldb_string_to_time(const char *s); \return the formatted string, or NULL if the time structure could not be converted */ -char *ldb_timestring_utc(void *mem_ctx, time_t t); +char *ldb_timestring_utc(TALLOC_CTX *mem_ctx, time_t t); /** Convert a string to a time structure @@ -1687,6 +1687,6 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque \return array of ldb_control elements */ -struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings); +struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings); #endif -- cgit From 6ee987ffa14fb44ddfd2908ecc5931f3ee10e597 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 10:29:32 +0100 Subject: r26371: Fix typo. (This used to be commit dcbacd9adb1ded14cbea3513f3db351e5b7bbe87) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 59f5f67fd2..e2ff8c6f98 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1217,7 +1217,7 @@ char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); /** Check the attribute name is valid according to rfc2251 - \param s tthe string to check + \param s the string to check \return 1 if the name is ok */ -- cgit From cb62bbbb7c2ee542a3a5f978ed25e501825a44d7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 03:35:59 +0100 Subject: r26481: Make function for loading symbol from DSO more generic, and allow modules to provide an ops table directly rather than an initialization function. (This used to be commit a71419a73a869c24121005ccbbcb4396f888888b) --- source4/lib/ldb/include/ldb_private.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index f88c55664d..d9f2defdc9 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -159,7 +159,8 @@ void ldb_reset_err_string(struct ldb_context *ldb); int ldb_register_module(const struct ldb_module_ops *); int ldb_register_backend(const char *url_prefix, ldb_connect_fn); -int ldb_try_load_dso(struct ldb_context *ldb, const char *name); +void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, + const char *symbol); /* The following definitions come from lib/ldb/common/ldb_debug.c */ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -- cgit From 28a06a1b2592bc45f554c2179f4e0596725fd693 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Wed, 26 Dec 2007 00:10:34 +0100 Subject: ldb: Get rid of a warning. (This used to be commit 37ed9fbeee37a1d86d6f6841eac5c1a0a85c1fcc) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e2ff8c6f98..2e54920c17 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -705,7 +705,7 @@ struct ldb_handle { struct ldb_search { struct ldb_dn *base; enum ldb_scope scope; - const struct ldb_parse_tree *tree; + struct ldb_parse_tree *tree; const char * const *attrs; struct ldb_result *res; }; -- cgit From 995788536e5ba7b3a0e67e377a9769b279d0b8ae Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 02:57:07 +0100 Subject: Remove more function-based inits. (This used to be commit b1a7810f3e70f9a831d9b8e85d531e448072adaf) --- source4/lib/ldb/include/ldb_private.h | 37 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d9f2defdc9..d2dcc675a5 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -41,6 +41,8 @@ struct ldb_context; struct ldb_module_ops; +struct ldb_backend_ops; + /* basic module structure */ struct ldb_module { struct ldb_module *prev, *next; @@ -70,9 +72,16 @@ struct ldb_module_ops { int (*sequence_number)(struct ldb_module *, struct ldb_request *); }; + typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], struct ldb_module **module); + +struct ldb_backend_ops { + const char *name; + ldb_connect_fn connect_fn; +}; + const char *ldb_default_modules_dir(void); /* @@ -170,17 +179,23 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, /* The following definitions come from lib/ldb/common/ldb_ldif.c */ int ldb_should_b64_encode(const struct ldb_val *val); -int ldb_objectclass_init(void); -int ldb_operational_init(void); -int ldb_paged_results_init(void); -int ldb_rdn_name_init(void); -int ldb_schema_init(void); -int ldb_asq_init(void); -int ldb_sort_init(void); -int ldb_ldap_init(void); -int ldb_ildap_init(void); -int ldb_tdb_init(void); -int ldb_sqlite3_init(void); +extern const struct ldb_module_ops ldb_objectclass_module_ops; +extern const struct ldb_module_ops ldb_operational_module_ops; +extern const struct ldb_module_ops ldb_paged_results_module_ops; +extern const struct ldb_module_ops ldb_rdn_name_module_ops; +extern const struct ldb_module_ops ldb_schema_module_ops; +extern const struct ldb_module_ops ldb_asq_module_ops; +extern const struct ldb_module_ops ldb_sort_module_ops; +extern const struct ldb_module_ops ldb_ldap_module_ops; +extern const struct ldb_module_ops ldb_ildap_module_ops; +extern const struct ldb_module_ops ldb_tdb_module_ops; +extern const struct ldb_module_ops ldb_sqlite3_module_ops; + +extern const struct ldb_backend_ops ldb_tdb_backend_ops; +extern const struct ldb_backend_ops ldb_sqlite3_backend_ops; +extern const struct ldb_backend_ops ldb_ldap_backend_ops; +extern const struct ldb_backend_ops ldb_ildap_backend_ops; +extern const struct ldb_backend_ops ldb_ldaps_backend_ops; int ldb_match_msg(struct ldb_context *ldb, const struct ldb_message *msg, -- cgit From b5bd6636907c76f6bb562b62abca78a7aeed83d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 25 Feb 2008 20:40:37 +0100 Subject: Fix use of realpath, fix init functions for ldb. (This used to be commit ca510136d2c4cae8f520c76df6aaadb5d412bea1) --- source4/lib/ldb/include/ldb_private.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d2dcc675a5..65bdc713db 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -185,11 +185,13 @@ extern const struct ldb_module_ops ldb_paged_results_module_ops; extern const struct ldb_module_ops ldb_rdn_name_module_ops; extern const struct ldb_module_ops ldb_schema_module_ops; extern const struct ldb_module_ops ldb_asq_module_ops; -extern const struct ldb_module_ops ldb_sort_module_ops; +extern const struct ldb_module_ops ldb_server_sort_module_ops; extern const struct ldb_module_ops ldb_ldap_module_ops; extern const struct ldb_module_ops ldb_ildap_module_ops; extern const struct ldb_module_ops ldb_tdb_module_ops; extern const struct ldb_module_ops ldb_sqlite3_module_ops; +extern const struct ldb_module_ops ldb_wins_ldb_module_ops; +extern const struct ldb_module_ops ldb_ranged_results_module_ops; extern const struct ldb_backend_ops ldb_tdb_backend_ops; extern const struct ldb_backend_ops ldb_sqlite3_backend_ops; -- cgit From 22ef67dd136f0a67885a17be68909643dc97304d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 26 Feb 2008 01:20:55 +0100 Subject: Fix the build (again). (This used to be commit ef00f6b5817107738dc44367838095896af4e77d) --- source4/lib/ldb/include/ldb_private.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 65bdc713db..880aafd593 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -188,7 +188,11 @@ extern const struct ldb_module_ops ldb_asq_module_ops; extern const struct ldb_module_ops ldb_server_sort_module_ops; extern const struct ldb_module_ops ldb_ldap_module_ops; extern const struct ldb_module_ops ldb_ildap_module_ops; +extern const struct ldb_module_ops ldb_paged_searches_module_ops; extern const struct ldb_module_ops ldb_tdb_module_ops; +extern const struct ldb_module_ops ldb_skel_module_ops; +extern const struct ldb_module_ops ldb_subtree_rename_module_ops; +extern const struct ldb_module_ops ldb_subtree_delete_module_ops; extern const struct ldb_module_ops ldb_sqlite3_module_ops; extern const struct ldb_module_ops ldb_wins_ldb_module_ops; extern const struct ldb_module_ops ldb_ranged_results_module_ops; -- cgit From 85d53f7b603f7c15b007f8c3fdde1989f07a6eb2 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Sun, 2 Mar 2008 10:46:47 +0100 Subject: Some cleanups for the ldb doxygen docs. (This used to be commit 5972308add8b1078e190beab204c1ba4b3a25747) --- source4/lib/ldb/include/ldb.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e54920c17..2e13a774b9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -290,7 +290,7 @@ char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); 2254 (Section 4). This function also escapes any non-printable characters. - \param ctx the memory context to allocate the return string in. + \param mem_ctx the memory context to allocate the return string in. \param val the (potentially) binary data to be encoded \return the encoded data as a null terminated string @@ -886,7 +886,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l \param attrs the search attributes for the query (pass NULL if none required) \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -911,7 +911,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, \param message contains the entry to be added \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -933,7 +933,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, \param message contains the entry to be modified \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -955,7 +955,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, \param dn the DN to be deleted \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -978,7 +978,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, \param newdn the new DN \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -997,7 +997,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req, \param req the request struct where to add the control \param oid the object identifier of the control as string - \param ciritical whether the control should be critical or not + \param critical whether the control should be critical or not \param data a talloc pointer to the control specific data \return result code (LDB_SUCCESS on success, or a failure code) @@ -1137,7 +1137,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -1226,6 +1226,7 @@ int ldb_valid_attr_name(const char *s); /* ldif manipulation functions */ + /** Write an LDIF message @@ -1418,8 +1419,8 @@ bool ldb_dn_is_null(struct ldb_dn *dn); This function compares to attribute names. Note that this is a case-insensitive comparison. - \param attr1 the first attribute name to compare - \param attr2 the second attribute name to compare + \param a the first attribute name to compare + \param b the second attribute name to compare \return 0 if the attribute names are the same, or only differ in case; non-zero if there are any differences @@ -1562,6 +1563,7 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg, This function performs basic sanity / integrity checks on an ldb_message. + \param ldb context in which to perform the checks \param msg the message to check \return LDB_SUCCESS if the message is OK, or a non-zero error code -- cgit From 92f6333535a57c034e2ceb3305b420c921a48094 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:29:13 +0100 Subject: ldb: fix the standalone build metze (This used to be commit 91b49365abed6f67e2b3c18b0090b4e6ff1df935) --- source4/lib/ldb/include/ldb_private.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d2dcc675a5..0ffba9d99b 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -185,7 +185,7 @@ extern const struct ldb_module_ops ldb_paged_results_module_ops; extern const struct ldb_module_ops ldb_rdn_name_module_ops; extern const struct ldb_module_ops ldb_schema_module_ops; extern const struct ldb_module_ops ldb_asq_module_ops; -extern const struct ldb_module_ops ldb_sort_module_ops; +extern const struct ldb_module_ops ldb_server_sort_module_ops; extern const struct ldb_module_ops ldb_ldap_module_ops; extern const struct ldb_module_ops ldb_ildap_module_ops; extern const struct ldb_module_ops ldb_tdb_module_ops; @@ -194,7 +194,7 @@ extern const struct ldb_module_ops ldb_sqlite3_module_ops; extern const struct ldb_backend_ops ldb_tdb_backend_ops; extern const struct ldb_backend_ops ldb_sqlite3_backend_ops; extern const struct ldb_backend_ops ldb_ldap_backend_ops; -extern const struct ldb_backend_ops ldb_ildap_backend_ops; +extern const struct ldb_backend_ops ldb_ldapi_backend_ops; extern const struct ldb_backend_ops ldb_ldaps_backend_ops; int ldb_match_msg(struct ldb_context *ldb, -- cgit From 7bf6895b6798bf26c93d80a15c06096aa787352a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Mar 2008 14:29:43 +0100 Subject: ldb: nothing uses "system/network.h" so don't include it metze (This used to be commit 087667e0cd66ea615b5aa43538192fe1d7de87ae) --- source4/lib/ldb/include/ldb_includes.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index e2bcca2b04..cc9b46ac1f 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -18,7 +18,6 @@ #include "replace.h" #include "system/filesys.h" -#include "system/network.h" #include "system/time.h" #include "talloc.h" #include "ldb.h" -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/lib/ldb/include/ldb.h | 4 +++- source4/lib/ldb/include/ldb_includes.h | 1 + source4/lib/ldb/include/ldb_private.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e13a774b9..c43d425585 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -782,6 +782,8 @@ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeou int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); +void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev); +struct event_context * ldb_get_event_context(struct ldb_context *ldb); /** Initialise ldbs' global information @@ -803,7 +805,7 @@ int ldb_global_init(void); \return pointer to ldb_context that should be free'd (using talloc_free()) at the end of the program. */ -struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx); +struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx); /** Connect to a database. diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index cc9b46ac1f..29c7b2dc5a 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -20,6 +20,7 @@ #include "system/filesys.h" #include "system/time.h" #include "talloc.h" +#include "events.h" #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index ea8533bc38..d7c2efe8a1 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -133,6 +133,8 @@ struct ldb_context { unsigned int create_perms; char *modules_dir; + + struct event_context *ev_ctx; }; #ifndef ARRAY_SIZE -- cgit From 1cea7ebe2e193e48f396d280f1253f64a3a4498b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 27 Jun 2008 09:39:30 +0200 Subject: lib/ldb: add forward declaration for struct event_context metze (This used to be commit 9bbdc682a985f210874c008a0abc25645e7fbd50) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c43d425585..0338ae1d93 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -782,6 +782,7 @@ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeou int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); +struct event_context; void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev); struct event_context * ldb_get_event_context(struct ldb_context *ldb); -- cgit From 5d375297718d06f7c5544372001b8955b23d7ba2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 20 Aug 2008 13:09:40 +1000 Subject: Remove last traces of the old 'subclass' feature (This used to be commit ed19d0abea5b206d186a51fa11dc0c04197e6ee2) --- source4/lib/ldb/include/ldb_private.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index d7c2efe8a1..62a6e35999 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -91,13 +91,6 @@ struct ldb_schema { /* attribute handling table */ unsigned num_attributes; struct ldb_schema_attribute *attributes; - - /* objectclass information */ - unsigned num_classes; - struct ldb_subclass { - char *name; - char **subclasses; - } *classes; }; /* -- cgit From 7e1c62f8b64c9e42018bea33557af31fb7fa7414 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Aug 2008 15:46:58 +1000 Subject: added a LDB_ATTR_FLAG_FIXED so the schema module can mark attributes as never to be removed. (This used to be commit 9dce558206a2ce70c69b9b6c5c3c9c58ee165b1d) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0338ae1d93..7ce6103422 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -358,9 +358,9 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte #define LDB_ATTR_FLAG_ALLOCATED (1<<1) /** - The attribute is constructed from other attributes + The attribute is supplied by the application and should not be removed */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) +#define LDB_ATTR_FLAG_FIXED (1<<2) /** LDAP attribute syntax for a DN -- cgit From 4ad97a1d0593b3401a352407009a99ead23f21f2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Aug 2008 19:24:58 +1000 Subject: Don't walk past the end of ldb values. This is a partial fix towards bugs due to us walking past the end of what we think are strings in ldb. There is much more work to do in this area. Andrew Bartlett (This used to be commit 5805a9a8f35fd90fa4f718f73534817fa3bbdfd2) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7ce6103422..5dbf99e5bf 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1381,6 +1381,7 @@ int ldb_base64_decode(char *s); struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn); struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); +struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn); bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value); -- cgit From cc43037f19056ed24d7fffa54456d597c63ad105 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Aug 2008 17:36:56 +1000 Subject: fixed a problem with length limited ldap values The core ldb code for string matching assumed NULL terminated strings, whereas the anr module used data_blob_const() to effectively truncate a ldb_val by changing its length. The ldb code is supposed to be based around length limited blobs, not NULL terminated strings, so the correct fix was to change the string comparison functions to be length limited (This used to be commit 26c6aa5a80ffaf06fc33f30a6533f8f16ef538bc) --- source4/lib/ldb/include/ldb.h | 8 ++++---- source4/lib/ldb/include/ldb_private.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5dbf99e5bf..937029f52c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s); + char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s, size_t n); }; /** @@ -1216,7 +1216,7 @@ void ldb_set_utf8_default(struct ldb_context *ldb); \note The default function is not yet UTF8 aware. Provide your own set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s, size_t n); /** Check the attribute name is valid according to rfc2251 @@ -1603,8 +1603,8 @@ int ldb_set_debug(struct ldb_context *ldb, this allows the user to set custom utf8 function for error reporting */ void ldb_set_utf8_fns(struct ldb_context *ldb, - void *context, - char *(*casefold)(void *, void *, const char *)); + void *context, + char *(*casefold)(void *, void *, const char *, size_t n)); /** this sets up debug to print messages on stderr diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 62a6e35999..e1026ab781 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -235,7 +235,7 @@ int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct l int check_critical_controls(struct ldb_control **controls); /* The following definitions come from lib/ldb/common/ldb_utf8.c */ -char *ldb_casefold_default(void *context, void *mem_ctx, const char *s); +char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n); void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); -- cgit