Skip Menu |
 

Date: Thu, 27 Dec 2012 13:40:45 -0500
From: Richard Basch <basch@alum.mit.edu>
Subject: krb5-1.11: iprop patch 2 of 4: kproplog
To: krb5-bugs@mit.edu
Download (untitled) / with headers
text/plain 1.8KiB

Attached is patch #2 to consistently reference the ulog as a circular buffer (within kproplog). 

 

diff -ru src.01/slave/kproplog.c src.02/slave/kproplog.c

--- src.01/slave/kproplog.c   2012-12-17 21:47:05.000000000 -0500

+++ src.02/slave/kproplog.c   2012-12-21 20:16:28.181247133 -0500

@@ -400,21 +400,23 @@

  * Print the update entry information

  */

static void

-print_update(kdb_hlog_t *ulog, uint32_t entry, unsigned int verbose)

+print_update(krb5_context kcontext, uint32_t entry, unsigned int verbose)

{

     XDR                 xdrs;

     uint32_t            start_sno, i, j, indx;

     char                *dbprinc;

+    uint32_t          ulogentries = kcontext->kdblog_context->ulogentries;

+    kdb_hlog_t               *ulog = kcontext->kdblog_context->ulog;

     kdb_ent_header_t    *indx_log;

     kdb_incr_update_t   upd;

-    if (entry && (entry < ulog->kdb_num))

+    if (entry > 0 && entry < ulog->kdb_num)

         start_sno = ulog->kdb_last_sno - entry;

     else

-        start_sno = ulog->kdb_first_sno - 1;

+        start_sno = ulog->kdb_last_sno - ulog->kdb_num;

     for (i = start_sno; i < ulog->kdb_last_sno; i++) {

-        indx = i % ulog->kdb_num;

+        indx = i % ulogentries;

         indx_log = (kdb_ent_header_t *)INDEX(ulog, indx);

@@ -543,7 +545,7 @@

     (void) printf(_("\nKerberos update log (%s)\n"),

                   params.iprop_logfile);

-    if (ulog_map(context, params.iprop_logfile, 0,

+    if (ulog_map(context, params.iprop_logfile, params.iprop_ulogsize,

                  reset ? FKADMIND : FKPROPLOG, db_args)) {

         (void) fprintf(stderr, _("Unable to map log file %s\n\n"),

                        params.iprop_logfile);

@@ -631,7 +633,7 @@

     }

     if ((!headeronly) && ulog->kdb_num) {

-        print_update(ulog, entry, verbose);

+        print_update(context, entry, verbose);

     }

     (void) printf("\n");

 

I committed a simplified version of this
(2743fdee849be4a00a9ea72d601004c95b22dd56) which passes ulogentries as a
separate argument to print_update().

I omitted the change to the "if (entry ..." test since it didn't appear
related to the purpose of this change.

I omitted the change to the start_sno assignment because I couldn't figure
out the purpose of the change. ulog->kdb_first_sno - 1 seems like a fine
starting point even if the ulog is underfull, as long as kdb_first_sno is
maintained properly.