2010-11-01 23:36:42 +11:00
# include "replace.h"
# include "system/filesys.h"
# include "system/time.h"
2012-06-19 12:43:10 +09:30
# include "tdb.h"
2009-01-29 18:39:30 -05:00
# include "ldb_module.h"
2004-03-31 06:45:39 +00:00
/* this private structure is used by the ltdb backend in the
ldb_context */
struct ltdb_private {
TDB_CONTEXT * tdb ;
unsigned int connect_flags ;
2004-05-01 09:45:56 +00:00
2006-09-21 06:44:12 +00:00
unsigned long long sequence_number ;
2004-05-01 09:45:56 +00:00
2006-10-18 21:45:46 +00:00
/* the low level tdb seqnum - used to avoid loading BASEINFO when
possible */
int tdb_seqnum ;
2005-01-02 07:49:29 +00:00
struct ltdb_cache {
struct ldb_message * indexlist ;
2009-10-21 22:21:26 +11:00
bool one_level_indexes ;
bool attribute_indexes ;
2005-01-02 07:49:29 +00:00
} * cache ;
2007-10-18 02:03:21 +02:00
int in_transaction ;
2007-11-15 01:53:44 +01:00
bool check_base ;
2011-10-26 09:47:35 +02:00
bool disallow_dn_filter ;
2008-12-16 18:45:28 +11:00
struct ltdb_idxptr * idxptr ;
2009-03-31 15:07:54 +11:00
bool prepared_commit ;
2009-12-09 14:37:26 +11:00
int read_lock_count ;
2010-11-23 20:19:49 +11:00
bool warn_unindexed ;
2013-01-01 20:57:25 -08:00
bool warn_reindex ;
2017-09-18 10:43:32 +12:00
bool read_only ;
2004-03-31 06:45:39 +00:00
} ;
2006-07-22 16:56:33 +00:00
struct ltdb_context {
2006-03-03 17:44:03 +00:00
struct ldb_module * module ;
2008-09-11 18:34:11 -04:00
struct ldb_request * req ;
2009-03-09 18:04:38 -04:00
bool request_terminated ;
struct ltdb_req_spy * spy ;
2006-03-03 17:44:03 +00:00
/* search stuff */
2006-08-22 18:09:49 +00:00
const struct ldb_parse_tree * tree ;
2006-11-22 00:59:34 +00:00
struct ldb_dn * base ;
2006-03-03 17:44:03 +00:00
enum ldb_scope scope ;
const char * const * attrs ;
2008-12-29 20:24:57 +01:00
struct tevent_timer * timeout_event ;
2015-12-03 16:30:59 +13:00
/* error handling */
int error ;
2006-03-03 17:44:03 +00:00
} ;
2004-05-01 09:45:56 +00:00
/* special record types */
# define LTDB_INDEX "@INDEX"
# define LTDB_INDEXLIST "@INDEXLIST"
# define LTDB_IDX "@IDX"
2009-10-21 22:21:26 +11:00
# define LTDB_IDXVERSION "@IDXVERSION"
2004-05-01 09:45:56 +00:00
# define LTDB_IDXATTR "@IDXATTR"
2006-12-11 15:49:39 +00:00
# define LTDB_IDXONE "@IDXONE"
2004-05-01 09:45:56 +00:00
# define LTDB_BASEINFO "@BASEINFO"
2007-11-15 01:53:44 +01:00
# define LTDB_OPTIONS "@OPTIONS"
2004-05-01 09:45:56 +00:00
# define LTDB_ATTRIBUTES "@ATTRIBUTES"
/* special attribute types */
# define LTDB_SEQUENCE_NUMBER "sequenceNumber"
2007-11-15 01:53:44 +01:00
# define LTDB_CHECK_BASE "checkBaseOnSearch"
2011-10-26 09:47:35 +02:00
# define LTDB_DISALLOW_DN_FILTER "disallowDNFilter"
2006-09-21 06:44:12 +00:00
# define LTDB_MOD_TIMESTAMP "whenChanged"
2004-05-01 09:45:56 +00:00
# define LTDB_OBJECTCLASS "objectClass"
2004-11-16 09:00:52 +00:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
2005-01-02 07:49:29 +00:00
int ltdb_cache_reload ( struct ldb_module * module ) ;
2004-11-16 09:00:52 +00:00
int ltdb_cache_load ( struct ldb_module * module ) ;
int ltdb_increase_sequence_number ( struct ldb_module * module ) ;
2005-05-17 21:43:47 +00:00
int ltdb_check_at_attributes_values ( const struct ldb_val * value ) ;
2004-11-16 09:00:52 +00:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
struct ldb_parse_tree ;
2009-09-15 10:00:24 -07:00
int ltdb_search_indexed ( struct ltdb_context * ctx , uint32_t * ) ;
2017-08-10 16:23:33 +12:00
int ltdb_index_add_new ( struct ldb_module * module ,
struct ltdb_private * ltdb ,
const struct ldb_message * msg ) ;
2009-10-21 22:21:26 +11:00
int ltdb_index_delete ( struct ldb_module * module , const struct ldb_message * msg ) ;
2017-08-10 16:23:33 +12:00
int ltdb_index_del_element ( struct ldb_module * module ,
struct ltdb_private * ltdb ,
struct ldb_dn * dn ,
2009-11-18 10:44:56 +01:00
struct ldb_message_element * el ) ;
2017-08-10 16:23:33 +12:00
int ltdb_index_add_element ( struct ldb_module * module ,
struct ltdb_private * ltdb ,
struct ldb_dn * dn ,
2009-10-21 22:21:26 +11:00
struct ldb_message_element * el ) ;
2017-08-10 16:23:33 +12:00
int ltdb_index_del_value ( struct ldb_module * module ,
struct ltdb_private * ltdb ,
struct ldb_dn * dn ,
2009-11-06 18:35:17 +01:00
struct ldb_message_element * el , unsigned int v_idx ) ;
2004-11-16 09:00:52 +00:00
int ltdb_reindex ( struct ldb_module * module ) ;
2008-12-16 18:45:28 +11:00
int ltdb_index_transaction_start ( struct ldb_module * module ) ;
int ltdb_index_transaction_commit ( struct ldb_module * module ) ;
int ltdb_index_transaction_cancel ( struct ldb_module * module ) ;
2004-11-16 09:00:52 +00:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
int ltdb_has_wildcard ( struct ldb_module * module , const char * attr_name ,
const struct ldb_val * val ) ;
void ltdb_search_dn1_free ( struct ldb_module * module , struct ldb_message * msg ) ;
2016-07-27 00:20:27 +12:00
int ltdb_search_dn1 ( struct ldb_module * module , struct ldb_dn * dn , struct ldb_message * msg ,
unsigned int unpack_flags ) ;
2017-08-10 16:06:08 +12:00
int ltdb_search_key ( struct ldb_module * module , struct ltdb_private * ltdb ,
struct TDB_DATA tdb_key ,
struct ldb_message * msg ,
unsigned int unpack_flags ) ;
2016-08-26 09:58:38 +12:00
int ltdb_filter_attrs ( TALLOC_CTX * mem_ctx ,
const struct ldb_message * msg , const char * const * attrs ,
struct ldb_message * * filtered_msg ) ;
2008-09-11 18:34:11 -04:00
int ltdb_search ( struct ltdb_context * ctx ) ;
2004-11-16 09:00:52 +00:00
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
2008-10-15 14:03:20 -04:00
int ltdb_lock_read ( struct ldb_module * module ) ;
int ltdb_unlock_read ( struct ldb_module * module ) ;
2017-09-01 14:35:08 +12:00
/*
* Determine if this key could hold a record . We allow the new GUID
* index , the old DN index and a possible future ID =
*/
bool ltdb_key_is_record ( TDB_DATA key ) ;
2017-08-10 14:31:18 +12:00
TDB_DATA ltdb_key_dn ( struct ldb_module * module , struct ldb_dn * dn ) ;
TDB_DATA ltdb_key_msg ( struct ldb_module * module , const struct ldb_message * msg ) ;
2004-11-16 09:00:52 +00:00
int ltdb_store ( struct ldb_module * module , const struct ldb_message * msg , int flgs ) ;
2009-12-19 20:55:11 +11:00
int ltdb_modify_internal ( struct ldb_module * module , const struct ldb_message * msg , struct ldb_request * req ) ;
2009-10-22 11:06:33 +11:00
int ltdb_delete_noindex ( struct ldb_module * module , struct ldb_dn * dn ) ;
int ltdb_err_map ( enum TDB_ERROR tdb_code ) ;
2004-11-16 09:00:52 +00:00
2005-07-20 00:59:38 +00:00
struct tdb_context * ltdb_wrap_open ( TALLOC_CTX * mem_ctx ,
const char * path , int hash_size , int tdb_flags ,
2006-07-03 06:40:56 +00:00
int open_flags , mode_t mode ,
struct ldb_context * ldb ) ;