From 3d715adc21f878dcdadbfe14275182039996b0ef Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 1 Feb 2010 21:27:14 -0800 Subject: [PATCH] Rename the database after closing it in hpropd If a Berkeley DB database is used as the underlying database, renaming the database before closing it can produce error messages like the following on close: /var/lib/heimdal-kdc/heimdal~.db: unable to flush: No such file or directory since the underlying database library caches the old file name. There is a rename() method in the Berkeley DB API, but it also invalidates the database handle and requires that it be reopened. Since the hdb_rename implementation does not require that the database be open, close the database before renaming it to avoid this problem. Signed-off-by: Love Hornquist Astrand --- kdc/hpropd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kdc/hpropd.c b/kdc/hpropd.c index 625fec5b9..3a30b8c25 100644 --- a/kdc/hpropd.c +++ b/kdc/hpropd.c @@ -240,12 +240,12 @@ main(int argc, char **argv) krb5_write_priv_message(context, ac, &sock, &data); } if(!print_dump) { - ret = db->hdb_rename(context, db, database); - if(ret) - krb5_err(context, 1, ret, "db_rename"); ret = db->hdb_close(context, db); if(ret) krb5_err(context, 1, ret, "db_close"); + ret = db->hdb_rename(context, db, database); + if(ret) + krb5_err(context, 1, ret, "db_rename"); } break; }