mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
validate dmaster on a client fetch request
(This used to be ctdb commit b49069aac0c14e5a02be843247930c197d620a81)
This commit is contained in:
parent
ddf430b2f2
commit
908f5085b0
@ -244,6 +244,30 @@ static void daemon_request_shutdown(struct ctdb_client *client,
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
send a fetch lock error reply to the client
|
||||
*/
|
||||
static void daemon_fetch_lock_error(struct ctdb_client *client,
|
||||
struct ctdb_req_fetch_lock *f)
|
||||
{
|
||||
struct ctdb_reply_fetch_lock r;
|
||||
|
||||
ZERO_STRUCT(r);
|
||||
r.hdr.length = sizeof(r);
|
||||
r.hdr.ctdb_magic = CTDB_MAGIC;
|
||||
r.hdr.ctdb_version = CTDB_VERSION;
|
||||
r.hdr.operation = CTDB_REPLY_FETCH_LOCK;
|
||||
r.hdr.reqid = f->hdr.reqid;
|
||||
r.state = -1;
|
||||
|
||||
/*
|
||||
* Ignore the result, there's not much we can do anyway.
|
||||
*/
|
||||
ctdb_queue_send(client->queue, (uint8_t *)&r.hdr,
|
||||
r.hdr.length);
|
||||
}
|
||||
|
||||
/*
|
||||
called when the daemon gets a fetch lock request from a client
|
||||
*/
|
||||
@ -257,21 +281,13 @@ static void daemon_request_fetch_lock(struct ctdb_client *client,
|
||||
|
||||
ctdb_db = find_ctdb_db(client->ctdb, f->db_id);
|
||||
if (ctdb_db == NULL) {
|
||||
struct ctdb_reply_fetch_lock r;
|
||||
daemon_fetch_lock_error(client, f);
|
||||
return;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(r);
|
||||
r.hdr.length = sizeof(r);
|
||||
r.hdr.ctdb_magic = CTDB_MAGIC;
|
||||
r.hdr.ctdb_version = CTDB_VERSION;
|
||||
r.hdr.operation = CTDB_REPLY_FETCH_LOCK;
|
||||
r.hdr.reqid = f->hdr.reqid;
|
||||
r.state = -1;
|
||||
|
||||
/*
|
||||
* Ignore the result, there's not much we can do anyway.
|
||||
*/
|
||||
ctdb_queue_send(client->queue, (uint8_t *)&r.hdr,
|
||||
r.hdr.length);
|
||||
if (!ctdb_validate_vnn(client->ctdb, f->header.dmaster)) {
|
||||
DEBUG(0,(__location__ " Invalid dmaster %u\n", f->header.dmaster));
|
||||
daemon_fetch_lock_error(client, f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,3 +102,4 @@ uint32_t ctdb_hash(const TDB_DATA *key)
|
||||
|
||||
return (1103515243 * value + 12345);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,11 @@ struct ctdb_address {
|
||||
int port;
|
||||
};
|
||||
|
||||
/*
|
||||
check a vnn is valid
|
||||
*/
|
||||
#define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
|
||||
|
||||
|
||||
/* called from the queue code when a packet comes in. Called with data==NULL
|
||||
on error */
|
||||
|
Loading…
x
Reference in New Issue
Block a user