From 64b4432d2cf2d6a2ae0a50d1d06b2e31bc9f0a5a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 15 Jan 2003 05:57:10 +0000 Subject: [PATCH] * First cut at static-linking the citserver. Ripped out libtool and replaced the dynloader paradigm with "server extensions" paradigm (static linked, but still very loosely coupled by way of using the API's to register callbacks and commands etc.) Needs more testing. --- citadel/ChangeLog | 7 ++ citadel/Makefile.in | 190 ++++++++++----------------------------- citadel/bootstrap | 9 +- citadel/configure.ac | 18 +--- citadel/dynloader.c | 89 +++++------------- citadel/dynloader.h | 2 +- citadel/serv_bio.c | 2 +- citadel/serv_calendar.c | 2 +- citadel/serv_chat.c | 2 +- citadel/serv_expire.c | 2 +- citadel/serv_imap.c | 2 +- citadel/serv_inetcfg.c | 2 +- citadel/serv_listsub.c | 2 +- citadel/serv_mrtg.c | 2 +- citadel/serv_netfilter.c | 2 +- citadel/serv_network.c | 2 +- citadel/serv_newuser.c | 2 +- citadel/serv_pas2.c | 2 +- citadel/serv_pop3.c | 2 +- citadel/serv_rwho.c | 2 +- citadel/serv_smtp.c | 2 +- citadel/serv_spam.c | 2 +- citadel/serv_test.c | 2 +- citadel/serv_upgrade.c | 2 +- citadel/serv_vandelay.c | 2 +- citadel/serv_vcard.c | 2 +- citadel/server_main.c | 11 +-- 27 files changed, 106 insertions(+), 260 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 9c40d6dee..962c54bf8 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,10 @@ $Log$ + Revision 601.109 2003/01/15 05:57:09 ajc + * First cut at static-linking the citserver. Ripped out libtool and + replaced the dynloader paradigm with "server extensions" paradigm (static + linked, but still very loosely coupled by way of using the API's to + register callbacks and commands etc.) Needs more testing. + Revision 601.108 2003/01/14 04:12:26 ajc * Set default view for new user Calendar> rooms to 3 (calendar) * Set default view for new user Tasks> rooms to 4 (tasks) @@ -4371,3 +4377,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 67142180f..1648bf18b 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -17,32 +17,35 @@ CHKPWD=@CHKPWD@ all: $(TARGETS) -.SUFFIXES: .lo .d .c +.SUFFIXES: .o .d .c EXEEXT=@EXEEXT@ SMTP=@SMTP@ CLIENT_TARGETS=citadel$(EXEEXT) whobbs$(EXEEXT) -SERVER_TARGETS=libcitserver.la citserver setup $(CHKPWD) -SERV_MODULES=modules/libchat.la modules/libvcard.la \ - modules/libupgrade.la \ +SERVER_TARGETS=citserver setup $(CHKPWD) +SERV_MODULES=serv_chat.o \ + serv_upgrade.o \ $(SMTP) \ - modules/libpop3.la \ - modules/libmrtg.la \ - modules/libspam.la \ - modules/libimap.la \ - modules/libnetwork.la \ - modules/liblistsub.la \ - modules/libnetfilter.la \ - modules/libnewuser.la \ - modules/libpas2.la \ - modules/libinetcfg.la \ - modules/librwho.la \ - modules/libbio.la \ - modules/libexpire.la \ - modules/libvandelay.la \ - modules/libcalendar.la + serv_pop3.o \ + serv_vcard.o vcard.o \ + serv_mrtg.o \ + serv_spam.o \ + serv_imap.o imap_fetch.o imap_misc.o imap_search.o \ + imap_store.o imap_tools.o \ + serv_network.o \ + serv_listsub.o \ + serv_netfilter.o \ + serv_newuser.o \ + serv_pas2.o md5.o \ + serv_inetcfg.o \ + serv_rwho.o \ + serv_bio.o \ + serv_expire.o \ + serv_vandelay.o \ + serv_calendar.o ical_dezonify.o + UTIL_TARGETS=aidepost msgform readlog \ stats citmail userlist sendcommand \ base64 migratenet$(EXEEXT) @@ -68,9 +71,6 @@ ACLOCAL=@ACLOCAL@ YACC=@YACC@ DATABASE=@DATABASE@ -LIBTOOL=./libtool -LTSHARE=cd modules && ../$(LIBTOOL) $(CC) -rpath $(prefix)/modules -no-undefined -avoid-version -module - # End configuration section VPATH=$(srcdir) @@ -99,17 +99,10 @@ DEP_FILES=$(SOURCES:.c=.d) client: $(CLIENT_TARGETS) -server: $(SERVER_TARGETS) +server: $(SERVER_TARGETS) $(SERV_MODULES) utils: $(UTIL_TARGETS) -serv_modules: $(SERV_MODULES) - @cd modules && mods=`echo .libs/*.s[ol]` && test "$$mods" != '.libs/*.s[ol]' && ln -sf $$mods . || true - @cd modules && mods=`echo .libs/*.dll` && test "$$mods" != '.libs/*.dll' && ln -sf $$mods . || true - -# -# - citadel$(EXEEXT): citadel.o citadel_ipc.o client_chat.o client_passwords.o \ commands.o html.o ipc_c_tcp.o md5.o messages.o rooms.o routines.o \ routines2.o screen.o tools.o $(LIBOBJS) @@ -125,101 +118,26 @@ citadel$(EXEEXT): citadel.o citadel_ipc.o client_chat.o client_passwords.o \ # # -SERV_OBJS = server_main.o - parsedate.o: parsedate.c -LIBSERV_OBJS = user_ops.lo citserver.lo sysdep.lo dynloader.lo \ - tools.lo $(DATABASE:.c=.lo) $(DOMAIN:.c=.lo) \ - control.lo policy.lo config.lo support.lo room_ops.lo \ - file_ops.lo msgbase.lo \ - locate_host.lo housekeeping.lo logging.lo mime_parser.lo html.lo \ - internet_addressing.lo \ - serv_crypto.lo parsedate.lo genstamp.lo \ - clientsocket.lo $(AUTH) $(LIBOBJS:.o=.lo) +SERV_OBJS = server_main.o \ + user_ops.o citserver.o sysdep.o dynloader.o \ + tools.o $(DATABASE:.c=.o) $(DOMAIN:.c=.o) \ + control.o policy.o config.o support.o room_ops.o \ + file_ops.o msgbase.o \ + locate_host.o housekeeping.o logging.o mime_parser.o html.o \ + internet_addressing.o \ + serv_crypto.o parsedate.o genstamp.o \ + clientsocket.o $(AUTH) $(SERV_MODULES) -libcitserver.la: $(LIBSERV_OBJS) - $(LIBTOOL) $(CC) $(LDFLAGS) -rpath $(prefix) -no-undefined \ - -o libcitserver.la $(LIBSERV_OBJS) $(LIBS) $(RESOLV) - -citserver: $(SERV_OBJS) $(LIBTOOL) libcitserver.la - $(LIBTOOL) --mode=link $(CC) $(SERV_OBJS) $(LDFLAGS) libcitserver.la -o \ - citserver $(LIBS) +citserver: $(SERV_OBJS) + $(CC) $(SERV_OBJS) $(LDFLAGS) $(LIBS) $(RESOLV) -o citserver .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@ -.c.lo: $(LIBTOOL) - @test -d modules || mkdir -p modules - $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@ - -modules/libchat.la: serv_chat.lo libcitserver.la $(LIBTOOL) - $(LTSHARE) -o libchat.la ../serv_chat.lo ../libcitserver.la - -modules/libtest.la: serv_test.lo libcitserver.la $(LIBTOOL) - $(LTSHARE) -o libtest.la ../serv_test.lo ../libcitserver.la - -modules/libpop3.la: serv_pop3.lo md5.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libpop3.la ../serv_pop3.lo ../md5.lo ../libcitserver.la - -modules/libmrtg.la: serv_mrtg.lo md5.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libmrtg.la ../serv_mrtg.lo ../libcitserver.la - -modules/libspam.la: serv_spam.lo md5.lo domain.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libspam.la ../serv_spam.lo ../domain.lo ../libcitserver.la - -modules/libinetcfg.la: serv_inetcfg.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libinetcfg.la ../serv_inetcfg.lo ../libcitserver.la - -modules/librwho.la: serv_rwho.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o librwho.la ../serv_rwho.lo ../libcitserver.la - -modules/libbio.la: serv_bio.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libbio.la ../serv_bio.lo ../libcitserver.la - -modules/libexpire.la: serv_expire.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libexpire.la ../serv_expire.lo ../libcitserver.la - -modules/libvandelay.la: serv_vandelay.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libvandelay.la ../serv_vandelay.lo ../libcitserver.la - -modules/libnetwork.la: serv_network.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libnetwork.la ../serv_network.lo ../libcitserver.la - -modules/liblistsub.la: serv_listsub.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o liblistsub.la ../serv_listsub.lo ../libcitserver.la - -modules/libnetfilter.la: serv_netfilter.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libnetfilter.la ../serv_netfilter.lo ../libcitserver.la - -modules/libnewuser.la: serv_newuser.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libnewuser.la ../serv_newuser.lo ../libcitserver.la - -modules/libupgrade.la: serv_upgrade.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libupgrade.la ../serv_upgrade.lo ../libcitserver.la - -modules/libvcard.la: serv_vcard.lo vcard.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libvcard.la ../serv_vcard.lo ../vcard.lo ../libcitserver.la - -modules/libsmtp.la: serv_smtp.lo domain.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libsmtp.la ../serv_smtp.lo ../domain.lo ../libcitserver.la - - -modules/libimap.la: serv_imap.lo imap_tools.lo imap_fetch.lo \ - imap_search.lo imap_store.lo imap_misc.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libimap.la ../imap_tools.lo ../serv_imap.lo \ - ../imap_fetch.lo ../imap_search.lo ../imap_store.lo ../imap_misc.lo ../libcitserver.la - -aidepost: aidepost.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) aidepost.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o aidepost $(LIBS) - -modules/libpas2.la: serv_pas2.lo md5.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libpas2.la ../serv_pas2.lo ../md5.lo ../libcitserver.la - -modules/libcalendar.la: serv_calendar.lo ical_dezonify.lo \ - $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libcalendar.la ../serv_calendar.lo ../ical_dezonify.lo \ - ../libcitserver.la +aidepost: aidepost.o config.o + $(CC) aidepost.o config.o $(LDFLAGS) -o aidepost $(LIBS) citmail: citmail.o config.o $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(LIBS) @@ -233,11 +151,11 @@ chkpwd: chkpwd.o auth.o config.o whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o citadel_ipc.o $(LIBOBJS) $(CC) whobbs.o ipc_c_tcp.o tools.o citadel_ipc.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(LIBS) -migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o citadel_ipc.o tools.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o citadel_ipc.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(LIBS) +migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o citadel_ipc.o tools.o $(LIBOBJS) + $(CC) migratenet.o config.o ipc_c_tcp.o citadel_ipc.o tools.o $(LIBOBJS) $(LDFLAGS) -o migratenet $(LIBS) -sendcommand: sendcommand.o ipc_c_tcp.o citadel_ipc.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) sendcommand.o ipc_c_tcp.o citadel_ipc.o libcitserver.la \ +sendcommand: sendcommand.o ipc_c_tcp.o citadel_ipc.o tools.o config.o $(LIBOBJS) + $(CC) sendcommand.o ipc_c_tcp.o citadel_ipc.o tools.o config.o \ $(LIBOBJS) $(LDFLAGS) -o sendcommand $(LIBS) base64: base64.o @@ -253,8 +171,8 @@ msgform: msgform.o readlog: readlog.o config.o $(CC) readlog.o config.o $(LDFLAGS) -o readlog -stats: stats.o ipc_c_tcp.o citadel_ipc.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) stats.o ipc_c_tcp.o citadel_ipc.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o stats $(LIBS) +stats: stats.o ipc_c_tcp.o citadel_ipc.o tools.o config.o + $(CC) stats.o ipc_c_tcp.o citadel_ipc.o tools.o config.o $(LDFLAGS) -o stats $(LIBS) .PHONY: install-data install-doc install-exec clean cleaner distclean @@ -283,18 +201,13 @@ install-doc: done install-exec: all weekly - @for i in bio bitbucket files images info modules userpics; do \ + @for i in bio bitbucket files images info userpics; do \ $(srcdir)/mkinstalldirs $(root)$(prefix)/$$i; \ done @for i in $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS); do \ if test -f $$i; then \ - echo $(LIBTOOL) --mode=install $(INSTALL) $$i $(root)$(prefix)/$$i; \ - $(LIBTOOL) --mode=install $(INSTALL) $$i $(root)$(prefix)/$$i; \ - fi \ - done - @for i in $(SERV_MODULES) ; do \ - if test -f $$i; then \ - (cd modules && ../$(LIBTOOL) --mode=install $(INSTALL) `basename $$i` $(root)$(prefix)/$$i) ; \ + echo $(INSTALL) $$i $(root)$(prefix)/$$i; \ + $(INSTALL) $$i $(root)$(prefix)/$$i; \ fi \ done @for i in utilsmenu weekly ; do \ @@ -309,19 +222,18 @@ install-exec: all weekly fi clean: - rm -f *.o *.lo parsedate.c + rm -f *.o parsedate.c cleaner: clean - rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) \ - modules/*.la modules/.libs so_locations + rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) *.la distclean: cleaner find . -name '*~' -o -name '.#*' | xargs rm -f - rm -f Makefile sysdep.h config.cache config.log config.status *.d weekly + rm -f Makefile sysdep.h config.cache config/.og config.status *.d weekly .c.d: @echo Checking dependencies for $< - @$(CC) -M $(CPPFLAGS) $< | sed -e 's!$*.o!$*.o $*.lo $@!' > $@ + @$(CC) -M $(CPPFLAGS) $< | sed -e 's!$*.o!$*.o $*/.o $@!' > $@ @test -s $@ || rm -f $@ Makefile: $(srcdir)/Makefile.in config.status @@ -339,8 +251,4 @@ $(srcdir)/aclocal.m4: $(srcdir)/acinclude.m4 weekly: $(srcdir)/weekly.in config.status CONFIG_FILES=weekly CONFIG_HEADERS= $(SHELL) ./config.status -LIBTOOL_DEPS = @LIBTOOL_DEPS@ -$(LIBTOOL): $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck - -include $(DEP_FILES) diff --git a/citadel/bootstrap b/citadel/bootstrap index 4511cb5f4..c6910888f 100755 --- a/citadel/bootstrap +++ b/citadel/bootstrap @@ -31,21 +31,16 @@ fi echo ... running aclocal ... $aclocal -echo ... running libtoolize ... -libtoolize -c --force echo ... running autoconf ... $autoconf echo ... running autoheader ... $autoheader echo -echo This script has been tested with autoconf 2.53, libtool 1.4d, and +echo This script has been tested with autoconf 2.53 and echo automake 1.5. Other versions may work, but I recommend the latest echo compatible versions of these. echo -echo libtool 1.4.2 is not sufficient to build portable configure scripts; -echo at least version 1.4d from alpha.gnu.org is needed. -echo -echo Also note that autoconf, automake, and libtool should all be configured +echo Also note that autoconf and automake should be configured echo with the same prefix. echo diff --git a/citadel/configure.ac b/citadel/configure.ac index 1a061cb96..d32210b54 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -120,11 +120,7 @@ if test "$GCC" = yes; then ;; esac fi -AC_LIBTOOL_DLOPEN -AC_LIBTOOL_WIN32_DLL AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_SUBST(LIBTOOL_DEPS) AC_PROG_INSTALL AC_PROG_YACC missing_dir=`cd $ac_aux_dir && pwd` @@ -145,7 +141,7 @@ dnl Checks for libraries. dnl We want to test for the following in libc before checking for their dnl respective libraries, because some systems (like Irix) have both, and the dnl non-libc versions may be broken. -AC_CHECK_FUNCS(crypt dlopen gethostbyname connect) +AC_CHECK_FUNCS(crypt gethostbyname connect) if test "$ac_cv_func_gethostbyname" = no; then AC_CHECK_LIB(nsl, gethostbyname) @@ -155,14 +151,6 @@ if test "$ac_cv_func_connect" = no; then AC_CHECK_LIB(socket, connect) fi -if test "$ac_cv_func_dlopen" = no; then - AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS" - test "$with_pam" = yes && chkpwd_LIBS="-ldl $chkpwd_LIBS"]) -fi - -dnl Check for HP/UX dynamic loader. This should only be in -ldld. -AC_CHECK_LIB(dld, shl_load, LIBS="-ldld $LIBS") - dnl Check for Solaris realtime support AC_CHECK_LIB(rt, sched_yield) @@ -446,7 +434,7 @@ if test "x$with_ncurses" != xno; then AC_CHECK_HEADERS(ncurses.h,,,[ ]) fi -AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c],, +AC_CHECK_HEADER(resolv.h, [SMTP=serv_smtp.o; DOMAIN=domain.c],, [#ifdef HAVE_SYS_TYPES_H #include #endif @@ -526,7 +514,7 @@ AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create, #endif], ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)]) if test "$ac_cv_func_pthread_create" = yes; then - test "$DATABASE" && TARGETS="client server utils serv_modules" + test "$DATABASE" && TARGETS="client server utils" if test "x$enable_threaded_client" != xno; then AC_DEFINE(THREADED_CLIENT) fi diff --git a/citadel/dynloader.c b/citadel/dynloader.c index fbec1b316..07295ba52 100644 --- a/citadel/dynloader.c +++ b/citadel/dynloader.c @@ -6,21 +6,10 @@ * */ -#ifdef DLL_EXPORT -#define IN_LIBCIT -#endif - #include "sysdep.h" #include #include #include -#ifdef HAVE_DLFCN_H -#include -#endif -#ifdef HAVE_DL_H -#include -#include "hpsux.h" -#endif #include #include #include @@ -112,64 +101,28 @@ int DLoader_Exec_Cmd(char *cmdbuf) return 0; } -void DLoader_Init(char *pathname) +void initialize_server_extensions(void) { - void *fcn_handle; - char dl_error[SIZ]; - DIR *dir; - int i; - struct dirent *dptr; - char *(*h_init_fcn) (void); - char *dl_info; - - char pathbuf[PATH_MAX]; - - if ((dir = opendir(pathname)) == NULL) { - perror("opendir"); - exit(1); - } - while ((dptr = readdir(dir)) != NULL) { - if (strlen(dptr->d_name) < 4) - continue; -#ifndef __CYGWIN__ - if (strcasecmp(&dptr->d_name[strlen(dptr->d_name)-3], ".so")) -#else - if (strcasecmp(&dptr->d_name[strlen(dptr->d_name)-4], ".dll")) -#endif - continue; - - snprintf(pathbuf, PATH_MAX, "%s/%s", pathname, dptr->d_name); - lprintf(7, "Initializing %s...\n", pathbuf); - -#ifdef RTLD_LAZY - if (!(fcn_handle = dlopen(pathbuf, RTLD_LAZY))) -#else /* OpenBSD */ - if (!(fcn_handle = dlopen(pathbuf, DL_LAZY))) -#endif - { - safestrncpy(dl_error, dlerror(), sizeof dl_error); - for (i=0; i