* loadv4.c: create empty policy database after loading V4 dump file
authorBarry Jaspan <bjaspan@mit.edu>
Thu, 1 Aug 1996 19:08:22 +0000 (19:08 +0000)
committerBarry Jaspan <bjaspan@mit.edu>
Thu, 1 Aug 1996 19:08:22 +0000 (19:08 +0000)
* dumpv4.c (dump_v4db): use global_params.stash_file

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

src/kadmin/dbutil/ChangeLog
src/kadmin/dbutil/dumpv4.c
src/kadmin/dbutil/loadv4.c

index 8c8aa4ce2a1bef1518f8f43484b811465038959c..82e18f5938cf7532b4a589f0bc9d36e959286144 100644 (file)
@@ -1,5 +1,9 @@
 Thu Aug  1 14:34:51 1996  Barry Jaspan  <bjaspan@DUN-DUN-NOODLES>
 
+       * loadv4.c: create empty policy database after loading V4 dump file
+
+       * dumpv4.c (dump_v4db): use global_params.stash_file
+
        * Makefile.in, Makefile.ov, configure.in, dump.c: add support for
         dump/load of OV*Secure-compatible format.
 
index a51626db3491d3c89e4eb98f91854637a93d0d58..8c85e8f1b453fc8f7d83d342c29cd4708e1c806d 100644 (file)
@@ -36,6 +36,7 @@
 #include <kdc.h>
 
 #include <stdio.h>
+#include <kadm5/admin.h>
 #include "kdb5_util.h"
 
 struct dump_record {
@@ -54,6 +55,7 @@ extern krb5_principal master_princ;
 extern krb5_boolean dbactive;
 extern int exit_status;
 extern krb5_context util_context;
+extern kadm5_config_params global_params;
 
 void update_ok_file();
 
@@ -352,7 +354,8 @@ int handle_keys(arg)
     krb5_use_enctype(util_context, &master_encblock, DEFAULT_KDC_ENCTYPE);
     if (retval = krb5_db_fetch_mkey(util_context, master_princ, 
                                    &master_encblock, 0,
-                                   0, (char *) NULL, 0, &master_keyblock)) {
+                                   0, global_params.stash_file, 0,
+                                   &master_keyblock)) { 
        com_err(arg->comerr_name, retval, "while reading master key");
        exit(1);
     }
index a1d37edc77e2bf3c8cd7c439315a8a828ef73554..f4e54a27805f754357b0af4c959d027caf54833d 100644 (file)
@@ -41,8 +41,7 @@ static char *v4_mkeyfile = "/.k";
 
 #include "k5-int.h"
 #include "com_err.h"
-#include "adm.h"
-#include "adm_proto.h"
+#include <kadm5/admin.h>
 #include <stdio.h>
 
 #include <netinet/in.h>                        /* ntohl */
@@ -155,6 +154,8 @@ char *argv[];
     char *stash_file = (char *) NULL;
     krb5_realm_params *rparams;
     int        persist, op_ind;
+    kadm5_config_params newparams;
+    extern kadm5_config_params global_params;
 
     krb5_init_context(&context);
 
@@ -426,6 +427,33 @@ master key name '%s'\n",
     (void) krb5_finish_key(context, &master_encblock);
     (void) krb5_finish_random_key(context, &master_encblock, &rblock.rseed);
     memset((char *)master_keyblock.contents, 0, master_keyblock.length);
+
+    /*
+     * Cons up config params for new policy database (which will be
+     * empty).  The policy dbname keys off the dbname.
+     */
+    newparams = global_params;
+    newparams.mask &= ~(KADM5_CONFIG_ADBNAME | KADM5_CONFIG_ADB_LOCKFILE);
+    newparams.dbname = dbname;
+    newparams.mask |= KADM5_CONFIG_DBNAME;
+    if (retval = kadm5_get_config_params(context, NULL, NULL, &newparams,
+                                      &newparams)) {
+        com_err(PROGNAME, retval, "while retrieiving configuration "
+                "parameters");
+        return;
+    }
+    /*
+     * Always create the policy db, even if we are not loading a dump
+     * file with policy info, because they are probably loading an old
+     * dump intending to use it with the new kadm5 system (ie: using
+     * load as create).
+     */
+    if (retval = osa_adb_create_policy_db(&newparams)) {
+        com_err(PROGNAME, retval, "while creating policy database");
+        kadm5_free_config_params(context, &newparams);
+        return;
+    }
+
     krb5_free_context(context);
     return;
 }