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 <lha@h5l.org>
This commit is contained in:
Russ Allbery
2010-02-01 21:27:14 -08:00
committed by Love Hornquist Astrand
parent 20c65310ea
commit 3d715adc21

View File

@@ -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;
}