The new entry point is defined by the macro
CTDL_MODULE_UPGRADE(module_name).
This entry point works in much the same way as the init entry point
except it is called before the init entry point. This entry point is
intended for use as its name implies. The module should do any upgrade
stuff it needs to do before it can initialise.
serv_upgrade.c demonstrates the useage.
-DEP_FILES=$(SOURCES:.c=.d) modules_init.d
+DEP_FILES=$(SOURCES:.c=.d) modules_init.d modules_upgrade.d
client: $(CLIENT_TARGETS)
client: $(CLIENT_TARGETS)
Make_modules: modules_init.c
Make_modules: modules_init.c
+modules_upgrade.c: modules_init.c
+
modules_init.c: mk_module_init.sh $(SOURCES)
$(srcdir)/mk_module_init.sh
modules_init.c: mk_module_init.sh $(SOURCES)
$(srcdir)/mk_module_init.sh
locate_host.o housekeeping.o html.o \
internet_addressing.o journaling.o \
parsedate.o genstamp.o ecrash.o \
locate_host.o housekeeping.o html.o \
internet_addressing.o journaling.o \
parsedate.o genstamp.o ecrash.o \
- clientsocket.o modules_init.o $(AUTH) $(SERV_MODULES)
+ clientsocket.o modules_init.o modules_upgrade.o $(AUTH) $(SERV_MODULES)
citserver: $(SERV_OBJS)
$(CC) $(SERV_OBJS) $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) $(SERVER_LIBS) $(RESOLV) -o citserver
citserver: $(SERV_OBJS)
$(CC) $(SERV_OBJS) $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) $(SERVER_LIBS) $(RESOLV) -o citserver
cleaner: clean
rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) database_cleanup.sh *.la
cleaner: clean
rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) database_cleanup.sh *.la
- rm -rf modules_init.c modules_init.h Make_modules Make_sources
+ rm -rf modules_upgrade.c modules_init.c modules_init.h Make_modules Make_sources
distclean: cleaner
find . -name '*~' -o -name '.#*' | xargs rm -f
distclean: cleaner
find . -name '*~' -o -name '.#*' | xargs rm -f
#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
+#define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
+
+#define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
+
/*
* Prototype for making log entries in Citadel.
/*
* Prototype for making log entries in Citadel.
H_FILE="$CUR_DIR/modules_init.h"
MOD_FILE="$CUR_DIR/Make_modules"
SRC_FILE="$CUR_DIR/Make_sources"
H_FILE="$CUR_DIR/modules_init.h"
MOD_FILE="$CUR_DIR/Make_modules"
SRC_FILE="$CUR_DIR/Make_sources"
+U_FILE="$CUR_DIR/modules_upgrade.c"
/usr/bin/printf "Scanning extension modules for entry points.\n"
/usr/bin/printf "Scanning extension modules for entry points.\n"
+# start the upgrade file
+cat <<EOF >$U_FILE
+/*
+ * $U_FILE
+ * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
+ */
+
+
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <time.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "citadel.h"
+#include "modules_init.h"
+#include "sysdep_decls.h"
+
+
+
+
+void upgrade_modules (void)
+{
+
+ CtdlLogPrintf (CTDL_INFO, "Upgrade modules.\n");
+
+EOF
+
# start the c file
cat <<EOF >$C_FILE
/*
# start the c file
cat <<EOF >$C_FILE
/*
#include "ctdl_module.h"
extern size_t nSizErrmsg;
void initialise_modules (int threading);
#include "ctdl_module.h"
extern size_t nSizErrmsg;
void initialise_modules (int threading);
+void upgrade_modules(void);
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found entry point in file $i\n"
cat <<EOF >> $C_FILE
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found entry point in file $i\n"
cat <<EOF >> $C_FILE
- lprintf (CTDL_INFO, "%%s\n", CTDL_INIT_CALL($RES_OUT));
+ lprintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
EOF
cat <<EOF >>$H_FILE
CTDL_MODULE_INIT($RES_OUT);
EOF
cat <<EOF >>$H_FILE
CTDL_MODULE_INIT($RES_OUT);
+EOF
+ fi
+ RES=X`grep CTDL_MODULE_UPGRADE $i | cut -f2 -d\( | cut -f1 -d\)`
+ if [ $RES != "X" ] ; then
+ RES_OUT=`echo $RES | cut -b2-`
+ /usr/bin/printf "Found upgrade point in file $i\n"
+cat <<EOF >> $U_FILE
+ lprintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+
+EOF
+cat <<EOF >>$H_FILE
+CTDL_MODULE_UPGRADE($RES_OUT);
# Add this entry point to the .h file
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
# Add this entry point to the .h file
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
+EOF
+ fi
+ RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
+ if [ $RES != "X" ] ; then
+ RES_OUT=`echo $RES | cut -b2-`
+ /usr/bin/printf "Found upgrade point in file modules/$j/$k\n"
+# Add this entry point to the .c file
+cat <<EOF >> $U_FILE
+ lprintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+EOF
+# Add this entry point to the .h file
+cat <<EOF >> $H_FILE
+ CTDL_MODULE_UPGRADE($RES_OUT);
EOF
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
EOF
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
+EOF
+ fi
+ RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
+ if [ $RES != "X" ] ; then
+ RES_OUT=`echo $RES | cut -b2-`
+ /usr/bin/printf "Found upgrade point in file user_modules/$j/$k\n"
+cat <<EOF >> $U_FILE
+ lprintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+EOF
+cat <<EOF >> $H_FILE
+CTDL_MODULE_UPGRADE($RES_OUT);
/usr/bin/printf "\t\t\tLogPrintMessages(filter);\n" >> $C_FILE
/usr/bin/printf "}\n" >> $C_FILE
/usr/bin/printf "\t\t\tLogPrintMessages(filter);\n" >> $C_FILE
/usr/bin/printf "}\n" >> $C_FILE
+#close the upgrade file
+/usr/bin/printf "}\n" >> $U_FILE
/usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE
/usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE
-CTDL_MODULE_INIT(upgrade)
+CTDL_MODULE_UPGRADE(upgrade)
- if (!threading)
- {
- check_server_upgrades();
- }
+ check_server_upgrades();
/* return our Subversion id for the Log */
return "$Id$";
/* return our Subversion id for the Log */
return "$Id$";
// eCrashSymbolTable symbol_table;
#endif
/* initialise semaphores here. Patch by Matt and davew
// eCrashSymbolTable symbol_table;
#endif
/* initialise semaphores here. Patch by Matt and davew
- * its called here as they are needed by lprintf for thread safety
+ * its called here as they are needed by CtdlLogPrintf for thread safety
*/
CtdlInitBase64Table();
InitialiseSemaphores();
*/
CtdlInitBase64Table();
InitialiseSemaphores();
/* any other parameter makes it crash and burn */
else {
/* any other parameter makes it crash and burn */
else {
- lprintf(CTDL_EMERG, "citserver: usage: "
+ CtdlLogPrintf(CTDL_EMERG, "citserver: usage: "
"citserver "
"[-lLogFacility] "
"[-d] [-f] [-D] "
"citserver "
"[-lLogFacility] "
"[-d] [-f] [-D] "
}
/* Tell 'em who's in da house */
}
/* Tell 'em who's in da house */
- lprintf(CTDL_NOTICE, "\n");
- lprintf(CTDL_NOTICE, "\n");
- lprintf(CTDL_NOTICE,
+ CtdlLogPrintf(CTDL_NOTICE, "\n");
+ CtdlLogPrintf(CTDL_NOTICE, "\n");
+ CtdlLogPrintf(CTDL_NOTICE,
"*** Citadel server engine v%d.%02d ***\n",
(REV_LEVEL/100), (REV_LEVEL%100));
"*** Citadel server engine v%d.%02d ***\n",
(REV_LEVEL/100), (REV_LEVEL%100));
+ CtdlLogPrintf(CTDL_NOTICE,
"Copyright (C) 1987-2007 by the Citadel development team.\n");
"Copyright (C) 1987-2007 by the Citadel development team.\n");
+ CtdlLogPrintf(CTDL_NOTICE,
"This program is distributed under the terms of the GNU "
"General Public License.\n");
"This program is distributed under the terms of the GNU "
"General Public License.\n");
- lprintf(CTDL_NOTICE, "\n");
- lprintf(CTDL_DEBUG, "Called as: %s\n", argv[0]);
- lprintf(CTDL_INFO, "%s\n", libcitadel_version_string());
+ CtdlLogPrintf(CTDL_NOTICE, "\n");
+ CtdlLogPrintf(CTDL_DEBUG, "Called as: %s\n", argv[0]);
+ CtdlLogPrintf(CTDL_INFO, "%s\n", libcitadel_version_string());
/* Load site-specific parameters, and set the ipgm secret */
/* Load site-specific parameters, and set the ipgm secret */
- lprintf(CTDL_INFO, "Loading citadel.config\n");
+ CtdlLogPrintf(CTDL_INFO, "Loading citadel.config\n");
get_config();
config.c_ipgm_secret = rand();
put_config();
get_config();
config.c_ipgm_secret = rand();
put_config();
- lprintf(CTDL_INFO, "Acquiring control record\n");
+ CtdlLogPrintf(CTDL_INFO, "Acquiring control record\n");
do_async_loop,
CitadelServiceTCP);
do_async_loop,
CitadelServiceTCP);
+
+ /*
+ * Run any upgrade entry points
+ */
+ CtdlLogPrintf(CTDL_INFO, "Upgrading modules.\n");
+ upgrade_modules();
+
+
/*
* Load any server-side extensions available here.
*/
/*
* Load any server-side extensions available here.
*/
- lprintf(CTDL_INFO, "Initializing server extensions\n");
+ CtdlLogPrintf(CTDL_INFO, "Initializing server extensions\n");
size = strlen(ctdl_home_directory) + 9;
initialise_modules(0);
size = strlen(ctdl_home_directory) + 9;
initialise_modules(0);
getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp);
#endif
if (pwp == NULL)
getpwuid_r(config.c_ctdluid, &pw, pwbuf, sizeof(pwbuf), &pwp);
#endif
if (pwp == NULL)
- lprintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
+ CtdlLogPrintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
"Group IDs will be incorrect.\n", (long)CTDLUID,
strerror(errno));
else {
initgroups(pw.pw_name, pw.pw_gid);
if (setgid(pw.pw_gid))
"Group IDs will be incorrect.\n", (long)CTDLUID,
strerror(errno));
else {
initgroups(pw.pw_name, pw.pw_gid);
if (setgid(pw.pw_gid))
- lprintf(CTDL_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
+ CtdlLogPrintf(CTDL_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
- lprintf(CTDL_INFO, "Changing uid to %ld\n", (long)CTDLUID);
+ CtdlLogPrintf(CTDL_INFO, "Changing uid to %ld\n", (long)CTDLUID);
if (setuid(CTDLUID) != 0) {
if (setuid(CTDLUID) != 0) {
- lprintf(CTDL_CRIT, "setuid() failed: %s\n", strerror(errno));
+ CtdlLogPrintf(CTDL_CRIT, "setuid() failed: %s\n", strerror(errno));
}
#if defined (HAVE_SYS_PRCTL_H) && defined (PR_SET_DUMPABLE)
prctl(PR_SET_DUMPABLE, 1);
}
#if defined (HAVE_SYS_PRCTL_H) && defined (PR_SET_DUMPABLE)
prctl(PR_SET_DUMPABLE, 1);
if (CtdlThreadGetCount() <= 1) // Shutting down clean up the garbage collector
{
if (CtdlThreadGetCount() <= 1) // Shutting down clean up the garbage collector
{
}
if (CtdlThreadGetCount())
}
if (CtdlThreadGetCount())