summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-03-27 21:26:56 -0700
committerKarolin Seeger <kseeger@samba.org>2009-03-30 12:02:45 +0200
commite3c9bdeb737a85f30edb1f1ea592c72e66af69f3 (patch)
tree09cdf2f6daa5d1cac25f77143efd5bb85396b1e2
parentbc6a6816ea5332d98b6c49bb8080b9c3524d41a1 (diff)
downloadsamba-e3c9bdeb737a85f30edb1f1ea592c72e66af69f3.tar.gz
samba-e3c9bdeb737a85f30edb1f1ea592c72e66af69f3.tar.xz
samba-e3c9bdeb737a85f30edb1f1ea592c72e66af69f3.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. (cherry picked from commit 10b518592e616ecfaadd829ecd0674a04510b422)
-rw-r--r--source/passdb/pdb_tdb.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/source/passdb/pdb_tdb.c b/source/passdb/pdb_tdb.c
index f60517f7c1e..f8fd11de6b7 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 <jmcd@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 "