Make kadm5_lock() and unlock work, and add kadmin commands for them.
The libkadm5 functions hdb_open() and close around all HDB ops. This meant the previous implementation of kadm5_lock() and unlock would always result in a core dump. Now we hdb_open() for write in kadm5_lock() and hdb_close() in kadm5_unlock(), with all kadm5_s_*() functions now not opening nor closing the HDB when the server context keep_open flag is set. Also, there's now kadmin(8) lock and unlock commands. These are there primarily as a way to test the kadm5_lock()/unlock() operations, but MIT's kadmin.local also has lock/unlock commands, and these can be useful for scripting (though they require much care).
This commit is contained in:
@@ -131,11 +131,14 @@ kadm5_s_create_principal_with_key(void *server_handle,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = context->db->hdb_open(context->context, context->db, O_RDWR, 0);
|
||||
if(ret)
|
||||
goto out;
|
||||
if (!context->keep_open) {
|
||||
ret = context->db->hdb_open(context->context, context->db, O_RDWR, 0);
|
||||
if(ret)
|
||||
goto out;
|
||||
}
|
||||
ret = context->db->hdb_store(context->context, context->db, 0, &ent);
|
||||
context->db->hdb_close(context->context, context->db);
|
||||
if (!context->keep_open)
|
||||
context->db->hdb_close(context->context, context->db);
|
||||
if (ret)
|
||||
goto out;
|
||||
kadm5_log_create (context, &ent.entry);
|
||||
@@ -183,11 +186,14 @@ kadm5_s_create_principal(void *server_handle,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = context->db->hdb_open(context->context, context->db, O_RDWR, 0);
|
||||
if(ret)
|
||||
goto out;
|
||||
if (!context->keep_open) {
|
||||
ret = context->db->hdb_open(context->context, context->db, O_RDWR, 0);
|
||||
if(ret)
|
||||
goto out;
|
||||
}
|
||||
ret = context->db->hdb_store(context->context, context->db, 0, &ent);
|
||||
context->db->hdb_close(context->context, context->db);
|
||||
if (!context->keep_open)
|
||||
context->db->hdb_close(context->context, context->db);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
Reference in New Issue
Block a user