diff options
author | Christian Ambach <ambi@samba.org> | 2013-05-16 15:07:44 +0200 |
---|---|---|
committer | Christian Ambach <ambi@samba.org> | 2013-05-17 13:16:37 +0200 |
commit | c29447f2b8705630a24d3d73f76661af296a4c4d (patch) | |
tree | 797ca658fd9f917d9be56f12e8a149aa9e5390e6 /source3/lib | |
parent | d67e614a07cbf143293436d380aba9a022c0e31b (diff) | |
download | samba-c29447f2b8705630a24d3d73f76661af296a4c4d.tar.gz samba-c29447f2b8705630a24d3d73f76661af296a4c4d.tar.bz2 samba-c29447f2b8705630a24d3d73f76661af296a4c4d.zip |
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
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/ctdb_conn.c | 15 |
1 files changed, 14 insertions, 1 deletions
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); } |