ltdb_server: let ctdbd refuse attach with CLEAR_IF_FIRST for persistent dbs
authorGregor Beck <gbeck@sernet.de>
Thu, 21 Jun 2012 08:27:45 +0000 (10:27 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 24 May 2013 12:22:17 +0000 (14:22 +0200)
server/ctdb_ltdb_server.c

index 0426d96bdbc584284d500c94996ba4f5d7efb2bc..edb077deb4e5a1ada00571cf66fdf6e705183d60 100644 (file)
@@ -1061,6 +1061,14 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        struct ctdb_db_context *db;
        struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
        struct ctdb_client *client = NULL;
+       bool clear_if_first = (tdb_flags & TDB_CLEAR_IF_FIRST);
+
+       if (persistent == clear_if_first) {
+               DEBUG(DEBUG_ERR, ("ERROR: DB Attach to %s: %s\n", db_name, persistent
+                                 ? "CLEAR_IF_FIRST is not allowed for persistent databases"
+                                 : "non-persistent databases need CLEAR_IF_FIRST"));
+               return -1;
+       }
 
        if (ctdb->tunable.allow_client_db_attach == 0) {
                DEBUG(DEBUG_ERR, ("DB Attach to database %s denied by tunable "