diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/cmdline/popt_common.c | 12 | ||||
-rw-r--r-- | source4/lib/cmdline/popt_credentials.c | 2 | ||||
-rw-r--r-- | source4/lib/ldb/common/attrib_handlers.c | 6 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_ldif.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_match.c | 2 | ||||
-rw-r--r-- | source4/lib/ldb/ldb.i | 1 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_map/ldb_map.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_wrap.c | 1 | ||||
-rw-r--r-- | source4/lib/messaging/pymessaging.c | 9 | ||||
-rw-r--r-- | source4/lib/registry/rpc.c | 2 | ||||
-rw-r--r-- | source4/lib/socket/socket.c | 2 | ||||
-rw-r--r-- | source4/lib/socket/socket.h | 2 | ||||
-rw-r--r-- | source4/lib/torture/subunit.c | 2 | ||||
-rw-r--r-- | source4/lib/torture/torture.c | 78 | ||||
-rw-r--r-- | source4/lib/torture/torture.h | 51 | ||||
-rw-r--r-- | source4/lib/wmi/wmicore.c | 5 |
16 files changed, 120 insertions, 63 deletions
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c index 96d8b8b40a..712d99996c 100644 --- a/source4/lib/cmdline/popt_common.c +++ b/source4/lib/cmdline/popt_common.c @@ -23,7 +23,6 @@ #include "version.h" #include "lib/cmdline/popt_common.h" #include "param/param.h" -#include "dynconfig/dynconfig.h" /* Handle command line options: * -d,--debuglevel @@ -63,10 +62,7 @@ static void popt_samba_callback(poptContext con, if (reason == POPT_CALLBACK_REASON_POST) { if (lp_configfile(cmdline_lp_ctx) == NULL) { - if (getenv("SMB_CONF_PATH")) - lp_load(cmdline_lp_ctx, getenv("SMB_CONF_PATH")); - else - lp_load(cmdline_lp_ctx, dyn_CONFIGFILE); + lp_load_default(cmdline_lp_ctx); } /* Hook any 'every Samba program must do this, after * the smb.conf is setup' functions here */ @@ -82,11 +78,7 @@ static void popt_samba_callback(poptContext con, pname++; if (reason == POPT_CALLBACK_REASON_PRE) { - if (global_loadparm != NULL) { - cmdline_lp_ctx = global_loadparm; - } else { - cmdline_lp_ctx = global_loadparm = loadparm_init(talloc_autofree_context()); - } + cmdline_lp_ctx = loadparm_init(talloc_autofree_context()); /* Hook for 'almost the first thing to do in a samba program' here */ /* setup for panics */ diff --git a/source4/lib/cmdline/popt_credentials.c b/source4/lib/cmdline/popt_credentials.c index de5ea7c1b6..42ecac1eaa 100644 --- a/source4/lib/cmdline/popt_credentials.c +++ b/source4/lib/cmdline/popt_credentials.c @@ -60,7 +60,7 @@ static void popt_common_credentials_callback(poptContext con, } if (reason == POPT_CALLBACK_REASON_POST) { - cli_credentials_guess(cmdline_credentials, global_loadparm); + cli_credentials_guess(cmdline_credentials, cmdline_lp_ctx); if (!dont_ask) { cli_credentials_set_cmdline_callbacks(cmdline_credentials); diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c index fb57e2dadc..5ec86b5b8f 100644 --- a/source4/lib/ldb/common/attrib_handlers.c +++ b/source4/lib/ldb/common/attrib_handlers.c @@ -240,7 +240,7 @@ int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx, out->length = 0; out->data = NULL; - dn = ldb_dn_new(ldb, mem_ctx, (char *)in->data); + dn = ldb_dn_from_ldb_val(ldb, mem_ctx, in); if ( ! ldb_dn_validate(dn)) { return LDB_ERR_INVALID_DN_SYNTAX; } @@ -268,10 +268,10 @@ int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx, struct ldb_dn *dn1 = NULL, *dn2 = NULL; int ret; - dn1 = ldb_dn_new(ldb, mem_ctx, (char *)v1->data); + dn1 = ldb_dn_from_ldb_val(ldb, mem_ctx, v1); if ( ! ldb_dn_validate(dn1)) return -1; - dn2 = ldb_dn_new(ldb, mem_ctx, (char *)v2->data); + dn2 = ldb_dn_from_ldb_val(ldb, mem_ctx, v2); if ( ! ldb_dn_validate(dn2)) { talloc_free(dn1); return -1; diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index fb93e17c6c..538ff8feaa 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -562,11 +562,11 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, goto failed; } - msg->dn = ldb_dn_new(msg, ldb, (char *)value.data); + msg->dn = ldb_dn_from_ldb_val(msg, ldb, &value); if ( ! ldb_dn_validate(msg->dn)) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Error: Unable to parse dn '%s'\n", - value.data); + (char *)value.data); goto failed; } diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c index 64d0e54761..4cde739d67 100644 --- a/source4/lib/ldb/common/ldb_match.c +++ b/source4/lib/ldb/common/ldb_match.c @@ -147,7 +147,7 @@ static int ldb_match_equality(struct ldb_context *ldb, int ret; if (ldb_attr_dn(tree->u.equality.attr) == 0) { - valuedn = ldb_dn_new(ldb, ldb, (char *)tree->u.equality.value.data); + valuedn = ldb_dn_from_ldb_val(ldb, ldb, &tree->u.equality.value); if (valuedn == NULL) { return 0; } diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 6013462225..6187096ab9 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -262,7 +262,6 @@ fail: { char *dn = ldb_dn_get_linearized($self), *ret; asprintf(&ret, "Dn('%s')", dn); - talloc_free(dn); return ret; } diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c index fafbb63b0a..72d8378a07 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.c +++ b/source4/lib/ldb/ldb_map/ldb_map.c @@ -626,7 +626,7 @@ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_new(mem_ctx, module->ldb, (char *)val->data); + dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; @@ -652,7 +652,7 @@ static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_new(mem_ctx, module->ldb, (char *)val->data); + dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index bc9266a306..3cf5ec613a 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -2732,7 +2732,6 @@ SWIGINTERN char const *ldb_dn_canonical_ex_str(ldb_dn *self){ SWIGINTERN char *ldb_dn___repr__(ldb_dn *self){ char *dn = ldb_dn_get_linearized(self), *ret; asprintf(&ret, "Dn('%s')", dn); - talloc_free(dn); return ret; } SWIGINTERN ldb_dn *ldb_dn___add__(ldb_dn *self,ldb_dn *other){ diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index c2c23b679e..ad8f955466 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -34,6 +34,9 @@ PyAPI_DATA(PyTypeObject) messaging_Type; PyAPI_DATA(PyTypeObject) irpc_ClientConnectionType; +/* FIXME: This prototype should be in param/pyparam.h */ +struct loadparm_context *py_default_loadparm_context(TALLOC_CTX *mem_ctx); + static bool server_id_from_py(PyObject *object, struct server_id *server_id) { if (!PyTuple_Check(object)) { @@ -80,7 +83,8 @@ PyObject *py_messaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwa ev = s4_event_context_init(ret->mem_ctx); if (messaging_path == NULL) { - messaging_path = lp_messaging_path(ret->mem_ctx, global_loadparm); + messaging_path = lp_messaging_path(ret->mem_ctx, + py_default_loadparm_context(ret->mem_ctx)); } else { messaging_path = talloc_strdup(ret->mem_ctx, messaging_path); } @@ -334,7 +338,8 @@ PyObject *py_irpc_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs) ev = s4_event_context_init(ret->mem_ctx); if (messaging_path == NULL) { - messaging_path = lp_messaging_path(ret->mem_ctx, global_loadparm); + messaging_path = lp_messaging_path(ret->mem_ctx, + py_default_loadparm_context(ret->mem_ctx)); } else { messaging_path = talloc_strdup(ret->mem_ctx, messaging_path); } diff --git a/source4/lib/registry/rpc.c b/source4/lib/registry/rpc.c index 3a16ae1db5..117951ed03 100644 --- a/source4/lib/registry/rpc.c +++ b/source4/lib/registry/rpc.c @@ -486,7 +486,7 @@ _PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx, struct dcerpc_pipe *p; struct rpc_registry_context *rctx; - dcerpc_init(); + dcerpc_init(lp_ctx); rctx = talloc(NULL, struct rpc_registry_context); diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 0c3d032068..26cdac99a3 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -70,7 +70,7 @@ _PUBLIC_ NTSTATUS socket_create_with_ops(TALLOC_CTX *mem_ctx, const struct socke if (!(flags & SOCKET_FLAG_BLOCK) && type == SOCKET_TYPE_STREAM && - lp_parm_bool(global_loadparm, NULL, "socket", "testnonblock", false)) { + getenv("SOCKET_TESTNONBLOCK") != NULL) { (*new_sock)->flags |= SOCKET_FLAG_TESTNONBLOCK; } diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index 4baa0cfbb1..ec3afe8f7f 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -208,4 +208,6 @@ NTSTATUS socket_connect_multi(TALLOC_CTX *mem_ctx, const char *server_address, void set_socket_options(int fd, const char *options); void socket_set_flags(struct socket_context *socket, unsigned flags); +extern bool testnonblock; + #endif /* _SAMBA_SOCKET_H */ diff --git a/source4/lib/torture/subunit.c b/source4/lib/torture/subunit.c index 40d9b9731d..d5ee344596 100644 --- a/source4/lib/torture/subunit.c +++ b/source4/lib/torture/subunit.c @@ -20,7 +20,7 @@ #include "includes.h" #include "lib/torture/torture.h" -static void subunit_init(struct torture_context *ctx) +static void subunit_init(struct torture_results *results) { /* FIXME: register segv and bus handler */ } diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c index 54ddc79be7..e465529f6b 100644 --- a/source4/lib/torture/torture.c +++ b/source4/lib/torture/torture.c @@ -24,25 +24,57 @@ #include "param/param.h" #include "system/filesys.h" +struct torture_results *torture_results_init(TALLOC_CTX *mem_ctx, const struct torture_ui_ops *ui_ops) +{ + struct torture_results *results = talloc_zero(mem_ctx, struct torture_results); + + results->ui_ops = ui_ops; + results->returncode = true; + + if (ui_ops->init) + ui_ops->init(results); + + return results; +} + /** * Initialize a torture context */ struct torture_context *torture_context_init(struct event_context *event_ctx, - const struct torture_ui_ops *ui_ops) + struct torture_results *results) { struct torture_context *torture = talloc_zero(event_ctx, struct torture_context); - torture->ui_ops = ui_ops; - torture->returncode = true; - torture->ev = event_ctx; - if (ui_ops->init) - ui_ops->init(torture); + if (torture == NULL) + return NULL; + + torture->ev = event_ctx; + torture->results = talloc_reference(torture, results); return torture; } /** + * Create a sub torture context + */ +struct torture_context *torture_context_child(struct torture_context *parent) +{ + struct torture_context *subtorture = talloc_zero(parent, struct torture_context); + + if (subtorture == NULL) + return NULL; + + subtorture->level = parent->level+1; + subtorture->ev = talloc_reference(subtorture, parent->ev); + subtorture->lp_ctx = talloc_reference(subtorture, parent->lp_ctx); + subtorture->outputdir = talloc_reference(subtorture, parent->outputdir); + subtorture->results = talloc_reference(subtorture, parent->results); + + return subtorture; +} + +/** create a temporary directory. */ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, @@ -70,13 +102,13 @@ void torture_comment(struct torture_context *context, const char *comment, ...) va_list ap; char *tmp; - if (!context->ui_ops->comment) + if (!context->results->ui_ops->comment) return; va_start(ap, comment); tmp = talloc_vasprintf(context, comment, ap); - context->ui_ops->comment(context, tmp); + context->results->ui_ops->comment(context, tmp); talloc_free(tmp); } @@ -89,13 +121,13 @@ void torture_warning(struct torture_context *context, const char *comment, ...) va_list ap; char *tmp; - if (!context->ui_ops->warning) + if (!context->results->ui_ops->warning) return; va_start(ap, comment); tmp = talloc_vasprintf(context, comment, ap); - context->ui_ops->warning(context, tmp); + context->results->ui_ops->warning(context, tmp); talloc_free(tmp); } @@ -224,8 +256,8 @@ bool torture_run_suite(struct torture_context *context, char *old_testname; context->level++; - if (context->ui_ops->suite_start) - context->ui_ops->suite_start(context, suite); + if (context->results->ui_ops->suite_start) + context->results->ui_ops->suite_start(context, suite); old_testname = context->active_testname; if (old_testname != NULL) @@ -245,8 +277,8 @@ bool torture_run_suite(struct torture_context *context, talloc_free(context->active_testname); context->active_testname = old_testname; - if (context->ui_ops->suite_finish) - context->ui_ops->suite_finish(context, suite); + if (context->results->ui_ops->suite_finish) + context->results->ui_ops->suite_finish(context, suite); context->level--; @@ -257,19 +289,19 @@ void torture_ui_test_start(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test) { - if (context->ui_ops->test_start) - context->ui_ops->test_start(context, tcase, test); + if (context->results->ui_ops->test_start) + context->results->ui_ops->test_start(context, tcase, test); } void torture_ui_test_result(struct torture_context *context, enum torture_result result, const char *comment) { - if (context->ui_ops->test_result) - context->ui_ops->test_result(context, result, comment); + if (context->results->ui_ops->test_result) + context->results->ui_ops->test_result(context, result, comment); if (result == TORTURE_ERROR || result == TORTURE_FAIL) - context->returncode = false; + context->results->returncode = false; } static bool internal_torture_run_test(struct torture_context *context, @@ -347,8 +379,8 @@ bool torture_run_tcase(struct torture_context *context, context->level++; context->active_tcase = tcase; - if (context->ui_ops->tcase_start) - context->ui_ops->tcase_start(context, tcase); + if (context->results->ui_ops->tcase_start) + context->results->ui_ops->tcase_start(context, tcase); if (tcase->fixture_persistent && tcase->setup && !tcase->setup(context, &tcase->data)) { @@ -378,8 +410,8 @@ bool torture_run_tcase(struct torture_context *context, done: context->active_tcase = NULL; - if (context->ui_ops->tcase_finish) - context->ui_ops->tcase_finish(context, tcase); + if (context->results->ui_ops->tcase_finish) + context->results->ui_ops->tcase_finish(context, tcase); context->level--; diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h index ea5cd70961..f06ffe012b 100644 --- a/source4/lib/torture/torture.h +++ b/source4/lib/torture/torture.h @@ -25,6 +25,7 @@ struct torture_test; struct torture_context; struct torture_suite; struct torture_tcase; +struct torture_results; enum torture_result { TORTURE_OK=0, @@ -39,7 +40,7 @@ enum torture_result { */ struct torture_ui_ops { - void (*init) (struct torture_context *); + void (*init) (struct torture_results *); void (*comment) (struct torture_context *, const char *); void (*warning) (struct torture_context *, const char *); void (*suite_start) (struct torture_context *, struct torture_suite *); @@ -73,44 +74,67 @@ void torture_ui_test_result(struct torture_context *context, struct torture_context { - const struct torture_ui_ops *ui_ops; - void *ui_data; + struct torture_results *results; char *active_testname; struct torture_test *active_test; struct torture_tcase *active_tcase; - bool quiet; /* Whether tests should avoid writing output to stdout */ - enum torture_result last_result; char *last_reason; - bool returncode; - + /** Directory used for temporary test data */ const char *outputdir; + + /** Indentation level */ int level; + + /** Event context */ struct event_context *ev; + /** Loadparm context (will go away in favor of torture_setting_ at some point) */ struct loadparm_context *lp_ctx; }; +struct torture_results +{ + const struct torture_ui_ops *ui_ops; + void *ui_data; + + /** Whether tests should avoid writing output to stdout */ + bool quiet; + + bool returncode; + + +}; + /* * Describes a particular torture test */ struct torture_test { + /** Short unique name for the test. */ const char *name; + + /** Long description for the test. */ const char *description; + + /** Whether this is a dangerous test + * (can corrupt the remote servers data or bring it down). */ bool dangerous; - /* Function to call to run this test */ + + /** Function to call to run this test */ bool (*run) (struct torture_context *torture_ctx, struct torture_tcase *tcase, struct torture_test *test); struct torture_test *prev, *next; - /* Pointer to the actual test function. This is run by the - * run() function above. */ + /** Pointer to the actual test function. This is run by the + * run() function above. */ void *fn; + + /** Use data for this test */ const void *data; }; @@ -390,8 +414,11 @@ bool torture_suite_init_tcase(struct torture_suite *suite, struct torture_tcase *tcase, const char *name); -struct torture_context *torture_context_init(struct event_context *event_ctx, - const struct torture_ui_ops *ui_ops); +struct torture_context *torture_context_init(struct event_context *event_ctx, struct torture_results *results); + +struct torture_results *torture_results_init(TALLOC_CTX *mem_ctx, const struct torture_ui_ops *ui_ops); + +struct torture_context *torture_context_child(struct torture_context *tctx); extern const struct torture_ui_ops torture_subunit_ui_ops; diff --git a/source4/lib/wmi/wmicore.c b/source4/lib/wmi/wmicore.c index a853f26035..7624946536 100644 --- a/source4/lib/wmi/wmicore.c +++ b/source4/lib/wmi/wmicore.c @@ -37,9 +37,10 @@ struct IWbemContext; DEBUG(1, ("OK : %s\n", msg)); \ } -void wmi_init(struct com_context **ctx, struct cli_credentials *credentials) +void wmi_init(struct com_context **ctx, struct cli_credentials *credentials, + struct loadparm_context *lp_ctx) { - dcerpc_init(); + dcerpc_init(lp_ctx); ndr_table_init(); /* FIXME: Register DCOM proxies? */ |