]> code.citadel.org Git - citadel.git/blobdiff - citadel/database_sleepycat.c
New versions of Berkeley DB (I tested with 4.5.20) seem to
[citadel.git] / citadel / database_sleepycat.c
index e29ce5b0883b22f235908bbdbe2f9245082b0ad6..918b6d415f9c6db1de8eba55351c88ceeb159e56 100644 (file)
@@ -77,6 +77,13 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg)
 }
 
 
+/* Verbose logging callback */
+void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg)
+{
+       lprintf(CTDL_ALERT, "BDB: %s\n", msg);
+}
+
+
 /* just a little helper function */
 static void txabort(DB_TXN * tid)
 {
@@ -336,9 +343,6 @@ void open_databases(void)
        int i;
        char dbfilename[SIZ];
        u_int32_t flags = 0;
-       DIR *dp;
-       struct dirent *d;
-       char filename[PATH_MAX];
 
        lprintf(CTDL_DEBUG, "cdb_*: open_databases() starting\n");
        lprintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
@@ -366,7 +370,11 @@ void open_databases(void)
        }
        dbenv->set_errpfx(dbenv, "citserver");
        dbenv->set_paniccall(dbenv, dbpanic);
+       dbenv->set_errcall(dbenv, cdb_verbose_err);
+       dbenv->set_errpfx(dbenv, "ctdl");
+#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 3)
        dbenv->set_msgcall(dbenv, cdb_verbose_log);
+#endif
        dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, 1);
        dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, 1);
 
@@ -441,18 +449,29 @@ void open_databases(void)
        }
 
        cdb_allocate_tsd();
+}
+
+
+/* Make sure we own all the files, because in a few milliseconds
+ * we're going to drop root privs.
+ */
+void cdb_chmod_data(void) {
+       DIR *dp;
+       struct dirent *d;
+       char filename[PATH_MAX];
 
-       /* Now make sure we own all the files, because in a few milliseconds
-        * we're going to drop root privs.
-        */
        dp = opendir(ctdl_data_dir);
        if (dp != NULL) {
                while (d = readdir(dp), d != NULL) {
                        if (d->d_name[0] != '.') {
                                snprintf(filename, sizeof filename,
                                         "%s/%s", ctdl_data_dir, d->d_name);
-                               chmod(filename, 0600);
-                               chown(filename, CTDLUID, (-1));
+                               lprintf(9, "chmod(%s, 0600) returned %d\n",
+                                       filename, chmod(filename, 0600)
+                               );
+                               lprintf(9, "chown(%s, CTDLUID, -1) returned %d\n",
+                                       filename, chown(filename, CTDLUID, (-1))
+                               );
                        }
                }
                closedir(dp);