1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s4-messaging: Pass the loadparm context, not just the messaging path

This will allow the TDB layer to get at the lp_ctx for tdb options.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 2011-10-13 20:01:56 +11:00
parent 5603dab647
commit 3cdb1fe440
14 changed files with 36 additions and 33 deletions

View File

@ -122,7 +122,7 @@ static NTSTATUS prepare_gensec(TALLOC_CTX *mem_ctx,
}
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"));

View File

@ -73,7 +73,7 @@ static void ridalloc_poke_rid_manager(struct ldb_module *module)
(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"));

View File

@ -1299,7 +1299,7 @@ static int rootdse_become_master(struct ldb_module *module,
"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));

View File

@ -34,6 +34,7 @@
#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
@ -566,7 +567,7 @@ int imessaging_cleanup(struct imessaging_context *msg)
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)
@ -592,9 +593,11 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
}
/* 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);
@ -648,13 +651,13 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
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

View File

@ -54,13 +54,13 @@ NTSTATUS imessaging_register(struct imessaging_context *msg, void *private_data,
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);

View File

@ -64,13 +64,14 @@ typedef struct {
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;
}
@ -80,15 +81,15 @@ static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObj
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;
@ -96,12 +97,12 @@ static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObj
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);
}

View File

@ -247,14 +247,14 @@ static bool irpc_setup(struct torture_context *tctx, void **_data)
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");

View File

@ -72,7 +72,7 @@ static bool test_ping_speed(struct torture_context *tctx)
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");
@ -81,7 +81,7 @@ static bool test_ping_speed(struct torture_context *tctx)
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);

View File

@ -74,7 +74,7 @@ static NTSTATUS pyrpc_irpc_connect(TALLOC_CTX *mem_ctx, const char *irpc_server,
{
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);

View File

@ -26,7 +26,6 @@ from samba.tests import TestCase
class MessagingTests(TestCase):
def get_context(self, *args, **kwargs):
kwargs["messaging_path"] = "."
return Messaging(*args, **kwargs)
def test_register(self):

View File

@ -221,7 +221,7 @@ static NTSTATUS setup_parent_messaging(struct tevent_context *event_ctx,
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);

View File

@ -189,7 +189,7 @@ static void stream_new_connection(struct tevent_context *ev,
/* 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");

View File

@ -79,7 +79,7 @@ static void task_server_callback(struct tevent_context *event_ctx,
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) {

View File

@ -463,7 +463,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
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);