database.c has been moved from server/ into server/backends/common.
Makefile now separates server objects from backend objects.
This is all in preparation for ctdldump and ctdlload to link the backend
code instead of calling BDB directly.
all := ctdldump ctdlload citserver setup sendcommand citmail chkpw chkpwd
all: $(all)
-SRCDIRS := $(wildcard server server/modules/* server/backends/*)
-SOURCES := $(wildcard server/*.c server/modules/*/*.c server/backends/*/*.c)
-OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
+SERVER_SOURCES := $(wildcard server/*.c server/modules/*/*.c)
+SERVER_OBJECTS := $(patsubst %.c,%.o,$(SERVER_SOURCES))
+BACKEND_SOURCES := $(wildcard server/backends/*/*.c)
+BACKEND_OBJECTS := $(patsubst %.c,%.o,$(BACKEND_SOURCES))
-citserver: $(OBJECTS)
+citserver: $(SERVER_OBJECTS) $(BACKEND_OBJECTS)
cc ${CFLAGS} \
- $(OBJECTS) \
+ $(SERVER_OBJECTS) $(BACKEND_OBJECTS) \
${LDFLAGS} \
-lresolv -lcitadel -lpthread -lz -lical -lldap -lcrypt -lexpat -lcurl -ldb \
-o citserver
-$(SOURCES): server/*.h server/modules/*/*.h server/backends/*/*.h
+$(SERVER_SOURCES): server/*.h server/modules/*/*.h server/backends/*/*.h
+ @touch $@
+
+$(BACKEND_SOURCES): server/*.h server/modules/*/*.h server/backends/*/*.h
@touch $@
%.o: %.c
}
// After a successful checkpoint, we can cull the unused logs
- if (CtdlGetConfigInt("c_auto_cull")) {
- ret = bdb_env->log_set_config(bdb_env, DB_LOG_AUTO_REMOVE, 1);
- }
- else {
- ret = bdb_env->log_set_config(bdb_env, DB_LOG_AUTO_REMOVE, 0);
+ ret = bdb_env->log_set_config(bdb_env, DB_LOG_AUTO_REMOVE, 1);
+ if (ret != 0) {
+ syslog(LOG_ERR, "bdb: bdb_checkpoint() auto coll logs: %s", db_strerror(ret));
}
}
--- /dev/null
+// Copyright (c) 1987-2023 by the citadel.org team
+// This program is open source software. Use, duplication, or disclosure
+// are subject to the terms of the GNU General Public License, version 3.
+
+// The functions in this file handle the selection and activation of a storage backend for Citadel Server.
+// Right now, it simply activates Berkeley DB because that's the only one we have.
+
+#include "../../sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <libcitadel.h>
+#include "../../ctdl_module.h"
+#include "../../control.h"
+#include "../../citserver.h"
+#include "../../config.h"
+
+// Header files for all available backends must be included here.
+#include "../berkeley_db/berkeley_db.h"
+
+// Backends must include implementations of all these functions, but with their own prefix instead of "cdb_".
+// The initialization function of the selected backend will map them.
+void (*cdb_open_databases)(void) = NULL;
+void (*cdb_close_databases)(void) = NULL;
+struct cdbdata (*cdb_fetch)(int, const void *, int) = NULL;
+int (*cdb_store)(int, const void *, int, void *, int) = NULL;
+int (*cdb_delete)(int, void *, int) = NULL;
+struct cdbkeyval (*cdb_next_item)(int) = NULL;
+void (*cdb_close_cursor)(int) = NULL;
+void (*cdb_begin_transaction)(void) = NULL;
+void (*cdb_end_transaction)(void) = NULL;
+void (*cdb_check_handles)(void) = NULL;
+void (*cdb_trunc)(int) = NULL;
+void (*check_handles)(void *) = NULL;
+void (*cdb_compact)(void) = NULL;
+void (*cdb_checkpoint)(void) = NULL;
+void (*cdb_rewind)(int) = NULL;
+
+// This function is responsible for choosing and initializing a back end.
+void cdb_init_backends(void) {
+ bdb_init_backend(); // for now, this is the only one, so we select it always.
+}
+
+
+// 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];
+
+ // Silently try to create the database subdirectory. If it's already there, no problem.
+ if ((mkdir(ctdl_db_dir, 0700) != 0) && (errno != EEXIST)) {
+ syslog(LOG_ERR, "bdb: database directory [%s] does not exist and could not be created: %m", ctdl_db_dir);
+ exit(CTDLEXIT_DB);
+ }
+ if (chmod(ctdl_db_dir, 0700) != 0) {
+ syslog(LOG_ERR, "bdb: unable to set database directory permissions [%s]: %m", ctdl_db_dir);
+ exit(CTDLEXIT_DB);
+ }
+ if (chown(ctdl_db_dir, ctdluid, (-1)) != 0) {
+ syslog(LOG_ERR, "bdb: unable to set the owner for [%s]: %m", ctdl_db_dir);
+ exit(CTDLEXIT_DB);
+ }
+ dp = opendir(ctdl_db_dir);
+ if (dp != NULL) {
+ while (d = readdir(dp), d != NULL) {
+ if (d->d_name[0] != '.') {
+ snprintf(filename, sizeof filename, "%s/%s", ctdl_db_dir, d->d_name);
+ syslog(LOG_DEBUG, "bdb: chmod(%s, 0600) returned %d", filename, chmod(filename, 0600));
+ syslog(LOG_DEBUG, "bdb: chown(%s, ctdluid, -1) returned %d", filename, chown(filename, ctdluid, (-1)));
+ }
+ }
+ closedir(dp);
+ }
+}
+
+
CtdlSetConfigInt( "c_imaps_port" , lconfig->c_imaps_port );
CtdlSetConfigInt( "c_pop3s_port" , lconfig->c_pop3s_port );
CtdlSetConfigInt( "c_smtps_port" , lconfig->c_smtps_port );
- CtdlSetConfigInt( "c_auto_cull" , lconfig->c_auto_cull );
CtdlSetConfigInt( "c_allow_spoofing" , lconfig->c_allow_spoofing );
CtdlSetConfigInt( "c_journal_email" , lconfig->c_journal_email );
CtdlSetConfigInt( "c_journal_pubmsgs" , lconfig->c_journal_pubmsgs );
int c_imaps_port;
int c_pop3s_port;
int c_smtps_port;
- char c_auto_cull;
+ char c_niu_4a;
char c_niu_5;
char c_allow_spoofing;
char c_journal_email;
cprintf("%d\n", CtdlGetConfigInt("c_pop3s_port"));
cprintf("%d\n", CtdlGetConfigInt("c_smtps_port"));
cprintf("%d\n", CtdlGetConfigInt("c_enable_fulltext"));
- cprintf("%d\n", CtdlGetConfigInt("c_auto_cull"));
+ cprintf("1\n");
cprintf("1\n");
cprintf("%d\n", CtdlGetConfigInt("c_allow_spoofing"));
cprintf("%d\n", CtdlGetConfigInt("c_journal_email"));
CtdlSetConfigInt("c_enable_fulltext", confbool(buf));
break;
case 43:
- CtdlSetConfigInt("c_auto_cull", confbool(buf));
+ // niu
break;
case 44:
// niu
+++ /dev/null
-// Copyright (c) 1987-2023 by the citadel.org team
-// This program is open source software. Use, duplication, or disclosure
-// are subject to the terms of the GNU General Public License, version 3.
-
-// The functions in this file handle the selection and activation of a storage backend for Citadel Server.
-// Right now, it simply activates Berkeley DB because that's the only one we have.
-
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <libcitadel.h>
-#include "ctdl_module.h"
-#include "control.h"
-#include "citserver.h"
-#include "config.h"
-
-// Header files for all available backends must be included here.
-#include "backends/berkeley_db/berkeley_db.h"
-
-// Backends must include implementations of all these functions, but with their own prefix instead of "cdb_".
-// The initialization function of the selected backend will map them.
-void (*cdb_open_databases)(void) = NULL;
-void (*cdb_close_databases)(void) = NULL;
-struct cdbdata (*cdb_fetch)(int, const void *, int) = NULL;
-int (*cdb_store)(int, const void *, int, void *, int) = NULL;
-int (*cdb_delete)(int, void *, int) = NULL;
-struct cdbkeyval (*cdb_next_item)(int) = NULL;
-void (*cdb_close_cursor)(int) = NULL;
-void (*cdb_begin_transaction)(void) = NULL;
-void (*cdb_end_transaction)(void) = NULL;
-void (*cdb_check_handles)(void) = NULL;
-void (*cdb_trunc)(int) = NULL;
-void (*check_handles)(void *) = NULL;
-void (*cdb_compact)(void) = NULL;
-void (*cdb_checkpoint)(void) = NULL;
-void (*cdb_rewind)(int) = NULL;
-
-// This function is responsible for choosing and initializing a back end.
-void cdb_init_backends(void) {
- bdb_init_backend(); // for now, this is the only one, so we select it always.
-}
-
-
-// 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];
-
- // Silently try to create the database subdirectory. If it's already there, no problem.
- if ((mkdir(ctdl_db_dir, 0700) != 0) && (errno != EEXIST)) {
- syslog(LOG_ERR, "bdb: database directory [%s] does not exist and could not be created: %m", ctdl_db_dir);
- exit(CTDLEXIT_DB);
- }
- if (chmod(ctdl_db_dir, 0700) != 0) {
- syslog(LOG_ERR, "bdb: unable to set database directory permissions [%s]: %m", ctdl_db_dir);
- exit(CTDLEXIT_DB);
- }
- if (chown(ctdl_db_dir, ctdluid, (-1)) != 0) {
- syslog(LOG_ERR, "bdb: unable to set the owner for [%s]: %m", ctdl_db_dir);
- exit(CTDLEXIT_DB);
- }
- dp = opendir(ctdl_db_dir);
- if (dp != NULL) {
- while (d = readdir(dp), d != NULL) {
- if (d->d_name[0] != '.') {
- snprintf(filename, sizeof filename, "%s/%s", ctdl_db_dir, d->d_name);
- syslog(LOG_DEBUG, "bdb: chmod(%s, 0600) returned %d", filename, chmod(filename, 0600));
- syslog(LOG_DEBUG, "bdb: chown(%s, ctdluid, -1) returned %d", filename, chown(filename, ctdluid, (-1)));
- }
- }
- closedir(dp);
- }
-}
-
-
CtdlSetConfigInt("c_enable_fulltext", 1);
}
- if (oldver < 652) {
- CtdlSetConfigInt("c_auto_cull", 1);
- }
-
if (oldver < 725) {
CtdlSetConfigInt("c_xmpp_c2s_port", 5222);
CtdlSetConfigInt("c_xmpp_s2s_port", 5269);
#include "../server/server.h"
#include "../server/citadel_dirs.h"
+uid_t ctdluid = 0;
// Wrapper for realloc() that crashes and burns if the call fails.
void *reallok(void *ptr, size_t size) {
#include "../server/makeuserkey.h"
#include "../server/citadel_dirs.h"
+uid_t ctdluid = 0;
// Wrapper for realloc() that crashes and burns if the call fails.
void *reallok(void *ptr, size_t size) {