* dump.c: Add a new dump version, r1_3_version, and make it the
authorTom Yu <tlyu@mit.edu>
Sat, 1 Jul 2000 00:31:06 +0000 (00:31 +0000)
committerTom Yu <tlyu@mit.edu>
Sat, 1 Jul 2000 00:31:06 +0000 (00:31 +0000)
default; it will be used in krb5-1.3 and will permit a principal's
kadm5 data to be dumped.  This is an interim measure until we
redesign the dump format somewhat.

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

src/kadmin/dbutil/ChangeLog
src/kadmin/dbutil/dump.c

index 1aa379e5999065d703b7f3e3fe0fba7d14d55b74..01c2f5e8ed5cf156921315359b3235e0b1825e53 100644 (file)
@@ -1,3 +1,10 @@
+2000-06-30  Tom Yu  <tlyu@mit.edu>
+
+       * dump.c: Add a new dump version, r1_3_version, and make it the
+       default; it will be used in krb5-1.3 and will permit a principal's
+       kadm5 data to be dumped.  This is an interim measure until we
+       redesign the dump format somewhat.
+
 2000-05-31  Wilfredo Sanchez  <tritan@mit.edu>
 
        * ovload.c: Check for existance of <memory.h>.
index 4378e310c9369dabaf7ad1908d3518f0f95fe7cd..49e49f727212fe80990bb1127fd0bf07c86292a2 100644 (file)
@@ -74,8 +74,16 @@ static krb5_error_code dump_k5beta_iterator PROTOTYPE((krb5_pointer,
                                                       krb5_db_entry *));
 static krb5_error_code dump_k5beta6_iterator PROTOTYPE((krb5_pointer,
                                                        krb5_db_entry *));
+static krb5_error_code dump_k5beta6_iterator_ext PROTOTYPE((krb5_pointer,
+                                                           krb5_db_entry *,
+                                                           int));
 static krb5_error_code dump_k5beta7_princ PROTOTYPE((krb5_pointer,
                                                     krb5_db_entry *));
+static krb5_error_code dump_k5beta7_princ_ext PROTOTYPE((krb5_pointer,
+                                                        krb5_db_entry *,
+                                                        int));
+static krb5_error_code dump_k5beta7_princ_withpolicy
+                       PROTOTYPE((krb5_pointer, krb5_db_entry *));
 static krb5_error_code dump_ov_princ PROTOTYPE((krb5_pointer,
                                                krb5_db_entry *));
 static void dump_k5beta7_policy PROTOTYPE((void *, osa_policy_ent_t));
@@ -141,6 +149,16 @@ dump_version ov_version = {
      process_ov_record,
 };
 
+dump_version r1_3_version = {
+     "Kerberos version 5 release 1.3",
+     "kdb5_util load_dump version 5\n",
+     0,
+     0,
+     dump_k5beta7_princ_withpolicy,
+     dump_k5beta7_policy,
+     process_k5beta7_record,
+};
+
 /* External data */
 extern char            *current_dbname;
 extern krb5_boolean    dbactive;
@@ -220,6 +238,7 @@ static const char dfile_err_fmt[] = "%s: cannot open %s (%s)\n";
 
 static const char oldoption[] = "-old";
 static const char b6option[] = "-b6";
+static const char b7option[] = "-b7";
 static const char verboseoption[] = "-verbose";
 static const char updateoption[] = "-update";
 static const char hashoption[] = "-hash";
@@ -633,6 +652,15 @@ static krb5_error_code
 dump_k5beta6_iterator(ptr, entry)
     krb5_pointer       ptr;
     krb5_db_entry      *entry;
+{
+    return dump_k5beta6_iterator_ext(ptr, entry, 0);
+}
+
+static krb5_error_code
+dump_k5beta6_iterator_ext(ptr, entry, kadm)
+    krb5_pointer       ptr;
+    krb5_db_entry      *entry;
+    int                        kadm;
 {
     krb5_error_code    retval;
     struct dump_args   *arg;
@@ -703,7 +731,10 @@ dump_k5beta6_iterator(ptr, entry)
              */
             switch (tlp->tl_data_type) {
             case KRB5_TL_KADM_DATA:
-                 skip++;
+                 if (kadm)
+                     counter++;
+                 else
+                     skip++;
                  break;
             default:
                  counter++;
@@ -731,7 +762,7 @@ dump_k5beta6_iterator(ptr, entry)
                    entry->fail_auth_count);
            /* Pound out tagged data. */
            for (tlp = entry->tl_data; tlp; tlp = tlp->tl_data_next) {
-               if (tlp->tl_data_type == KRB5_TL_KADM_DATA)
+               if (tlp->tl_data_type == KRB5_TL_KADM_DATA && !kadm)
                     continue; /* see above, [krb5-admin/89] */
 
                fprintf(arg->ofile, "%d\t%d\t",
@@ -796,6 +827,15 @@ static krb5_error_code
 dump_k5beta7_princ(ptr, entry)
     krb5_pointer       ptr;
     krb5_db_entry      *entry;
+{
+    return dump_k5beta7_princ_ext(ptr, entry, 0);
+}
+
+static krb5_error_code
+dump_k5beta7_princ_ext(ptr, entry, kadm)
+    krb5_pointer       ptr;
+    krb5_db_entry      *entry;
+    int                        kadm;
 {
      krb5_error_code retval;
      struct dump_args *arg;
@@ -826,7 +866,7 @@ dump_k5beta7_princ(ptr, entry)
          /* save the callee from matching the name again */
          tmp_nnames = arg->nnames;
          arg->nnames = 0;
-         retval = dump_k5beta6_iterator(ptr, entry);
+         retval = dump_k5beta6_iterator_ext(ptr, entry, kadm);
          arg->nnames = tmp_nnames;
      }
 
@@ -834,6 +874,14 @@ dump_k5beta7_princ(ptr, entry)
      return retval;
 }
 
+static krb5_error_code
+dump_k5beta7_princ_withpolicy(ptr, entry)
+    krb5_pointer       ptr;
+    krb5_db_entry      *entry;
+{
+    return dump_k5beta7_princ_ext(ptr, entry, 1);
+}
+
 void dump_k5beta7_policy(void *data, osa_policy_ent_t entry)
 {
      struct dump_args *arg;
@@ -953,7 +1001,7 @@ static krb5_error_code dump_ov_princ(krb5_pointer ptr, krb5_db_entry *kdb)
 
 /*
  * usage is:
- *     dump_db [-old] [-b6] [-ov] [-verbose] [filename [principals...]]
+ *     dump_db [-old] [-b6] [-b7] [-ov] [-verbose] [filename [principals...]]
  */
 void
 dump_db(argc, argv)
@@ -980,7 +1028,7 @@ dump_db(argc, argv)
        programname = strrchr(argv[0], (int) '/') + 1;
     ofile = (char *) NULL;
     error = 0;
-    dump = &beta7_version;
+    dump = &r1_3_version;
     arglist.verbose = 0;
     new_mkey_file = 0;
     mkey_convert = 0;
@@ -993,6 +1041,8 @@ dump_db(argc, argv)
             dump = &old_version;
        else if (!strcmp(argv[aindex], b6option))
             dump = &beta6_version;
+       else if (!strcmp(argv[aindex], b7option))
+            dump = &beta7_version;
        else if (!strcmp(argv[aindex], ovoption))
             dump = &ov_version;
        else if (!strcmp(argv[aindex], verboseoption))
@@ -2008,7 +2058,8 @@ restore_dump(programname, kcontext, dumpfile, f, verbose, dump, pol_db)
 }
 
 /*
- * Usage: load_db [-old] [-ov] [-b6] [-verbose] [-update] [-hash] filename
+ * Usage: load_db [-old] [-ov] [-b6] [-b7] [-verbose] [-update] [-hash]
+ *             filename
  */
 void
 load_db(argc, argv)
@@ -2052,6 +2103,8 @@ load_db(argc, argv)
             load = &old_version;
        else if (!strcmp(argv[aindex], b6option))
             load = &beta6_version;
+       else if (!strcmp(argv[aindex], b7option))
+            load = &beta7_version;
        else if (!strcmp(argv[aindex], ovoption))
             load = &ov_version;
        else if (!strcmp(argv[aindex], verboseoption))
@@ -2129,6 +2182,8 @@ load_db(argc, argv)
              load = &beta6_version;
         else if (strcmp(buf, beta7_version.header) == 0)
              load = &beta7_version;
+        else if (strcmp(buf, r1_3_version.header) == 0)
+             load = &r1_3_version;
         else if (strncmp(buf, ov_version.header,
                          strlen(ov_version.header)) == 0)
              load = &ov_version;