1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2018-06-26 20:12:23 +10:00 committed by Martin Schwenke
parent af446d5209
commit 63255ef925
3 changed files with 35 additions and 13 deletions

View File

@ -725,9 +725,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,

View File

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

View File

@ -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) {