From c29447f2b8705630a24d3d73f76661af296a4c4d Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Thu, 16 May 2013 15:07:44 +0200 Subject: s3:lib/ctdb_conn make sure we are root before connecting to CTDB CTDB socket is only reachable for root, make sure we are root when trying to connect to it Signed-off-by: Christian Ambach Reviewed-by: Stefan Metzmacher Autobuild-User(master): Christian Ambach Autobuild-Date(master): Fri May 17 13:16:37 CEST 2013 on sn-devel-104 --- source3/lib/ctdb_conn.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/ctdb_conn.c b/source3/lib/ctdb_conn.c index d7bf6a5755..90930eb86b 100644 --- a/source3/lib/ctdb_conn.c +++ b/source3/lib/ctdb_conn.c @@ -35,6 +35,18 @@ struct ctdb_conn_init_state { struct ctdb_conn *conn; }; +/* + * use the callbacks of async_connect_send to make sure + * we are connecting to CTDB as root + */ +static void before_connect_cb(void *private_data) { + become_root(); +} + +static void after_connect_cb(void *private_data) { + unbecome_root(); +} + static void ctdb_conn_init_done(struct tevent_req *subreq); static int ctdb_conn_destructor(struct ctdb_conn *conn); @@ -83,7 +95,8 @@ struct tevent_req *ctdb_conn_init_send(TALLOC_CTX *mem_ctx, subreq = async_connect_send(state, ev, state->conn->fd, (struct sockaddr *)&state->addr, - sizeof(state->addr), NULL, NULL, NULL); + sizeof(state->addr), before_connect_cb, + after_connect_cb, NULL); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } -- cgit