mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
Use a custom init function for samba4 that sets a samba4
specific debug function. By default do not debug, this is the most appropriate action for a library as we cannot assume what stderr is use for in the main app. The main app is responsible to set ev_debug_stderr if they so desire. (This used to be commit e566a2f308ac6fb4b526a744f7059b565670aea5)
This commit is contained in:
parent
929adc9efa
commit
2daf2897d5
@ -581,7 +581,7 @@ int main(int argc, const char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
gensec_init(cmdline_lp_ctx);
|
||||
dump_args();
|
||||
|
@ -3228,7 +3228,7 @@ static int do_message_op(const char *netbios_name, const char *desthost,
|
||||
|
||||
lp_smbcli_options(cmdline_lp_ctx, &smb_options);
|
||||
|
||||
ev_ctx = event_context_init(talloc_autofree_context());
|
||||
ev_ctx = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
|
||||
|
||||
|
@ -604,7 +604,7 @@ int main(int argc, char *argv[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
assert(ev);
|
||||
|
||||
tcx->ibwctx = ibw_init(tcx->attrs, tcx->nattrs,
|
||||
|
@ -650,7 +650,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
|
||||
domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name);
|
||||
talloc_set_destructor(domain_socket_name, unlink_destructor);
|
||||
|
||||
ctdb->ev = event_context_init(NULL);
|
||||
ctdb->ev = s4_event_context_init(NULL);
|
||||
|
||||
/* start frozen, then let the first election sort things out */
|
||||
if (!ctdb_blocking_freeze(ctdb)) {
|
||||
|
@ -1487,7 +1487,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
|
||||
|
||||
/* get a new event context */
|
||||
talloc_free(ctdb->ev);
|
||||
ctdb->ev = event_context_init(ctdb);
|
||||
ctdb->ev = s4_event_context_init(ctdb);
|
||||
|
||||
event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
|
||||
ctdb_recoverd_parent, &fd[0]);
|
||||
|
@ -141,7 +141,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
block_signal(SIGPIPE);
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
ctdb = ctdb_cmdline_init(ev);
|
||||
|
||||
|
@ -192,7 +192,7 @@ int main(int argc, const char *argv[])
|
||||
while (extra_argv[extra_argc]) extra_argc++;
|
||||
}
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
/* initialise ctdb */
|
||||
ctdb = ctdb_cmdline_client(ev);
|
||||
|
@ -211,7 +211,7 @@ int main(int argc, const char *argv[])
|
||||
while (extra_argv[extra_argc]) extra_argc++;
|
||||
}
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
ctdb = ctdb_cmdline_client(ev);
|
||||
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, const char *argv[])
|
||||
while (extra_argv[extra_argc]) extra_argc++;
|
||||
}
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
ctdb = ctdb_cmdline_client(ev);
|
||||
|
||||
|
@ -977,7 +977,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
control = extra_argv[0];
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
/* initialise ctdb */
|
||||
ctdb = ctdb_cmdline_client(ev);
|
||||
|
@ -121,7 +121,7 @@ int samdb_copy_template(struct ldb_context *ldb,
|
||||
/* FIXME: need to remove this wehn we finally pass the event
|
||||
* context around in ldb */
|
||||
if (event_ctx == NULL) {
|
||||
event_ctx = event_context_init(templates_ldb);
|
||||
event_ctx = s4_event_context_init(templates_ldb);
|
||||
}
|
||||
|
||||
templates_ldb = ldb_wrap_connect(ldb, event_ctx, lp_ctx,
|
||||
|
@ -43,7 +43,6 @@ typedef void (*event_aio_handler_t)(struct event_context *, struct aio_event *,
|
||||
int, void *);
|
||||
|
||||
#ifdef _SAMBA_BUILD_
|
||||
struct event_context *s4_event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
|
||||
struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx);
|
||||
#endif
|
||||
|
||||
|
@ -43,9 +43,9 @@ int ev_set_debug(struct event_context *ev,
|
||||
/*
|
||||
debug function for ev_set_debug_stderr
|
||||
*/
|
||||
static void ev_debug_stderr(void *context, enum ev_debug_level level,
|
||||
void ev_debug_stderr(void *context, enum ev_debug_level level,
|
||||
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
|
||||
static void ev_debug_stderr(void *context, enum ev_debug_level level,
|
||||
void ev_debug_stderr(void *context, enum ev_debug_level level,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
if (level <= EV_DEBUG_WARNING) {
|
||||
@ -63,13 +63,18 @@ int ev_set_debug_stderr(struct event_context *ev)
|
||||
}
|
||||
|
||||
/*
|
||||
log a message
|
||||
* log a message
|
||||
*
|
||||
* The default debug action is to ignore debugging messages.
|
||||
* This is the most appropriate action for a library.
|
||||
* Applications using the library must decide where to
|
||||
* redirect debugging messages
|
||||
*/
|
||||
void ev_debug(struct event_context *ev, enum ev_debug_level level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
if (ev->debug_ops.debug == NULL) {
|
||||
ev_set_debug_stderr(ev);
|
||||
return;
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
ev->debug_ops.debug(ev->debug_ops.context, level, fmt, ap);
|
||||
|
@ -55,3 +55,54 @@ NTSTATUS s4_events_aio_init(void)
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
this is used to catch debug messages from events
|
||||
*/
|
||||
static void ev_wrap_debug(void *context, enum ev_debug_level level,
|
||||
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
|
||||
|
||||
static void ev_wrap_debug(void *context, enum ev_debug_level level,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
int samba_level = -1;
|
||||
char *s = NULL;
|
||||
switch (level) {
|
||||
case EV_DEBUG_FATAL:
|
||||
samba_level = 0;
|
||||
break;
|
||||
case EV_DEBUG_ERROR:
|
||||
samba_level = 1;
|
||||
break;
|
||||
case EV_DEBUG_WARNING:
|
||||
samba_level = 2;
|
||||
break;
|
||||
case EV_DEBUG_TRACE:
|
||||
samba_level = 5;
|
||||
break;
|
||||
|
||||
};
|
||||
vasprintf(&s, fmt, ap);
|
||||
if (!s) return;
|
||||
DEBUG(samba_level, ("events: %s\n", s));
|
||||
free(s);
|
||||
}
|
||||
|
||||
/*
|
||||
create a event_context structure. This must be the first events
|
||||
call, and all subsequent calls pass this event_context as the first
|
||||
element. Event handlers also receive this as their first argument.
|
||||
|
||||
This samba4 specific call sets the samba4 debug handler.
|
||||
*/
|
||||
struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct event_context *ev;
|
||||
|
||||
ev = event_context_init_byname(mem_ctx, NULL);
|
||||
if (ev) {
|
||||
ev_set_debug(ev, ev_wrap_debug, NULL);
|
||||
}
|
||||
return ev;
|
||||
}
|
||||
|
||||
|
@ -758,12 +758,12 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
|
||||
module->private_data = ildb;
|
||||
ildb->module = module;
|
||||
|
||||
event_ctx = ldb_get_opaque(ldb, "EventContext");
|
||||
event_ctx = ldb_get_event_context(ldb);
|
||||
|
||||
/* FIXME: We must make the event context an explicit parameter, but we
|
||||
* need to build the events library separately first. Hack a new event
|
||||
* context so that CMD line utilities work until we have libevents for
|
||||
* standalone builds ready */
|
||||
* context so that CMD line utilities work until we have them all
|
||||
* converted */
|
||||
if (event_ctx == NULL) {
|
||||
event_ctx = event_context_init(NULL);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ PyObject *py_messaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwa
|
||||
|
||||
ret->mem_ctx = talloc_new(NULL);
|
||||
|
||||
ev = event_context_init(ret->mem_ctx);
|
||||
ev = s4_event_context_init(ret->mem_ctx);
|
||||
|
||||
if (messaging_path == NULL) {
|
||||
messaging_path = lp_messaging_path(ret, global_loadparm);
|
||||
@ -330,7 +330,7 @@ PyObject *py_irpc_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
|
||||
|
||||
ret->server_name = server;
|
||||
|
||||
ev = event_context_init(ret->mem_ctx);
|
||||
ev = s4_event_context_init(ret->mem_ctx);
|
||||
|
||||
if (messaging_path == NULL) {
|
||||
messaging_path = lp_messaging_path(ret, global_loadparm);
|
||||
|
@ -3486,7 +3486,7 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
|
||||
|
||||
arg3 = NULL;
|
||||
arg4 = NULL;
|
||||
arg5 = event_context_init(NULL);
|
||||
arg5 = s4_event_context_init(NULL);
|
||||
arg6 = loadparm_init(NULL);
|
||||
arg1 = NULL;
|
||||
arg7 = &tmp7;
|
||||
@ -3574,7 +3574,7 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
|
||||
|
||||
arg3 = NULL;
|
||||
arg4 = NULL;
|
||||
arg5 = event_context_init(NULL);
|
||||
arg5 = s4_event_context_init(NULL);
|
||||
arg6 = loadparm_init(NULL);
|
||||
arg1 = NULL;
|
||||
arg7 = &tmp7;
|
||||
@ -3735,7 +3735,7 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
|
||||
(char *) "ev_ctx",(char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL
|
||||
};
|
||||
|
||||
arg3 = event_context_init(NULL);
|
||||
arg3 = s4_event_context_init(NULL);
|
||||
arg4 = loadparm_init(NULL);
|
||||
arg5 = NULL;
|
||||
arg6 = NULL;
|
||||
|
@ -118,7 +118,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
}
|
||||
|
||||
ev_ctx = event_context_init(NULL);
|
||||
ev_ctx = s4_event_context_init(NULL);
|
||||
|
||||
h1 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend1, remote1);
|
||||
if (h1 == NULL)
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char **argv)
|
||||
while((opt = poptGetNextOpt(pc)) != -1) {
|
||||
}
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
|
||||
if (remote) {
|
||||
h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials);
|
||||
|
@ -517,7 +517,7 @@ int main(int argc, char **argv)
|
||||
|
||||
ctx = talloc_zero(NULL, struct regshell_context);
|
||||
|
||||
ev_ctx = event_context_init(ctx);
|
||||
ev_ctx = s4_event_context_init(ctx);
|
||||
|
||||
if (remote != NULL) {
|
||||
ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx,
|
||||
|
@ -129,7 +129,7 @@ int main(int argc, char **argv)
|
||||
while((opt = poptGetNextOpt(pc)) != -1) {
|
||||
}
|
||||
|
||||
ev_ctx = event_context_init(NULL);
|
||||
ev_ctx = s4_event_context_init(NULL);
|
||||
|
||||
if (remote != NULL) {
|
||||
h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials);
|
||||
|
@ -47,7 +47,7 @@ static PyObject *py_nbt_node_init(PyObject *self, PyObject *args, PyObject *kwar
|
||||
if (ret->mem_ctx == NULL)
|
||||
return NULL;
|
||||
|
||||
ev = event_context_init(ret->mem_ctx);
|
||||
ev = s4_event_context_init(ret->mem_ctx);
|
||||
ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm));
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
@ -2621,7 +2621,7 @@ SWIGINTERN PyObject *_wrap_smbcli_sock_connect_byname(PyObject *SWIGUNUSEDPARM(s
|
||||
(char *) "host",(char *) "ports",(char *) "resolve_ctx",(char *) "event_ctx", NULL
|
||||
};
|
||||
|
||||
arg5 = event_context_init(NULL);
|
||||
arg5 = s4_event_context_init(NULL);
|
||||
arg3 = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:smbcli_sock_connect_byname",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
|
||||
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
|
||||
|
@ -47,7 +47,7 @@ static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
|
||||
/* FIXME: we really need to get a context from the caller or we may end
|
||||
* up with 2 event contexts */
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
mem_ctx = talloc_new(ev);
|
||||
|
||||
libnet_ctx = py_net_ctx(cls, ev);
|
||||
|
@ -336,7 +336,7 @@ static PyObject *dcerpc_interface_new(PyTypeObject *self, PyObject *args, PyObje
|
||||
}
|
||||
ret = PyObject_New(dcerpc_InterfaceObject, &dcerpc_InterfaceType);
|
||||
|
||||
event_ctx = event_context_init(mem_ctx);
|
||||
event_ctx = s4_event_context_init(mem_ctx);
|
||||
|
||||
/* Create a dummy interface table struct. TODO: In the future, we should rather just allow
|
||||
* connecting without requiring an interface table.
|
||||
|
@ -115,7 +115,7 @@ static void prefork_new_task(struct event_context *ev,
|
||||
pid = getpid();
|
||||
|
||||
/* This is now the child code. We need a completely new event_context to work with */
|
||||
ev2 = event_context_init(NULL);
|
||||
ev2 = s4_event_context_init(NULL);
|
||||
|
||||
/* the service has given us a private pointer that
|
||||
encapsulates the context it needs for this new connection -
|
||||
@ -173,7 +173,7 @@ static void prefork_new_task(struct event_context *ev,
|
||||
talloc_free(ev2);
|
||||
|
||||
/* But we need a events system to handle reaping children */
|
||||
ev_parent = event_context_init(NULL);
|
||||
ev_parent = s4_event_context_init(NULL);
|
||||
|
||||
/* TODO: Handle some events... */
|
||||
|
||||
|
@ -92,7 +92,7 @@ static void standard_accept_connection(struct event_context *ev,
|
||||
pid = getpid();
|
||||
|
||||
/* This is now the child code. We need a completely new event_context to work with */
|
||||
ev2 = event_context_init(NULL);
|
||||
ev2 = s4_event_context_init(NULL);
|
||||
|
||||
/* the service has given us a private pointer that
|
||||
encapsulates the context it needs for this new connection -
|
||||
@ -161,7 +161,7 @@ static void standard_new_task(struct event_context *ev,
|
||||
pid = getpid();
|
||||
|
||||
/* This is now the child code. We need a completely new event_context to work with */
|
||||
ev2 = event_context_init(NULL);
|
||||
ev2 = s4_event_context_init(NULL);
|
||||
|
||||
/* the service has given us a private pointer that
|
||||
encapsulates the context it needs for this new connection -
|
||||
|
@ -77,7 +77,7 @@ static void thread_accept_connection(struct event_context *ev,
|
||||
struct new_conn_state *state;
|
||||
struct event_context *ev2;
|
||||
|
||||
ev2 = event_context_init(ev);
|
||||
ev2 = s4_event_context_init(ev);
|
||||
if (ev2 == NULL) return;
|
||||
|
||||
state = talloc(ev2, struct new_conn_state);
|
||||
@ -160,7 +160,7 @@ static void thread_new_task(struct event_context *ev,
|
||||
struct new_task_state *state;
|
||||
struct event_context *ev2;
|
||||
|
||||
ev2 = event_context_init(ev);
|
||||
ev2 = s4_event_context_init(ev);
|
||||
if (ev2 == NULL) return;
|
||||
|
||||
state = talloc(ev2, struct new_task_state);
|
||||
|
@ -313,7 +313,7 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
|
||||
|
||||
/* the event context is the top level structure in smbd. Everything else
|
||||
should hang off that */
|
||||
event_ctx = event_context_init(talloc_autofree_context());
|
||||
event_ctx = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
if (event_ctx == NULL) {
|
||||
DEBUG(0,("Initializing event context failed\n"));
|
||||
|
@ -3219,7 +3219,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
|
||||
|
||||
printf("seed=%u\n", options.seed);
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
gensec_init(lp_ctx);
|
||||
|
||||
|
@ -637,7 +637,7 @@ static void usage(poptContext pc)
|
||||
servers[1] = servers[0];
|
||||
}
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
gensec_init(lp_ctx);
|
||||
|
||||
|
@ -550,7 +550,7 @@ static void usage(void)
|
||||
DEBUG(0,("seed=%u\n", seed));
|
||||
srandom(seed);
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
locking_init(1);
|
||||
lp_smbcli_options(lp_ctx, &options);
|
||||
|
@ -355,7 +355,7 @@ static void usage(poptContext pc)
|
||||
|
||||
lp_ctx = cmdline_lp_ctx;
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
gensec_init(lp_ctx);
|
||||
|
||||
|
@ -689,7 +689,7 @@ int main(int argc,char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
torture = torture_context_init(event_context_init(NULL), ui_ops);
|
||||
torture = torture_context_init(s4_event_context_init(NULL), ui_ops);
|
||||
if (basedir != NULL) {
|
||||
if (basedir[0] != '/') {
|
||||
fprintf(stderr, "Please specify an absolute path to --basedir\n");
|
||||
|
@ -185,7 +185,7 @@ static int binary_net(int argc, const char **argv)
|
||||
|
||||
dcerpc_init();
|
||||
|
||||
ev = event_context_init(NULL);
|
||||
ev = s4_event_context_init(NULL);
|
||||
if (!ev) {
|
||||
d_printf("Failed to create an event context\n");
|
||||
exit(1);
|
||||
|
@ -359,7 +359,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
|
||||
|
||||
ev = event_context_init(talloc_autofree_context());
|
||||
ev = s4_event_context_init(talloc_autofree_context());
|
||||
|
||||
while (poptPeekArg(pc)) {
|
||||
const char *name = poptGetArg(pc);
|
||||
|
@ -462,7 +462,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
|
||||
return;
|
||||
}
|
||||
|
||||
ev = event_context_init(state);
|
||||
ev = s4_event_context_init(state);
|
||||
if (!ev) {
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user