Add backwards compatibility for version numbers 1.0 and 2.0 of the
authorTheodore Tso <tytso@mit.edu>
Tue, 4 Oct 1994 19:11:51 +0000 (19:11 +0000)
committerTheodore Tso <tytso@mit.edu>
Tue, 4 Oct 1994 19:11:51 +0000 (19:11 +0000)
database entry.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4436 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kdb/ChangeLog
src/lib/kdb/kdb_compat.h [new file with mode: 0644]
src/lib/kdb/kdb_dbm.c

index 570f2fd5615f566b10ff31c2bd9731b44d19bb2d..03af33eabd766ac74b949beeca57af69fc4d5a0c 100644 (file)
@@ -1,3 +1,8 @@
+Tue Oct  4 15:08:03 1994  Theodore Y. Ts'o  (tytso@dcl)
+
+       * kdb_dbm.c (decode_princ_contents): Add backwards compatibility
+               for version numbers 1.0 and 2.0.  
+
 Mon Oct  3 22:47:49 1994  Theodore Y. Ts'o  (tytso@dcl)
 
        * kdb_dbm.c (decode_princ_contents): Force an incompatible version
diff --git a/src/lib/kdb/kdb_compat.h b/src/lib/kdb/kdb_compat.h
new file mode 100644 (file)
index 0000000..3873f48
--- /dev/null
@@ -0,0 +1,51 @@
+
+/*
+ * Note --- this structure cannot be modified without changing the
+ * database version number in libkdb.a
+ */
+typedef struct _old_krb5_db_entry {
+    old_krb5_principal principal;
+    old_krb5_encrypted_keyblock key;
+    krb5_kvno kvno;
+    krb5_deltat        max_life;
+    krb5_deltat        max_renewable_life;
+    krb5_kvno mkvno;                   /* master encryption key vno */
+    
+    krb5_timestamp expiration;         /* This is when the client expires */
+    krb5_timestamp pw_expiration;      /* This is when its password does */
+    krb5_timestamp last_pwd_change;    /* Last time of password change  */
+    krb5_timestamp last_success;       /* Last successful password */
+    
+    krb5_timestamp last_failed;                /* Last failed password attempt */
+    krb5_kvno fail_auth_count;                 /* # of failed password attempts */
+    
+    old_krb5_principal mod_name;
+    krb5_timestamp mod_date;
+    krb5_flags attributes;
+    krb5_int32 salt_type:8,
+              salt_length:24;
+    krb5_octet *salt;
+    krb5_encrypted_keyblock alt_key;
+    krb5_int32 alt_salt_type:8,
+              alt_salt_length:24;
+    krb5_octet *alt_salt;
+    
+    krb5_int32 expansion[8];
+} old_krb5_db_entry;
+
+typedef struct _old_krb5_encrypted_keyblock {
+    krb5_keytype keytype;
+    int length;
+    krb5_octet *contents;
+} old_krb5_encrypted_keyblock;
+
+typedef struct old_krb5_principal_data {
+    krb5_magic magic;
+    krb5_data realm;
+    krb5_data *data;           /* An array of strings */
+    krb5_int32 length;
+    krb5_int32 type;
+} old_krb5_principal_data;
+
+typedef        old_krb5_principal_data *old_krb5_principal;
+
index 2a00a1dff678b8b74f8a8d97d925a156d6917f0b..b9cb8f3218b6d05114a4c3d2fe62c0cb0a1764a8 100644 (file)
 #include <fcntl.h>
 #endif
 
+#define OLD_COMPAT_VERSION_1
+
+#ifdef OLD_COMPAT_VERSION_1
+#include "kdb_compat.h"
+#endif
+
 #define KRB5_DBM_MAX_RETRY 5
 
 /* exclusive or shared lock flags */
@@ -599,6 +605,50 @@ krb5_db_entry *entry;
        minor_version = *nextloc;
        nextloc++; sizeleft--;
     }
+#ifdef OLD_COMPAT_VERSION_1
+    if (major_version == 0 || major_version == 1) {
+       old_krb5_db_entry old_entry;
+
+       /*
+        * Copy in structure to old-style structure, and then copy it
+        * to the new structure.
+        */
+       sizeleft -= sizeof(old_entry);
+       if (sizeleft < 0) 
+           return KRB5_KDB_TRUNCATED_RECORD;
+
+       memcpy((char *) &old_entry, nextloc, sizeof(old_entry));
+       nextloc += sizeof(old_entry);   /* Skip past structure */
+       
+       entry->key.keytype = old_entry.key.keytype;
+       entry->key.length = old_entry.key.length;
+
+       entry->kvno = old_entry.kvno;
+       entry->max_life = old_entry.max_life;
+       entry->max_renewable_life = old_entry.max_renewable_life;
+       entry->mkvno = old_entry.mkvno;
+       
+       entry->expiration = old_entry.expiration;
+       entry->pw_expiration = old_entry.pw_expiration;
+       entry->last_pwd_change = old_entry.last_pwd_change;
+       entry->last_success = old_entry.last_success;
+    
+       entry->last_failed = old_entry.last_failed;
+       entry->fail_auth_count = old_entry.fail_auth_count;
+    
+       entry->mod_date = old_entry.mod_date;
+       entry->attributes = old_entry.attributes;
+       entry->salt_type = old_entry.salt_type;
+       entry->salt_length = old_entry.salt_length;
+       
+       entry->alt_key.keytype = old_entry.alt_key.keytype;
+       entry->alt_key.length = old_entry.alt_key.length;
+       entry->alt_salt_type = old_entry.alt_salt_type;
+       entry->alt_salt_length = old_entry.alt_salt_length;
+
+       goto resume_processing;
+    }
+#endif
     if (major_version != 2)
        return KRB5_KDB_BAD_VERSION;
     
@@ -607,6 +657,12 @@ krb5_db_entry *entry;
        return KRB5_KDB_TRUNCATED_RECORD;
 
     memcpy((char *) entry, nextloc, sizeof(*entry));
+    nextloc += sizeof(*entry); /* Skip past structure */
+
+#ifdef OLD_COMPAT_VERSION_1
+resume_processing:
+#endif
+    
     /*
      * These values should be zero if they are not in use, but just in
      * case, we clear them to make sure nothing bad happens if we need
@@ -618,7 +674,6 @@ krb5_db_entry *entry;
     entry->alt_salt = 0;
     entry->key.contents = 0;
     entry->alt_key.contents = 0;
-    nextloc += sizeof(*entry); /* Skip past structure */
 
     /*
      * Get the principal name for the entry (stored as a string which