Add a tunable "AllowClientDBAttach" with default value 1.
authorMichael Adam <obnox@samba.org>
Fri, 2 Sep 2011 14:42:10 +0000 (16:42 +0200)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 5 Sep 2011 06:16:52 +0000 (16:16 +1000)
When set to 0, clients will not be able to attach to databases
via the db_attach control. This might can be useful for maintenance
where ctdb should be kept running but clients should not be able
to modify databases.

include/ctdb_private.h
server/ctdb_ltdb_server.c
server/ctdb_tunables.c

index 555ed0b42041852f900eff7abc6a900d87cb3bac..675ea49c241f1d6495b28f10f5394fe1d79d32a6 100644 (file)
@@ -121,6 +121,7 @@ struct ctdb_tunable {
        uint32_t deferred_attach_timeout;
        uint32_t vacuum_fast_path_count;
        uint32_t lcp2_public_ip_assignment;
+       uint32_t allow_client_db_attach;
 };
 
 /*
index 6a1244186b4508a8704235d8d86c609707396131..3d18e06155802947bb1d35108feec4a6750bf820 100644 (file)
@@ -1010,6 +1010,12 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
        struct ctdb_client *client = NULL;
 
+       if (ctdb->tunable.allow_client_db_attach == 0) {
+               DEBUG(DEBUG_ERR, ("DB Attach to database %s denied by tunable "
+                                 "AllowClientDBAccess == 0\n", db_name));
+               return -1;
+       }
+
        /* dont allow any local clients to attach while we are in recovery mode
         * except for the recovery daemon.
         * allow all attach from the network since these are always from remote
index 9da3cc806562f1601797ecf040b0a5762a6de39c..ef86051cecf2ebd634dfa30b5c4d28dca4d9b1f3 100644 (file)
@@ -68,7 +68,8 @@ static const struct {
        { "UseStatusEvents",     0,  offsetof(struct ctdb_tunable, use_status_events_for_monitoring) },
        { "AllowUnhealthyDBRead", 0,  offsetof(struct ctdb_tunable, allow_unhealthy_db_read) },
        { "StatHistoryInterval",  1,  offsetof(struct ctdb_tunable, stat_history_interval) },
-       { "DeferredAttachTO",  120,  offsetof(struct ctdb_tunable, deferred_attach_timeout) }
+       { "DeferredAttachTO",  120,  offsetof(struct ctdb_tunable, deferred_attach_timeout) },
+       { "AllowClientDBAttach", 1, offsetof(struct ctdb_tunable, allow_client_db_attach) }
 };
 
 /*