Udiff kdb5_create.c
--- /net/etna.eng/build7/semery/mit2/webrev/usr/src/cmd/krb5/kadmin/dbutil/kdb5_create.c- Wed Sep 8 16:59:48 2004
+++ kdb5_create.c Wed Sep 8 13:41:04 2004
@@ -1,11 +1,11 @@
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "@(#)kdb5_create.c 1.9 04/09/08 SMI"
+#pragma ident "@(#)kdb5_create.c 1.8 04/05/04 SMI"
/*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*
* Openvision retains the copyright to derivative works of
@@ -84,10 +84,11 @@
#include <kadm5/admin.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <kadm5/adb.h>
#include <libintl.h>
+#include "kdb5_util.h"
enum ap_op {
NULL_KEY, /* setup null keys */
MASTER_KEY, /* use master key as new key */
TGT_KEY /* special handling for tgt key */
@@ -190,10 +191,11 @@
char *pw_str = 0;
unsigned int pw_size = 0;
int do_stash = 0;
krb5_int32 crflags = KRB5_KDB_CREATE_BTREE;
krb5_data pwd, seed;
+ kdb_log_context *log_ctx;
krb5_keyblock mkey;
krb5_data master_salt = { 0, NULL };
if (strrchr(argv[0], '/'))
argv[0] = strrchr(argv[0], '/')+1;
@@ -217,10 +219,12 @@
rblock.expiration = global_params.expiration;
rblock.flags = global_params.flags;
rblock.nkslist = global_params.num_keysalts;
rblock.kslist = global_params.keysalts;
+ log_ctx = util_context->kdblog_context;
+
retval = krb5_db_set_name(util_context, global_params.dbname);
if (!retval)
retval = EEXIST;
if (retval == EEXIST || retval == EACCES || retval == EPERM) {
@@ -345,10 +349,37 @@
global_params.dbname);
exit_status++;
goto cleanup;
}
+ if (log_ctx && log_ctx->iproprole) {
+ if (retval = ulog_map(util_context, &global_params, FKCOMMAND)) {
+ com_err(argv[0], retval,
+ gettext("while creating update log"));
+ exit_status++;
+ goto cleanup;
+ }
+
+ /*
+ * We're reinitializing the update log in case one already
+ * existed, but this should never happen.
+ */
+ (void) memset(log_ctx->ulog, 0, sizeof (kdb_hlog_t));
+
+ log_ctx->ulog->kdb_hmagic = KDB_HMAGIC;
+ log_ctx->ulog->db_version_num = KDB_VERSION;
+ log_ctx->ulog->kdb_state = KDB_STABLE;
+ log_ctx->ulog->kdb_block = ULOG_BLOCK;
+
+ /*
+ * Since we're creating a new db we shouldn't worry about
+ * adding the initial principals since any slave might as well
+ * do full resyncs from this newly created db.
+ */
+ log_ctx->iproprole = IPROP_NULL;
+ }
+
if ((retval = add_principal(util_context,
master_princ, MASTER_KEY, &rblock, &mkey)) ||
(retval = add_principal(util_context,
&tgt_princ, TGT_KEY, &rblock, &mkey))) {
(void) krb5_db_fini(util_context);