From d5bc673e319dee589049e374c395e32f50044809 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sun, 28 Feb 2016 17:54:56 -0600 Subject: [PATCH] Fix HDB two-phase commit for /dev/null log --- lib/kadm5/log.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/kadm5/log.c b/lib/kadm5/log.c index 8a0fcc0b3..31127d413 100644 --- a/lib/kadm5/log.c +++ b/lib/kadm5/log.c @@ -897,6 +897,13 @@ kadm5_log_create(kadm5_server_context *context, hdb_entry *entry) ent.free_entry = 0; ent.entry = *entry; + /* + * If we're not logging then we can't recover-to-perform, so just + * perform. + */ + if (strcmp(log_context->log_file, "/dev/null") == 0) + return context->db->hdb_store(context->context, context->db, 0, &ent); + /* * Test for any conflicting entries before writing the log. If we commit * to the log we'll end-up rolling forward on recovery, but that would be @@ -982,6 +989,9 @@ kadm5_log_delete(kadm5_server_context *context, off_t end_off = 0; /* Ditto; this allows de-indentation by two levels */ off_t off; + if (strcmp(log_context->log_file, "/dev/null") == 0) + return context->db->hdb_remove(context->context, context->db, 0, + princ); ret = context->db->hdb_remove(context->context, context->db, HDB_F_PRECHECK, princ); if (ret) @@ -1088,6 +1098,14 @@ kadm5_log_rename(kadm5_server_context *context, ent.free_entry = 0; ent.entry = *entry; + if (strcmp(log_context->log_file, "/dev/null") == 0) { + ret = context->db->hdb_store(context->context, context->db, 0, &ent); + if (ret == 0) + return context->db->hdb_remove(context->context, context->db, 0, + source); + return ret; + } + /* * Pre-check that the transaction will succeed. * @@ -1243,6 +1261,10 @@ kadm5_log_modify(kadm5_server_context *context, ent.free_entry = 0; ent.entry = *entry; + if (strcmp(log_context->log_file, "/dev/null") == 0) + return context->db->hdb_store(context->context, context->db, + HDB_F_REPLACE, &ent); + ret = context->db->hdb_store(context->context, context->db, HDB_F_PRECHECK | HDB_F_REPLACE, &ent); if (ret) @@ -1598,6 +1620,9 @@ kadm5_log_nop(kadm5_server_context *context, enum kadm_nop_type nop_type) kadm5_log_context *log_context = &context->log_context; off_t off; + if (strcmp(log_context->log_file, "/dev/null") == 0) + return 0; + off = lseek(log_context->log_fd, 0, SEEK_CUR); if (off == -1) return errno;