#endif
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "sysdep_decls.h"
#include "threads.h"
#include "config.h"
+#include "control.h"
#include "ctdl_module.h"
for (i = 0; i < MAXCDB; i++)
if (cursors[i] != NULL) {
CtdlLogPrintf(CTDL_EMERG,
- "cdb_*: cursor still in progress on cdb %d: %s\n",
+ "cdb_*: cursor still in progress on cdb %02x: %s\n",
i, msg);
abort();
}
int i;
char dbfilename[SIZ];
u_int32_t flags = 0;
+ int dbversion_major, dbversion_minor, dbversion_patch;
+ int current_dbversion = 0;
CtdlLogPrintf(CTDL_DEBUG, "cdb_*: open_databases() starting\n");
CtdlLogPrintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
CtdlLogPrintf(CTDL_INFO, " Linked db: %s\n",
- db_version(NULL, NULL, NULL));
+ db_version(&dbversion_major, &dbversion_minor, &dbversion_patch));
+
+ current_dbversion = (dbversion_major * 1000000) + (dbversion_minor * 1000) + dbversion_patch;
+
+ CtdlLogPrintf(CTDL_DEBUG, "Calculated dbversion: %d\n", current_dbversion);
+ CtdlLogPrintf(CTDL_DEBUG, " Previous dbversion: %d\n", CitControl.MMdbversion);
+
+ if (CitControl.MMdbversion > current_dbversion) {
+ CtdlLogPrintf(CTDL_EMERG, "You are attempting to run the Citadel server using a version\n"
+ "of Berkeley DB that is older than that which last created or\n"
+ "updated the database. Because this would probably cause data\n"
+ "corruption or loss, the server is aborting execution now.\n");
+ exit(CTDLEXIT_DB);
+ }
+
+ CitControl.MMdbversion = current_dbversion;
+ put_control();
+
#ifdef HAVE_ZLIB
CtdlLogPrintf(CTDL_INFO, "Linked zlib: %s\n", zlibVersion());
#endif
DB_CREATE | DB_AUTO_COMMIT | DB_THREAD,
0600);
if (ret) {
- CtdlLogPrintf(CTDL_EMERG, "db_open[%d]: %s\n", i,
+ CtdlLogPrintf(CTDL_EMERG, "db_open[%02x]: %s\n", i,
db_strerror(ret));
exit(CTDLEXIT_DB);
}
/* close the tables */
for (a = 0; a < MAXCDB; ++a) {
- CtdlLogPrintf(CTDL_INFO, "Closing database %d\n", a);
+ CtdlLogPrintf(CTDL_INFO, "Closing database %02x\n", a);
ret = dbp[a]->close(dbp[a], 0);
if (ret) {
CtdlLogPrintf(CTDL_EMERG,