diff options
author | Jeremy Allison <jra@samba.org> | 2009-03-27 21:29:37 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-03-27 21:29:37 -0700 |
commit | 0b890ae19a6e9dad9bdff248ada3fdee9416ab96 (patch) | |
tree | 1261ce6d78089eb9472a911ca1ae202404382642 /source3 | |
parent | ee22c417f3ae156522151815605300c703eeb664 (diff) | |
download | samba-0b890ae19a6e9dad9bdff248ada3fdee9416ab96.tar.gz samba-0b890ae19a6e9dad9bdff248ada3fdee9416ab96.tar.bz2 samba-0b890ae19a6e9dad9bdff248ada3fdee9416ab96.zip |
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.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/passdb/pdb_tdb.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index fb40b27476..1060733df4 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/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 <jmcd@us.ibm.com> 2005 * @@ -38,7 +38,9 @@ static int tdbsam_debug_level = DBGC_ALL; #endif #define TDBSAM_VERSION 4 /* Most recent TDBSAM version */ +#define TDBSAM_MINOR_VERSION 0 /* 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 @@ -359,6 +361,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")); return false; @@ -382,6 +390,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 */ @@ -404,6 +413,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 */ @@ -412,7 +427,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 @@ -437,6 +454,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 */ @@ -446,9 +469,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 " |