diff options
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/common/ldb_modules.c | 11 | ||||
-rw-r--r-- | source4/lib/ldb/include/ldb_private.h | 3 | ||||
-rw-r--r-- | source4/lib/ldb/ldb.i | 4 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_wrap.c | 24 | ||||
-rw-r--r-- | source4/lib/ldb/tools/ldbadd.c | 10 | ||||
-rw-r--r-- | source4/lib/ldb/tools/ldbedit.c | 10 | ||||
-rw-r--r-- | source4/lib/ldb/tools/ldbmodify.c | 10 |
8 files changed, 61 insertions, 15 deletions
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 2b453bb0c3..ab0f4c51cc 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -40,6 +40,9 @@ #define LDB_MODULE_PREFIX "modules:" #define LDB_MODULE_PREFIX_LEN 8 +static void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, + const char *symbol); + void ldb_set_modules_dir(struct ldb_context *ldb, const char *path) { talloc_free(ldb->modules_dir); @@ -291,8 +294,8 @@ int ldb_register_module(const struct ldb_module_ops *ops) return 0; } -void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, - const char *symbol) +static void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, + const char *symbol) { char *path; void *handle; @@ -334,6 +337,10 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str for (i = 0; module_list[i] != NULL; i++) { struct ldb_module *current; const struct ldb_module_ops *ops; + + if (strcmp(module_list[i], "") == 0) { + continue; + } ops = ldb_find_module_ops(module_list[i]); if (ops == NULL) { diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 8f7e010bee..90c4980017 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -259,9 +259,6 @@ const char *ldb_default_modules_dir(void); int ldb_register_backend(const char *url_prefix, ldb_connect_fn); -void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, - const char *symbol); - struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); int ldb_module_send_entry(struct ldb_request *req, diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 6ecbfbfa08..0f05c1fbab 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -190,6 +190,7 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx, } %apply const char * const *NULL_STR_LIST { const char * const *attrs } +%apply const char * const *NULL_STR_LIST { const char * const *options } %apply const char * const *NULL_STR_LIST { const char * const *control_strings } #endif @@ -711,9 +712,10 @@ typedef struct ldb_context { %feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \ "Connect to a LDB URL."; ldb_error connect(const char *url, unsigned int flags = 0, - const char *options[] = NULL); + const char *const *options = NULL); ~ldb() { talloc_free($self); } + ldb_error search_ex(TALLOC_CTX *mem_ctx, ldb_dn *base = NULL, enum ldb_scope scope = LDB_SCOPE_DEFAULT, diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 65711d9f4b..eedbda4170 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -1250,5 +1250,9 @@ int ltdb_reindex(struct ldb_module *module) return LDB_ERR_OPERATIONS_ERROR; } + if (tdb_repack(ltdb->tdb) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + return LDB_SUCCESS; } diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index 3cf5ec613a..4a34c1c998 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -4822,7 +4822,7 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject ldb *arg1 = (ldb *) 0 ; char *arg2 = (char *) 0 ; unsigned int arg3 = (unsigned int) 0 ; - char **arg4 = (char **) (char **)NULL ; + char **arg4 = (char **) NULL ; void *argp1 = 0 ; int res1 = 0 ; int res2 ; @@ -4830,8 +4830,6 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject int alloc2 = 0 ; unsigned int val3 ; int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; @@ -4860,25 +4858,33 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject arg3 = (unsigned int)(val3); } if (obj3) { - res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_char, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Ldb_connect" "', argument " "4"" of type '" "char const *[]""'"); - } - arg4 = (char **)(argp4); + if (obj3 == Py_None) { + arg4 = NULL; + } else if (PySequence_Check(obj3)) { + int i; + arg4 = talloc_array(NULL, char *, PySequence_Size(obj3)+1); + for(i = 0; i < PySequence_Size(obj3); i++) + arg4[i] = PyString_AsString(PySequence_GetItem(obj3, i)); + arg4[i] = NULL; + } else { + SWIG_exception(SWIG_TypeError, "expected sequence"); + } } if (arg1 == NULL) SWIG_exception(SWIG_ValueError, "ldb context must be non-NULL"); - result = ldb_connect(arg1,(char const *)arg2,arg3,(char const *(*))arg4); + result = ldb_connect(arg1,(char const *)arg2,arg3,(char const *const *)arg4); if (result != 0) { PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); SWIG_fail; } resultobj = Py_None; if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + talloc_free(arg4); return resultobj; fail: if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + talloc_free(arg4); return NULL; } diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 15376e7342..3749aec629 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -92,6 +92,11 @@ int main(int argc, const char **argv) options = ldb_cmdline_process(ldb, argc, argv, usage); + if (ldb_transaction_start(ldb) != 0) { + printf("Failed to start transaction\n"); + exit(1); + } + if (options->argc == 0) { ret = process_file(ldb, stdin, &count); } else { @@ -108,6 +113,11 @@ int main(int argc, const char **argv) } } + if (count != 0 && ldb_transaction_commit(ldb) != 0) { + printf("Failed to commit transaction\n"); + exit(1); + } + talloc_free(ldb); printf("Added %d records with %d failures\n", count, failures); diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index b2a040cd09..b18aea1b10 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -112,6 +112,11 @@ static int merge_edits(struct ldb_context *ldb, int ret = 0; int adds=0, modifies=0, deletes=0; + if (ldb_transaction_start(ldb) != 0) { + fprintf(stderr, "Failed to start transaction\n"); + return -1; + } + /* do the adds and modifies */ for (i=0;i<count2;i++) { msg = msg_find(ldb, msgs1, count1, msgs2[i]->dn); @@ -150,6 +155,11 @@ static int merge_edits(struct ldb_context *ldb, } } + if (ldb_transaction_commit(ldb) != 0) { + fprintf(stderr, "Failed to commit transaction\n"); + return -1; + } + printf("# %d adds %d modifies %d deletes\n", adds, modifies, deletes); return ret; diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index 6e355a10cf..8b6309e016 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -91,6 +91,11 @@ int main(int argc, const char **argv) ldb = ldb_init(NULL, NULL); + if (ldb_transaction_start(ldb) != 0) { + printf("Failed to start transaction\n"); + exit(1); + } + options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc == 0) { @@ -108,6 +113,11 @@ int main(int argc, const char **argv) } } + if (count != 0 && ldb_transaction_commit(ldb) != 0) { + printf("Failed to commit transaction\n"); + exit(1); + } + talloc_free(ldb); printf("Modified %d records with %d failures\n", count, failures); |