2 #include "system/filesys.h"
3 #include "system/time.h"
5 #include "ldb_module.h"
9 int (*store)(struct ltdb_private *ltdb, TDB_DATA key, TDB_DATA data, int flags);
10 int (*delete)(struct ltdb_private *ltdb, TDB_DATA key);
11 int (*fetch_and_parse)(struct ltdb_private *ltdb, TDB_DATA key,
12 int (*parser)(TDB_DATA key, TDB_DATA data,
15 int (*lock_read)(struct ldb_module *);
16 int (*unlock_read)(struct ldb_module *);
17 int (*begin_write)(struct ltdb_private *);
18 int (*prepare_write)(struct ltdb_private *);
19 int (*abort_write)(struct ltdb_private *);
20 int (*finish_write)(struct ltdb_private *);
21 int (*error)(struct ltdb_private *ltdb);
22 const char * (*errorstr)(struct ltdb_private *ltdb);
23 const char * (*name)(struct ltdb_private *ltdb);
24 bool (*has_changed)(struct ltdb_private *ltdb);
27 /* this private structure is used by the ltdb backend in the
30 const struct kv_db_ops *kv_ops;
32 unsigned int connect_flags;
34 unsigned long long sequence_number;
36 /* the low level tdb seqnum - used to avoid loading BASEINFO when
41 struct ldb_message *indexlist;
42 bool one_level_indexes;
43 bool attribute_indexes;
44 const char *GUID_index_attribute;
45 const char *GUID_index_dn_component;
51 bool disallow_dn_filter;
52 struct ltdb_idxptr *idxptr;
61 const struct ldb_schema_syntax *GUID_index_syntax;
64 * Maximum index key length. If non zero keys longer than this length
65 * will be truncated for non unique indexes. Keys for unique indexes
66 * greater than this length will be rejected.
68 unsigned max_key_length;
72 struct ldb_module *module;
73 struct ldb_request *req;
75 bool request_terminated;
76 struct ltdb_req_spy *spy;
79 const struct ldb_parse_tree *tree;
82 const char * const *attrs;
83 struct tevent_timer *timeout_event;
89 /* special record types */
90 #define LTDB_INDEX "@INDEX"
91 #define LTDB_INDEXLIST "@INDEXLIST"
92 #define LTDB_IDX "@IDX"
93 #define LTDB_IDXVERSION "@IDXVERSION"
94 #define LTDB_IDXATTR "@IDXATTR"
95 #define LTDB_IDXONE "@IDXONE"
96 #define LTDB_IDXDN "@IDXDN"
97 #define LTDB_IDXGUID "@IDXGUID"
98 #define LTDB_IDX_DN_GUID "@IDX_DN_GUID"
99 #define LTDB_BASEINFO "@BASEINFO"
100 #define LTDB_OPTIONS "@OPTIONS"
101 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
103 /* special attribute types */
104 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
105 #define LTDB_CHECK_BASE "checkBaseOnSearch"
106 #define LTDB_DISALLOW_DN_FILTER "disallowDNFilter"
107 #define LTDB_MOD_TIMESTAMP "whenChanged"
108 #define LTDB_OBJECTCLASS "objectClass"
111 #define LTDB_GUID_KEY_PREFIX "GUID="
112 #define LTDB_GUID_SIZE 16
113 #define LTDB_GUID_KEY_SIZE (LTDB_GUID_SIZE + sizeof(LTDB_GUID_KEY_PREFIX) - 1)
115 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
117 int ltdb_cache_reload(struct ldb_module *module);
118 int ltdb_cache_load(struct ldb_module *module);
119 int ltdb_increase_sequence_number(struct ldb_module *module);
120 int ltdb_check_at_attributes_values(const struct ldb_val *value);
122 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
124 struct ldb_parse_tree;
126 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
127 int ltdb_index_add_new(struct ldb_module *module,
128 struct ltdb_private *ltdb,
129 const struct ldb_message *msg);
130 int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
131 int ltdb_index_del_element(struct ldb_module *module,
132 struct ltdb_private *ltdb,
133 const struct ldb_message *msg,
134 struct ldb_message_element *el);
135 int ltdb_index_add_element(struct ldb_module *module,
136 struct ltdb_private *ltdb,
137 const struct ldb_message *msg,
138 struct ldb_message_element *el);
139 int ltdb_index_del_value(struct ldb_module *module,
140 struct ltdb_private *ltdb,
141 const struct ldb_message *msg,
142 struct ldb_message_element *el, unsigned int v_idx);
143 int ltdb_reindex(struct ldb_module *module);
144 int ltdb_index_transaction_start(struct ldb_module *module);
145 int ltdb_index_transaction_commit(struct ldb_module *module);
146 int ltdb_index_transaction_cancel(struct ldb_module *module);
147 int ltdb_key_dn_from_idx(struct ldb_module *module,
148 struct ltdb_private *ltdb,
153 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
155 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
156 const struct ldb_val *val);
157 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
158 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
159 unsigned int unpack_flags);
160 int ltdb_search_base(struct ldb_module *module,
163 struct ldb_dn **ret_dn);
164 int ltdb_search_key(struct ldb_module *module, struct ltdb_private *ltdb,
165 struct TDB_DATA tdb_key,
166 struct ldb_message *msg,
167 unsigned int unpack_flags);
168 int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
169 const struct ldb_message *msg, const char * const *attrs,
170 struct ldb_message **filtered_msg);
171 int ltdb_search(struct ltdb_context *ctx);
173 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
175 * Determine if this key could hold a record. We allow the new GUID
176 * index, the old DN index and a possible future ID=
178 bool ltdb_key_is_record(TDB_DATA key);
179 TDB_DATA ltdb_key_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx,
181 TDB_DATA ltdb_key_msg(struct ldb_module *module, TALLOC_CTX *mem_ctx,
182 const struct ldb_message *msg);
183 int ltdb_guid_to_key(struct ldb_module *module,
184 struct ltdb_private *ltdb,
185 const struct ldb_val *GUID_val,
187 int ltdb_idx_to_key(struct ldb_module *module,
188 struct ltdb_private *ltdb,
190 const struct ldb_val *idx_val,
192 TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
193 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
194 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
195 int ltdb_delete_noindex(struct ldb_module *module,
196 const struct ldb_message *msg);
197 int ltdb_err_map(enum TDB_ERROR tdb_code);
199 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
200 const char *path, int hash_size, int tdb_flags,
201 int open_flags, mode_t mode,
202 struct ldb_context *ldb);
203 int init_store(struct ltdb_private *ltdb, const char *name,
204 struct ldb_context *ldb, const char *options[],
205 struct ldb_module **_module);