This will allow the TDB layer to get at the lp_ctx for tdb options.
Andrew Bartlett
}
msg_ctx = imessaging_client_init(frame,
- lpcfg_imessaging_path(frame, lp_ctx),
+ lp_ctx,
event_ctx);
if (msg_ctx == NULL) {
DEBUG(1, ("imessaging_init failed\n"));
(struct loadparm_context *)ldb_get_opaque(ldb, "loadparm");
TALLOC_CTX *tmp_ctx = talloc_new(module);
- msg = imessaging_client_init(tmp_ctx, lpcfg_imessaging_path(tmp_ctx, lp_ctx),
+ msg = imessaging_client_init(tmp_ctx, lp_ctx,
ldb_get_event_context(ldb));
if (!msg) {
DEBUG(3,(__location__ ": Failed to create messaging context\n"));
"RODC cannot become a role master.");
}
- msg = imessaging_client_init(tmp_ctx, lpcfg_imessaging_path(tmp_ctx, lp_ctx),
+ msg = imessaging_client_init(tmp_ctx, lp_ctx,
ldb_get_event_context(ldb));
if (!msg) {
ldb_asprintf_errstring(ldb, "Failed to generate client messaging context in %s", lpcfg_imessaging_path(tmp_ctx, lp_ctx));
#include "../lib/util/util_tdb.h"
#include "cluster/cluster.h"
#include "../lib/util/tevent_ntstatus.h"
+#include "lib/param/param.h"
/* change the message version with any incompatible changes in the protocol */
#define IMESSAGING_VERSION 1
memory
*/
struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
- const char *dir,
+ struct loadparm_context *lp_ctx,
struct server_id server_id,
struct tevent_context *ev,
bool auto_remove)
}
/* create the messaging directory if needed */
- mkdir(dir, 0700);
- msg->base_path = talloc_reference(msg, dir);
+ msg->base_path = lpcfg_imessaging_path(msg, lp_ctx);
+
+ mkdir(msg->base_path, 0700);
+
msg->path = imessaging_path(msg, server_id);
msg->server_id = server_id;
msg->idr = idr_init(msg);
A hack, for the short term until we get 'client only' messaging in place
*/
struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx,
- const char *dir,
+ struct loadparm_context *lp_ctx,
struct tevent_context *ev)
{
struct server_id id;
ZERO_STRUCT(id);
id.pid = random() % 0x10000000;
- return imessaging_init(mem_ctx, dir, id, ev, true);
+ return imessaging_init(mem_ctx, lp_ctx, id, ev, true);
}
/*
a list of registered irpc server functions
NTSTATUS imessaging_register_tmp(struct imessaging_context *msg, void *private_data,
msg_callback_t fn, uint32_t *msg_type);
struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
- const char *dir,
+ struct loadparm_context *lp_ctx,
struct server_id server_id,
struct tevent_context *ev,
bool auto_remove);
int imessaging_cleanup(struct imessaging_context *msg);
struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx,
- const char *dir,
+ struct loadparm_context *lp_ctx,
struct tevent_context *ev);
NTSTATUS imessaging_send_ptr(struct imessaging_context *msg, struct server_id server,
uint32_t msg_type, void *ptr);
static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs)
{
struct tevent_context *ev;
- const char *kwnames[] = { "own_id", "messaging_path", NULL };
+ const char *kwnames[] = { "own_id", "lp_ctx", NULL };
PyObject *own_id = Py_None;
- const char *imessaging_path = NULL;
+ PyObject *py_lp_ctx = Py_None;
imessaging_Object *ret;
+ struct loadparm_context *lp_ctx;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oz:connect",
- discard_const_p(char *, kwnames), &own_id, &imessaging_path)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:connect",
+ discard_const_p(char *, kwnames), &own_id, &py_lp_ctx)) {
return NULL;
}
ret->mem_ctx = talloc_new(NULL);
- ev = s4_event_context_init(ret->mem_ctx);
-
- if (imessaging_path == NULL) {
- imessaging_path = lpcfg_imessaging_path(ret->mem_ctx,
- py_default_loadparm_context(ret->mem_ctx));
- } else {
- imessaging_path = talloc_strdup(ret->mem_ctx, imessaging_path);
+ lp_ctx = lpcfg_from_py_object(ret->mem_ctx, py_lp_ctx);
+ if (lp_ctx == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "imessaging_connect unable to interpret loadparm_context");
+ talloc_free(ret->mem_ctx);
+ return NULL;
}
+ ev = s4_event_context_init(ret->mem_ctx);
+
if (own_id != Py_None) {
struct server_id server_id;
return NULL;
ret->msg_ctx = imessaging_init(ret->mem_ctx,
- imessaging_path,
+ lp_ctx,
server_id,
ev, true);
} else {
ret->msg_ctx = imessaging_client_init(ret->mem_ctx,
- imessaging_path,
+ lp_ctx,
ev);
}
data->ev = tctx->ev;
torture_assert(tctx, data->msg_ctx1 =
imessaging_init(tctx,
- lpcfg_imessaging_path(tctx, tctx->lp_ctx),
+ tctx->lp_ctx,
cluster_id(0, MSG_ID1),
data->ev, true),
"Failed to init first messaging context");
torture_assert(tctx, data->msg_ctx2 =
imessaging_init(tctx,
- lpcfg_imessaging_path(tctx, tctx->lp_ctx),
+ tctx->lp_ctx,
cluster_id(0, MSG_ID2),
data->ev, true),
"Failed to init second messaging context");
ev = tctx->ev;
msg_server_ctx = imessaging_init(tctx,
- lpcfg_imessaging_path(tctx, tctx->lp_ctx), cluster_id(0, 1),
+ tctx->lp_ctx, cluster_id(0, 1),
ev, true);
torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context");
imessaging_register_tmp(msg_server_ctx, tctx, exit_message, &msg_exit);
msg_client_ctx = imessaging_init(tctx,
- lpcfg_imessaging_path(tctx, tctx->lp_ctx),
+ tctx->lp_ctx,
cluster_id(0, 2),
ev, true);
{
struct imessaging_context *msg;
- msg = imessaging_client_init(mem_ctx, lpcfg_imessaging_path(mem_ctx, lp_ctx), event_ctx);
+ msg = imessaging_client_init(mem_ctx, lp_ctx, event_ctx);
NT_STATUS_HAVE_NO_MEMORY(msg);
*binding_handle = irpc_binding_handle_by_name(mem_ctx, msg, irpc_server, table);
class MessagingTests(TestCase):
def get_context(self, *args, **kwargs):
- kwargs["messaging_path"] = "."
return Messaging(*args, **kwargs)
def test_register(self):
NTSTATUS status;
msg = imessaging_init(talloc_autofree_context(),
- lpcfg_imessaging_path(event_ctx, lp_ctx),
+ lp_ctx,
cluster_id(0, SAMBA_PARENT_TASKID), event_ctx, false);
NT_STATUS_HAVE_NO_MEMORY(msg);
/* setup to receive internal messages on this connection */
srv_conn->msg_ctx = imessaging_init(srv_conn,
- lpcfg_imessaging_path(srv_conn, lp_ctx),
+ lp_ctx,
srv_conn->server_id, ev, false);
if (!srv_conn->msg_ctx) {
stream_terminate_connection(srv_conn, "imessaging_init() failed");
task->lp_ctx = lp_ctx;
task->msg_ctx = imessaging_init(task,
- lpcfg_imessaging_path(task, task->lp_ctx),
+ task->lp_ctx,
task->server_id,
task->event_ctx, false);
if (!task->msg_ctx) {
const char *winbind_method[] = { "winbind", NULL };
struct auth4_context *auth_context;
- msg = imessaging_client_init(state, lpcfg_imessaging_path(state, lp_ctx), ev);
+ msg = imessaging_client_init(state, lp_ctx, ev);
if (!msg) {
talloc_free(mem_ctx);
exit(1);