From 3ede7942b8959a79d0b14729ee2f993735b22ade Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 26 Jun 2018 20:12:23 +1000 Subject: [PATCH] ctdb-daemon: Only consider client ID for local database attach The comment immediately above this code says "don't allow local clients to attach" and then looks up the client ID regardless of whether the request is local or remote. This means that an intentional remote attach from a client will not work correctly. No real client should ever do that since clients attach so they an access databases locally. Perhaps some sanity checks should be added. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13500 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 63255ef92552da92956c05160f33622d0bbc3a28) --- ctdb/include/ctdb_private.h | 7 +++++-- ctdb/server/ctdb_control.c | 32 ++++++++++++++++++++++++-------- ctdb/server/ctdb_ltdb_server.c | 9 ++++++--- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index da3760da7b2..03e0068358f 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -724,9 +724,12 @@ int ctdb_set_db_readonly(struct ctdb_context *ctdb, int ctdb_process_deferred_attach(struct ctdb_context *ctdb); -int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata, +int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, + TDB_DATA indata, TDB_DATA *outdata, - uint8_t db_flags, uint32_t client_id, + uint8_t db_flags, + uint32_t srcnode, + uint32_t client_id, struct ctdb_req_control_old *c, bool *async_reply); int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata, diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index f7a8b6b6e65..063cd1d3a8f 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -267,18 +267,34 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, } case CTDB_CONTROL_DB_ATTACH: - return ctdb_control_db_attach(ctdb, indata, outdata, 0, client_id, - c, async_reply); + return ctdb_control_db_attach(ctdb, + indata, + outdata, + 0, + srcnode, + client_id, + c, + async_reply); case CTDB_CONTROL_DB_ATTACH_PERSISTENT: - return ctdb_control_db_attach(ctdb, indata, outdata, - CTDB_DB_FLAGS_PERSISTENT, client_id, - c, async_reply); + return ctdb_control_db_attach(ctdb, + indata, + outdata, + CTDB_DB_FLAGS_PERSISTENT, + srcnode, + client_id, + c, + async_reply); case CTDB_CONTROL_DB_ATTACH_REPLICATED: - return ctdb_control_db_attach(ctdb, indata, outdata, - CTDB_DB_FLAGS_REPLICATED, client_id, - c, async_reply); + return ctdb_control_db_attach(ctdb, + indata, + outdata, + CTDB_DB_FLAGS_REPLICATED, + srcnode, + client_id, + c, + async_reply); case CTDB_CONTROL_SET_CALL: return control_not_implemented("SET_CALL", NULL); diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index 1962f854683..ca5bb124f5f 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -1105,9 +1105,12 @@ int ctdb_process_deferred_attach(struct ctdb_context *ctdb) /* a client has asked to attach a new database */ -int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata, +int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, + TDB_DATA indata, TDB_DATA *outdata, - uint8_t db_flags, uint32_t client_id, + uint8_t db_flags, + uint32_t srcnode, + uint32_t client_id, struct ctdb_req_control_old *c, bool *async_reply) { @@ -1128,7 +1131,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata, * allow all attach from the network since these are always from remote * recovery daemons. */ - if (client_id != 0) { + if (srcnode == ctdb->pnn && client_id != 0) { client = reqid_find(ctdb->idr, client_id, struct ctdb_client); } if (client != NULL) { -- 2.18.0