summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-04-18 18:39:02 +1000
committerAndrew Tridgell <tridge@samba.org>2007-04-18 18:39:02 +1000
commit908f5085b051bbf154acae75ad2a76d342593fdd (patch)
tree17f09f2e16a33e403aabd11d991c71b469affe3d /ctdb/common
parentddf430b2f2229699f834a5bace056f73cc695809 (diff)
downloadsamba-908f5085b051bbf154acae75ad2a76d342593fdd.tar.gz
validate dmaster on a client fetch request
(This used to be ctdb commit b49069aac0c14e5a02be843247930c197d620a81)
Diffstat (limited to 'ctdb/common')
-rw-r--r--ctdb/common/ctdb_daemon.c46
-rw-r--r--ctdb/common/ctdb_util.c1
2 files changed, 32 insertions, 15 deletions
diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c
index 14019ea3f10..d784b059b85 100644
--- a/ctdb/common/ctdb_daemon.c
+++ b/ctdb/common/ctdb_daemon.c
@@ -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;
-
- 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);
+ daemon_fetch_lock_error(client, f);
+ return;
+ }
+
+ 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;
}
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index e824e098e56..1c6a571d8ee 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -102,3 +102,4 @@ uint32_t ctdb_hash(const TDB_DATA *key)
return (1103515243 * value + 12345);
}
+