The branch, v3-2-test has been updated
       via  10b518592e616ecfaadd829ecd0674a04510b422 (commit)
      from  f4e68b09a6ba30d968bccfad8bf6b67b4456b111 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 10b518592e616ecfaadd829ecd0674a04510b422
Author: Jeremy Allison <j...@samba.org>
Date:   Fri Mar 27 21:26:56 2009 -0700

    Fix the problem of 3.0.x passdb databases being version
    3 but using a different hash calculation than 3.2.x passwd
    databases (also version 3). Introduces a minor version
    number.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/passdb/pdb_tdb.c |   48 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 43 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c
index f60517f..f8fd11d 100644
--- a/source/passdb/pdb_tdb.c
+++ b/source/passdb/pdb_tdb.c
@@ -4,7 +4,7 @@
  * Copyright (C) Andrew Tridgell   1992-1998
  * Copyright (C) Simo Sorce        2000-2003
  * Copyright (C) Gerald Carter     2000-2006
- * Copyright (C) Jeremy Allison    2001
+ * Copyright (C) Jeremy Allison    2001-2009
  * Copyright (C) Andrew Bartlett   2002
  * Copyright (C) Jim McDonough <j...@us.ibm.com> 2005
  * 
@@ -38,7 +38,9 @@ static int tdbsam_debug_level = DBGC_ALL;
 #endif
 
 #define TDBSAM_VERSION 3       /* Most recent TDBSAM version */
+#define TDBSAM_MINOR_VERSION   1       /* Most recent TDBSAM minor version */
 #define TDBSAM_VERSION_STRING  "INFO/version"
+#define TDBSAM_MINOR_VERSION_STRING    "INFO/minor_version"
 #define PASSDB_FILE_NAME       "passdb.tdb"
 #define USERPREFIX             "USER_"
 #define USERPREFIX_LEN         5
@@ -953,6 +955,12 @@ static bool tdbsam_convert(struct db_context **pp_db, 
const char *name, int32 fr
                goto cancel;
        }
 
+       if (dbwrap_store_int32(db, TDBSAM_MINOR_VERSION_STRING,
+                              TDBSAM_MINOR_VERSION) != 0) {
+               DEBUG(0, ("tdbsam_convert: Could not store tdbsam minor 
version\n"));
+               goto cancel;
+       }
+
        if (db->transaction_commit(db) != 0) {
                DEBUG(0, ("tdbsam_convert: Could not commit transaction\n"));
                goto cancel;
@@ -976,6 +984,7 @@ static bool tdbsam_convert(struct db_context **pp_db, const 
char *name, int32 fr
 static bool tdbsam_open( const char *name )
 {
        int32   version;
+       int32   minor_version;
 
        /* check if we are already open */
 
@@ -998,6 +1007,12 @@ static bool tdbsam_open( const char *name )
                version = 0;    /* Version not found, assume version 0 */
        }
 
+       /* Get the minor version */
+       minor_version = dbwrap_fetch_int32(db_sam, TDBSAM_MINOR_VERSION_STRING);
+       if (minor_version == -1) {
+               minor_version = 0; /* Minor version not found, assume 0 */
+       }
+
        /* Compare the version */
        if (version > TDBSAM_VERSION) {
                /* Version more recent than the latest known */
@@ -1006,7 +1021,9 @@ static bool tdbsam_open( const char *name )
                return false;
        }
 
-       if ( version < TDBSAM_VERSION ) {
+       if ( version < TDBSAM_VERSION ||
+                       (version == TDBSAM_VERSION &&
+                        minor_version < TDBSAM_MINOR_VERSION) ) {
                /*
                 * Ok - we think we're going to have to convert.
                 * Due to the backup process we now must do to
@@ -1031,6 +1048,12 @@ static bool tdbsam_open( const char *name )
                        version = 0;    /* Version not found, assume version 0 
*/
                }
 
+               /* Re-check the minor version */
+               minor_version = dbwrap_fetch_int32(db_sam, 
TDBSAM_MINOR_VERSION_STRING);
+               if (minor_version == -1) {
+                       minor_version = 0; /* Minor version not found, assume 0 
*/
+               }
+
                /* Compare the version */
                if (version > TDBSAM_VERSION) {
                        /* Version more recent than the latest known */
@@ -1040,9 +1063,24 @@ static bool tdbsam_open( const char *name )
                        return false;
                }
 
-               if ( version < TDBSAM_VERSION ) {
-                       DEBUG(1, ("tdbsam_open: Converting version %d database 
to "
-                                 "version %d.\n", version, TDBSAM_VERSION));
+               if ( version < TDBSAM_VERSION ||
+                               (version == TDBSAM_VERSION &&
+                                minor_version < TDBSAM_MINOR_VERSION) ) {
+                       /*
+                        * Note that minor versions we read that are greater
+                        * than the current minor version we have hard coded
+                        * are assumed to be compatible if they have the same
+                        * major version. That allows previous versions of the
+                        * passdb code that don't know about minor versions to
+                        * still use this database. JRA.
+                        */
+
+                       DEBUG(1, ("tdbsam_open: Converting version %d.%d 
database to "
+                                 "version %d.%d.\n",
+                                       version,
+                                       minor_version,
+                                       TDBSAM_VERSION,
+                                       TDBSAM_MINOR_VERSION));
 
                        if ( !tdbsam_convert(&db_sam, name, version) ) {
                                DEBUG(0, ("tdbsam_open: Error when trying to 
convert "


-- 
Samba Shared Repository

Reply via email to