Fix bug #6195 - Migrating from 3.0.x to 3.3.x can fail to update passdb.tdb correctly...
authorJeremy Allison <jra@samba.org>
Fri, 27 Mar 2009 19:09:51 +0000 (12:09 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 27 Mar 2009 19:09:51 +0000 (12:09 -0700)
Clustered setups should have only ever used
the unsigned version of TDB_DATA in the
first place so they can't be in this mess :-).
Just do the normal upgrade in the clustered case.
Jeremy.

source/include/dbwrap.h
source/lib/dbwrap.c
source/passdb/pdb_tdb.c

index 1f388165dba2aa42064df5d91e7e5bd12a3ac369..329c191af57c5f593dcf11f8e03d7c91e0524bea 100644 (file)
@@ -49,6 +49,8 @@ struct db_context {
        bool persistent;
 };
 
+bool db_is_local(const char *name);
+
 struct db_context *db_open(TALLOC_CTX *mem_ctx,
                           const char *name,
                           int hash_size, int tdb_flags,
index 7fe1631bff040595e8b5d4b7b31d555742fcf62c..00182aa15e3e2b1a4ad846e51b1bddd243596d0b 100644 (file)
@@ -42,6 +42,33 @@ static int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
        return 0;
 }
 
+bool db_is_local(const char *name)
+{
+#ifdef CLUSTER_SUPPORT
+       const char *sockname = lp_ctdbd_socket();
+
+       if(!sockname || !*sockname) {
+               sockname = CTDB_PATH;
+       }
+
+       if (lp_clustering() && socket_exist(sockname)) {
+               const char *partname;
+               /* ctdb only wants the file part of the name */
+               partname = strrchr(name, '/');
+               if (partname) {
+                       partname++;
+               } else {
+                       partname = name;
+               }
+               /* allow ctdb for individual databases to be disabled */
+               if (lp_parm_bool(-1, "ctdb", partname, True)) {
+                       return false;
+               }
+       }
+#endif
+       return true;
+}
+
 /**
  * If you need transaction support use db_open_trans()
  */
index 9928768a2195219abe6a139551a1d550e1901f82..f60517f7c1efccfd4d407ef568dac5c25337153b 100644 (file)
@@ -921,7 +921,8 @@ static bool tdbsam_convert(struct db_context **pp_db, const char *name, int32 fr
        struct db_context *db = NULL;
        int ret;
 
-       if (!tdbsam_convert_backup(name, pp_db)) {
+       /* We only need the update backup for local db's. */
+       if (db_is_local(name) && !tdbsam_convert_backup(name, pp_db)) {
                DEBUG(0, ("tdbsam_convert: Could not backup %s\n", name));
                return false;
        }