summaryrefslogtreecommitdiffstats
path: root/src/kadmin
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2010-11-06 00:02:13 +0000
committerGreg Hudson <ghudson@mit.edu>2010-11-06 00:02:13 +0000
commit3e0113994526883a9fefad307177c4ff6c292e4a (patch)
treea407b00c1c6e58ed4b17a9eb7e9bd656928e5f06 /src/kadmin
parent097035870531003c02f8d8caed4abf7f680d1a1c (diff)
downloadkrb5-3e0113994526883a9fefad307177c4ff6c292e4a.tar.gz
krb5-3e0113994526883a9fefad307177c4ff6c292e4a.tar.xz
krb5-3e0113994526883a9fefad307177c4ff6c292e4a.zip
After a failed kdb5_util load, make a subsequent load operation work
by removing the remnant temporary files after obtaining a lock. To make this safe, the private contract for temporary DB creation and promotion had to be altered, along with many of the DB2 internal helper functions. ticket: 6814 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24511 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kadmin')
-rw-r--r--src/kadmin/dbutil/dump.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c
index 0e1b609594..96d1a13c47 100644
--- a/src/kadmin/dbutil/dump.c
+++ b/src/kadmin/dbutil/dump.c
@@ -2522,41 +2522,29 @@ load_db(argc, argv)
}
}
else {
- /*
- * Initialize the database.
- */
- if ((kret = krb5_db_open(kcontext, db5util_db_args,
- KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_ADMIN))) {
+ /* Initialize the database. */
+ kret = krb5_db_open(kcontext, db5util_db_args,
+ KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_ADMIN);
+ if (kret) {
const char *emsg = krb5_get_error_message(kcontext, kret);
fprintf(stderr, "%s: %s\n", progname, emsg);
krb5_free_error_message (kcontext, emsg);
exit_status++;
goto error;
}
- }
-
- /*
- * If an update restoration, make sure the db is left unusable if
- * the update fails.
- */
- if ((kret = krb5_db_lock(kcontext,
- (flags & FLAG_UPDATE) ?
- KRB5_DB_LOCKMODE_PERMANENT :
- KRB5_DB_LOCKMODE_EXCLUSIVE))) {
- /*
- * Ignore a not supported error since there is nothing to do about it
- * anyway.
- */
- if (kret != KRB5_PLUGIN_OP_NOTSUPP) {
+ /* Make sure the db is left unusable if the update fails, if the db
+ * supports locking. */
+ kret = krb5_db_lock(kcontext, KRB5_DB_LOCKMODE_PERMANENT);
+ if (kret == 0)
+ db_locked = 1;
+ else if (kret != KRB5_PLUGIN_OP_NOTSUPP) {
fprintf(stderr, "%s: %s while permanently locking database\n",
progname, error_message(kret));
exit_status++;
goto error;
}
}
- else
- db_locked = 1;
if (log_ctx && log_ctx->iproprole) {
if (add_update)