summaryrefslogtreecommitdiffstats
path: root/src/lib/kdb
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1994-10-04 19:11:51 +0000
committerTheodore Tso <tytso@mit.edu>1994-10-04 19:11:51 +0000
commit4eb90a1bdbe8577d1ee8b5c614a4174826b53157 (patch)
tree3f9b80da6488fd9fc0533096fd5b6888bf2b2f51 /src/lib/kdb
parent18f215983b8f8fad8ccb9eb75ea06bd49bede2f3 (diff)
downloadkrb5-4eb90a1bdbe8577d1ee8b5c614a4174826b53157.tar.gz
krb5-4eb90a1bdbe8577d1ee8b5c614a4174826b53157.tar.xz
krb5-4eb90a1bdbe8577d1ee8b5c614a4174826b53157.zip
Add backwards compatibility for version numbers 1.0 and 2.0 of the
database entry. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4436 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/kdb')
-rw-r--r--src/lib/kdb/ChangeLog5
-rw-r--r--src/lib/kdb/kdb_compat.h51
-rw-r--r--src/lib/kdb/kdb_dbm.c57
3 files changed, 112 insertions, 1 deletions
diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog
index 570f2fd561..03af33eabd 100644
--- a/src/lib/kdb/ChangeLog
+++ b/src/lib/kdb/ChangeLog
@@ -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
index 0000000000..3873f48fc4
--- /dev/null
+++ b/src/lib/kdb/kdb_compat.h
@@ -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;
+
diff --git a/src/lib/kdb/kdb_dbm.c b/src/lib/kdb/kdb_dbm.c
index 2a00a1dff6..b9cb8f3218 100644
--- a/src/lib/kdb/kdb_dbm.c
+++ b/src/lib/kdb/kdb_dbm.c
@@ -38,6 +38,12 @@
#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