krb5 commit: In kdb5_util load, init ulog closer to promote
Greg Hudson
ghudson at MIT.EDU
Wed Feb 5 00:22:06 EST 2014
https://github.com/krb5/krb5/commit/1c0507df449ded505f54383387032db2723bd871
commit 1c0507df449ded505f54383387032db2723bd871
Author: Greg Hudson <ghudson at mit.edu>
Date: Thu Jan 23 10:51:21 2014 -0500
In kdb5_util load, init ulog closer to promote
Always map the ulog with FKCOMMAND, not FKLOAD which reinitializes the
ulog. Don't reinitialize the ulog until just before calling
krb5_db_promote(). Get rid of FKLOAD since it isn't needed any more;
we can just call ulog_init_header() manually.
src/include/kdb_log.h | 1 -
src/kadmin/dbutil/dump.c | 10 +++++++---
src/lib/kdb/kdb_log.c | 7 +------
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/include/kdb_log.h b/src/include/kdb_log.h
index 88f0eb5..16d8af2 100644
--- a/src/include/kdb_log.h
+++ b/src/include/kdb_log.h
@@ -50,7 +50,6 @@ extern "C" {
#define FKPROPLOG 2
#define FKPROPD 3
#define FKCOMMAND 4 /* Includes kadmin.local and kdb5_util */
-#define FKLOAD 5 /* kdb5_util load */
/*
* Default ulog file attributes
diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c
index e180f69..ab96ca7 100644
--- a/src/kadmin/dbutil/dump.c
+++ b/src/kadmin/dbutil/dump.c
@@ -1485,7 +1485,7 @@ load_db(int argc, char **argv)
kdb_log_context *log_ctx;
krb5_boolean db_locked = FALSE, temp_db_created = FALSE;
krb5_boolean verbose = FALSE, update = FALSE, iprop_load = FALSE;
- uint32_t caller = FKCOMMAND, last_sno, last_seconds, last_useconds;
+ uint32_t last_sno, last_seconds, last_useconds;
/* Parse the arguments. */
dbname = global_params.dbname;
@@ -1505,7 +1505,6 @@ load_db(int argc, char **argv)
if (log_ctx && log_ctx->iproprole) {
load = &iprop_version;
iprop_load = TRUE;
- caller = FKLOAD;
} else {
fprintf(stderr, _("Iprop not enabled\n"));
goto error;
@@ -1574,7 +1573,7 @@ load_db(int argc, char **argv)
if (global_params.iprop_enabled &&
ulog_map(util_context, global_params.iprop_logfile,
- global_params.iprop_ulogsize, caller, db5util_db_args)) {
+ global_params.iprop_ulogsize, FKCOMMAND, db5util_db_args)) {
fprintf(stderr, _("Could not open iprop ulog\n"));
goto error;
}
@@ -1648,6 +1647,11 @@ load_db(int argc, char **argv)
}
if (!update) {
+ /* Initialize the ulog header before promoting so we can't leave behind
+ * the pre-load ulog state if we are killed just after promoting. */
+ if (log_ctx != NULL && log_ctx->iproprole)
+ ulog_init_header(util_context);
+
ret = krb5_db_promote(util_context, db5util_db_args);
/* Ignore a not supported error since there is nothing to do about it
* anyway. */
diff --git a/src/lib/kdb/kdb_log.c b/src/lib/kdb/kdb_log.c
index c988dcb..1fd798e 100644
--- a/src/lib/kdb/kdb_log.c
+++ b/src/lib/kdb/kdb_log.c
@@ -415,11 +415,6 @@ ulog_init_header(krb5_context context)
*
* Create and initialize if need be, map as MAP_SHARED.
*
- * - FKLOAD
- *
- * Create if need be, initialize (even if the ulog was already present), map
- * as MAP_SHARED. (Intended for kdb5_util load of iprop dump.)
- *
* - FKCOMMAND
*
* Create and [re-]initialize if need be, size appropriately, map as
@@ -513,7 +508,7 @@ ulog_map(krb5_context context, const char *logname, uint32_t ulogentries,
return KRB5_LOG_CORRUPT;
}
- if (ulog->kdb_hmagic != KDB_ULOG_HDR_MAGIC || caller == FKLOAD) {
+ if (ulog->kdb_hmagic != KDB_ULOG_HDR_MAGIC) {
reset_header(ulog);
if (caller != FKPROPLOG)
ulog_sync_header(ulog);
More information about the cvs-krb5
mailing list