1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

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 <ambi@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Christian Ambach <ambi@samba.org>
Autobuild-Date(master): Fri May 17 13:16:37 CEST 2013 on sn-devel-104
This commit is contained in:
Christian Ambach
2013-05-16 15:07:44 +02:00
parent d67e614a07
commit c29447f2b8

View File

@ -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);
}