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 {