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 (*lock_read)(struct ldb_module *);
12 int (*unlock_read)(struct ldb_module *);
13 int (*begin_write)(struct ltdb_private *);
14 int (*prepare_write)(struct ltdb_private *);
15 int (*abort_write)(struct ltdb_private *);
16 int (*finish_write)(struct ltdb_private *);
17 int (*error)(struct ltdb_private *ltdb);
18 const char * (*name)(struct ltdb_private *ltdb);
21 /* this private structure is used by the ltdb backend in the
24 const struct kv_db_ops *kv_ops;
26 unsigned int connect_flags;
28 unsigned long long sequence_number;
30 /* the low level tdb seqnum - used to avoid loading BASEINFO when
35 struct ldb_message *indexlist;
36 bool one_level_indexes;
37 bool attribute_indexes;
38 const char *GUID_index_attribute;
39 const char *GUID_index_dn_component;
45 bool disallow_dn_filter;
46 struct ltdb_idxptr *idxptr;
55 const struct ldb_schema_syntax *GUID_index_syntax;
58 * Maximum index key length. If non zero keys longer than this length
59 * will be truncated for non unique indexes. Keys for unique indexes
60 * greater than this length will be rejected.
62 unsigned max_key_length;
66 struct ldb_module *module;
67 struct ldb_request *req;
69 bool request_terminated;
70 struct ltdb_req_spy *spy;
73 const struct ldb_parse_tree *tree;
76 const char * const *attrs;
77 struct tevent_timer *timeout_event;
83 /* special record types */
84 #define LTDB_INDEX "@INDEX"
85 #define LTDB_INDEXLIST "@INDEXLIST"
86 #define LTDB_IDX "@IDX"
87 #define LTDB_IDXVERSION "@IDXVERSION"
88 #define LTDB_IDXATTR "@IDXATTR"
89 #define LTDB_IDXONE "@IDXONE"
90 #define LTDB_IDXDN "@IDXDN"
91 #define LTDB_IDXGUID "@IDXGUID"
92 #define LTDB_IDX_DN_GUID "@IDX_DN_GUID"
93 #define LTDB_BASEINFO "@BASEINFO"
94 #define LTDB_OPTIONS "@OPTIONS"
95 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
97 /* special attribute types */
98 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
99 #define LTDB_CHECK_BASE "checkBaseOnSearch"
100 #define LTDB_DISALLOW_DN_FILTER "disallowDNFilter"
101 #define LTDB_MOD_TIMESTAMP "whenChanged"
102 #define LTDB_OBJECTCLASS "objectClass"
105 #define LTDB_GUID_KEY_PREFIX "GUID="
106 #define LTDB_GUID_SIZE 16
107 #define LTDB_GUID_KEY_SIZE (LTDB_GUID_SIZE + sizeof(LTDB_GUID_KEY_PREFIX) - 1)
109 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
111 int ltdb_cache_reload(struct ldb_module *module);
112 int ltdb_cache_load(struct ldb_module *module);
113 int ltdb_increase_sequence_number(struct ldb_module *module);
114 int ltdb_check_at_attributes_values(const struct ldb_val *value);
116 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
118 struct ldb_parse_tree;
120 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
121 int ltdb_index_add_new(struct ldb_module *module,
122 struct ltdb_private *ltdb,
123 const struct ldb_message *msg);
124 int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
125 int ltdb_index_del_element(struct ldb_module *module,
126 struct ltdb_private *ltdb,
127 const struct ldb_message *msg,
128 struct ldb_message_element *el);
129 int ltdb_index_add_element(struct ldb_module *module,
130 struct ltdb_private *ltdb,
131 const struct ldb_message *msg,
132 struct ldb_message_element *el);
133 int ltdb_index_del_value(struct ldb_module *module,
134 struct ltdb_private *ltdb,
135 const struct ldb_message *msg,
136 struct ldb_message_element *el, unsigned int v_idx);
137 int ltdb_reindex(struct ldb_module *module);
138 int ltdb_index_transaction_start(struct ldb_module *module);
139 int ltdb_index_transaction_commit(struct ldb_module *module);
140 int ltdb_index_transaction_cancel(struct ldb_module *module);
141 int ltdb_key_dn_from_idx(struct ldb_module *module,
142 struct ltdb_private *ltdb,
147 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
149 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
150 const struct ldb_val *val);
151 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
152 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
153 unsigned int unpack_flags);
154 int ltdb_search_base(struct ldb_module *module,
157 struct ldb_dn **ret_dn);
158 int ltdb_search_key(struct ldb_module *module, struct ltdb_private *ltdb,
159 struct TDB_DATA tdb_key,
160 struct ldb_message *msg,
161 unsigned int unpack_flags);
162 int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
163 const struct ldb_message *msg, const char * const *attrs,
164 struct ldb_message **filtered_msg);
165 int ltdb_search(struct ltdb_context *ctx);
167 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
169 * Determine if this key could hold a record. We allow the new GUID
170 * index, the old DN index and a possible future ID=
172 bool ltdb_key_is_record(TDB_DATA key);
173 TDB_DATA ltdb_key_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx,
175 TDB_DATA ltdb_key_msg(struct ldb_module *module, TALLOC_CTX *mem_ctx,
176 const struct ldb_message *msg);
177 int ltdb_guid_to_key(struct ldb_module *module,
178 struct ltdb_private *ltdb,
179 const struct ldb_val *GUID_val,
181 int ltdb_idx_to_key(struct ldb_module *module,
182 struct ltdb_private *ltdb,
184 const struct ldb_val *idx_val,
186 TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
187 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
188 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
189 int ltdb_delete_noindex(struct ldb_module *module,
190 const struct ldb_message *msg);
191 int ltdb_err_map(enum TDB_ERROR tdb_code);
193 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
194 const char *path, int hash_size, int tdb_flags,
195 int open_flags, mode_t mode,
196 struct ldb_context *ldb);