r18282@cathode-dark-space: raeburn | 2006-06-29 23:51:48 -0400
ticket: 3964
status: open
New kdb backend operation promote_db, makes a temporary database become the
live database. New function krb5_db_promote invokes it.
ticket: 3964
version_fixed: 1.5
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-5@18300
dc483132-0cff-0310-8789-
dd5450dbe970
krb5_error_code krb5_db_fini ( krb5_context kcontext );
const char * krb5_db_errcode2string ( krb5_context kcontext, long err_code );
krb5_error_code krb5_db_destroy ( krb5_context kcontext, char **db_args );
+krb5_error_code krb5_db_promote ( krb5_context kcontext, char **db_args );
krb5_error_code krb5_db_get_age ( krb5_context kcontext, char *db_name, time_t *t );
krb5_error_code krb5_db_set_option ( krb5_context kcontext, int option, void *value );
krb5_error_code krb5_db_lock ( krb5_context kcontext, int lock_mode );
/*
* Cons up params for the new databases. If we are not in update
- * mode, we dont create tmp file and then move it to final place. As it is dependent on DB type, this is not done
+ * mode, we create an alternate database and then promote it to
+ * be the live db.
*/
newparams = global_params;
if (! update) {
exit_status++;
return;
}
+
+ if (!add_db_arg("temporary")) {
+ com_err(progname, ENOMEM, "computing parameters for database");
+ exit(1);
+ }
}
/*
clean_n_exit:
return;
}
+
+krb5_error_code
+krb5_db_promote(krb5_context kcontext, char **db_args)
+{
+ krb5_error_code status = 0;
+ char *section = NULL;
+ kdb5_dal_handle *dal_handle;
+
+ section = kdb_get_conf_section(kcontext);
+ if (section == NULL) {
+ status = KRB5_KDB_SERVER_INTERNAL_ERR;
+ krb5_set_error_message (kcontext, status,
+ "unable to determine configuration section for realm %s\n",
+ kcontext->default_realm);
+ goto clean_n_exit;
+ }
+
+ if (kcontext->db_context == NULL) {
+ status = kdb_setup_lib_handle(kcontext);
+ if (status) {
+ goto clean_n_exit;
+ }
+ }
+
+ dal_handle = (kdb5_dal_handle *) kcontext->db_context;
+ status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE);
+ if (status) {
+ goto clean_n_exit;
+ }
+
+ status =
+ dal_handle->lib_handle->vftabl.promote_db(kcontext, section, db_args);
+ kdb_unlock_lib_lock(dal_handle->lib_handle, FALSE);
+
+ clean_n_exit:
+ if (section)
+ free(section);
+ return status;
+}
+
krb5_boolean keepold,
krb5_db_entry * db_entry);
+ /* Promote a temporary database to be the live one. */
+ krb5_error_code (*promote_db) (krb5_context context,
+ char *conf_section,
+ char **db_args);
+
} kdb_vftabl;
typedef struct _db_library {