From: Nathan Bryant Date: Tue, 26 Mar 2002 04:38:32 +0000 (+0000) Subject: * support autoconf 2.53 X-Git-Tag: v7.86~6460 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=c80517ddb77edae8563c21365c580f79c0405652;p=citadel.git * support autoconf 2.53 * make a note that people should be using libtool 1.4d * cut some of the more pointless bells and whistles out of the configure script in an effort to make it more maintainable * modularized ipc_c_tcp.c and client_crypto.o so that they're not tied to the curses stuff. * timezone/daylight and other FreeBSD fixes * more effort in the configure script to detect the common bastardizations (ahem, ports) of Berkeley DB without falling down --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index f8aba6139..329b2c9f8 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,15 @@ $Log$ + Revision 590.163 2002/03/26 04:38:31 nbryant + * support autoconf 2.53 + * make a note that people should be using libtool 1.4d + * cut some of the more pointless bells and whistles out of the configure + script in an effort to make it more maintainable + * modularized ipc_c_tcp.c and client_crypto.o so that they're not tied + to the curses stuff. + * timezone/daylight and other FreeBSD fixes + * more effort in the configure script to detect the common + bastardizations (ahem, ports) of Berkeley DB without falling down + Revision 590.162 2002/03/25 03:09:39 nbryant fix warning on platforms where pthread_t may be a pointer @@ -3538,4 +3549,3 @@ 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 accb014dc..0d1914b73 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -17,10 +17,9 @@ CHKPWD=@CHKPWD@ all: $(TARGETS) -.SUFFIXES: .lo .ro .d .c +.SUFFIXES: .lo .d .c EXEEXT=@EXEEXT@ -CX=@CX@ SMTP=@SMTP@ @@ -53,19 +52,11 @@ DEFS=@DEFS@ CPPFLAGS=@CPPFLAGS@ -I. CFLAGS=@CFLAGS@ CC=@CC@ -GDBM=@GDBM@ RESOLV=@RESOLV@ LIBS=@LIBS@ LDFLAGS=@LDFLAGS@ -CURSES=@CURSES@ -NETLIBS=@NETLIBS@ chkpwd_LIBS=@chkpwd_LIBS@ LIBOBJS=@LIBOBJS@ -CL_LIBOBJS=@CL_LIBOBJS@ -PTHREAD_DEFS=@PTHREAD_DEFS@ -PTHREAD_LIBS=@PTHREAD_LIBS@ -SSL_LIBS=@SSL_LIBS@ -CLIENT_PTLIBS=@CLIENT_PTLIBS@ INSTALL=@INSTALL@ INSTALL_DATA=@INSTALL_DATA@ SHELL=/bin/sh @@ -114,18 +105,15 @@ serv_modules: $(SERV_MODULES) # # -citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \ - routines2$(CX) messages$(CX) screen$(CX) \ - client_passwords$(CX) md5$(CX) client_crypto$(CX) \ - commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) $(LIBOBJS) - $(CC) ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \ - routines2$(CX) messages$(CX) screen$(CX) \ - commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) \ - client_passwords$(CX) md5$(CX) client_crypto$(CX) \ - $(LIBOBJS) $(LDFLAGS) -o citadel $(CURSES) $(NETLIBS) $(SSL_LIBS) $(CLIENT_PTLIBS) - -.c.o: - $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< +citadel$(EXEEXT): ipc_c_tcp.o citadel.o rooms.o routines.o \ + routines2.o messages.o screen.o \ + client_passwords.o md5.o client_crypto.o \ + commands.o client_chat.o serv_info.o tools.o $(LIBOBJS) + $(CC) ipc_c_tcp.o citadel.o rooms.o routines.o \ + routines2.o messages.o screen.o \ + commands.o client_chat.o serv_info.o tools.o \ + client_passwords.o md5.o client_crypto.o \ + $(LIBOBJS) $(LDFLAGS) -o citadel $(LIBS) .y.c: $(YACC) $(YFLAGS) $< @@ -134,9 +122,9 @@ citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \ # # -SERV_OBJS = server_main.ro +SERV_OBJS = server_main.o -parsedate.ro: parsedate.c +parsedate.o: parsedate.c LIBSERV_OBJS = user_ops.lo citserver.lo sysdep.lo dynloader.lo tools.lo $(DATABASE:.c=.lo) \ control.lo policy.lo config.lo support.lo room_ops.lo file_ops.lo msgbase.lo \ @@ -145,18 +133,18 @@ LIBSERV_OBJS = user_ops.lo citserver.lo sysdep.lo dynloader.lo tools.lo $(DATABA libcitserver.la: $(LIBSERV_OBJS) $(LIBTOOL) $(CC) $(LDFLAGS) -rpath $(prefix) -no-undefined -avoid-version \ - -o libcitserver.la $(LIBSERV_OBJS) $(GDBM) $(LIBS) $(PTHREAD_LIBS) $(NETLIBS) $(SSL_LIBS) $(RESOLV) + -o libcitserver.la $(LIBSERV_OBJS) $(LIBS) $(RESOLV) citserver: $(SERV_OBJS) $(LIBTOOL) libcitserver.la $(LIBTOOL) --mode=link $(CC) $(SERV_OBJS) $(LDFLAGS) libcitserver.la -o \ - citserver $(PTHREAD_LIBS) + citserver $(LIBS) -.c.ro: - $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -DCIT_CLIENT $(PTHREAD_DEFS) -c $< -o $@ +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -DCIT_CLIENT -c $< -o $@ .c.lo: $(LIBTOOL) @test -d modules || mkdir -p modules - $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(PTHREAD_DEFS) -c $< -o $@ + $(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 @@ -207,7 +195,7 @@ modules/libimap.la: serv_imap.lo imap_tools.lo imap_fetch.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 $(PTHREAD_LIBS) + $(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 @@ -216,10 +204,10 @@ modules/libical.la: serv_ical.lo $(LIBTOOL) libcitserver.la $(LTSHARE) -o libical.la ../serv_ical.lo ../libcitserver.la citmail: citmail.o config.o - $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(NETLIBS) + $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(LIBS) setup: setup.o tools.o - $(CC) setup.o tools.o $(CURSES) $(NETLIBS) $(LDFLAGS) -o setup + $(CC) setup.o tools.o $(LIBS) $(LDFLAGS) -o setup chkpwd: chkpwd.o auth.o config.o $(CC) chkpwd.o auth.o config.o $(LDFLAGS) -o chkpwd $(chkpwd_LIBS) @@ -227,22 +215,22 @@ chkpwd: chkpwd.o auth.o config.o netsetup: netsetup.o config.o $(CC) netsetup.o config.o $(LDFLAGS) -o netsetup -whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o $(LIBOBJS) - $(CC) whobbs.o ipc_c_tcp.o tools.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(NETLIBS) +whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS) + $(CC) whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(LIBS) -migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o tools.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(NETLIBS) +migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS) + $(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(LIBS) -sendcommand: sendcommand.o ipc_c_tcp.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) sendcommand.o ipc_c_tcp.o libcitserver.la \ - $(LIBOBJS) $(LDFLAGS) -o sendcommand $(NETLIBS) $(PTHREAD_LIBS) +sendcommand: sendcommand.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS) + $(LIBTOOL) $(CC) sendcommand.o ipc_c_tcp.o client_crypto.o libcitserver.la \ + $(LIBOBJS) $(LDFLAGS) -o sendcommand $(LIBS) base64: base64.o $(CC) base64.o $(LDFLAGS) -o base64 -userlist: userlist.o ipc_c_tcp.o tools.o $(LIBOBJS) - $(CC) userlist.o ipc_c_tcp.o tools.o \ - $(LIBOBJS) $(LDFLAGS) -o userlist $(NETLIBS) +userlist: userlist.o ipc_c_tcp.o client_crypto.o tools.o $(LIBOBJS) + $(CC) userlist.o ipc_c_tcp.o client_crypto.o tools.o \ + $(LIBOBJS) $(LDFLAGS) -o userlist $(LIBS) msgform: msgform.o $(CC) msgform.o $(LDFLAGS) -o msgform @@ -250,8 +238,8 @@ msgform: msgform.o readlog: readlog.o config.o $(CC) readlog.o config.o $(LDFLAGS) -o readlog -stats: stats.o ipc_c_tcp.o libcitserver.la $(LIBOBJS) - $(LIBTOOL) $(CC) stats.o ipc_c_tcp.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o stats $(NETLIBS) $(PTHREAD_LIBS) +stats: stats.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS) + $(LIBTOOL) $(CC) stats.o ipc_c_tcp.o client_crypto.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o stats $(LIBS) .PHONY: install-data install-doc install-exec clean cleaner distclean @@ -306,7 +294,7 @@ install-exec: all weekly fi clean: - rm -f *.o *.ro *.lo parsedate.c + rm -f *.o *.lo parsedate.c cleaner: clean rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) \ @@ -318,7 +306,7 @@ distclean: cleaner .c.d: @echo Checking dependencies for $< - @$(CC) -M $(CPPFLAGS) $(PTHREAD_DEFS) $< | sed -e 's!$*.o!$*.o $*.ro $*.lo $@!' > $@ + @$(CC) -M $(CPPFLAGS) $< | sed -e 's!$*.o!$*.o $*.lo $@!' > $@ @test -s $@ || rm -f $@ Makefile: $(srcdir)/Makefile.in config.status diff --git a/citadel/bootstrap b/citadel/bootstrap index faf3acc0e..f4195af36 100755 --- a/citadel/bootstrap +++ b/citadel/bootstrap @@ -7,20 +7,19 @@ echo ... running aclocal ... aclocal echo ... running libtoolize ... -libtoolize --force +libtoolize -c --force echo ... running autoconf ... autoconf echo ... running autoheader ... autoheader echo -echo This script has been tested with autoconf 2.52, libtool 1.4.2, and +echo This script has been tested with autoconf 2.53, libtool 1.4d, and echo automake 1.5. Other versions may work, but I recommend the latest echo compatible versions of these. echo -echo Some versions of libtool may have outputted, above, a spurious warning -echo that you have to regenerate your aclocal.m4. This is a mostly harmless bug -echo and can be ignored. +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 with the same prefix. diff --git a/citadel/citadel.c b/citadel/citadel.c index 59819c905..09961d8eb 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -918,6 +918,11 @@ int shift(int argc, char **argv, int start, int count) { return argc; } +static void statusHook(char *s) { + sln_printf(s); + sln_flush(); +} + /* * main */ @@ -932,6 +937,10 @@ int main(int argc, char **argv) char hexstring[MD5_HEXSTRING_SIZE]; int stored_password = 0; char password[SIZ]; + + setIPCDeathHook(screen_delete); + setIPCErrorPrintf(err_printf); + setCryptoStatusHook(statusHook); /* Permissions sanity check - don't run citadel setuid/setgid */ if (getuid() != geteuid()) { diff --git a/citadel/citserver.c b/citadel/citserver.c index f9161690e..d543bba20 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -66,12 +66,6 @@ char *unique_session_numbers; int ScheduledShutdown = 0; int do_defrag = 0; -/* These are commented out. Why do we need them? They're defined in time.h - * anyway, and declaring them again here makes FreeBSD barf on it. -extern long int timezone; -extern int daylight; - */ - /* * Various things that need to be initialized at startup */ @@ -356,11 +350,17 @@ char CtdlCheckExpress(void) { void cmd_time(void) { time_t tv; + struct tm *tmp; tv = time(NULL); - localtime(&tv); + tmp = localtime(&tv); - cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, daylight); + /* timezone and daylight global variables are not portable. */ +#ifdef HAVE_STRUCT_TM_TM_GMTOFF + cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp->tm_gmtoff, tmp->tm_isdst); +#else + cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp->tm_isdst); +#endif } /* diff --git a/citadel/client_crypto.c b/citadel/client_crypto.c index aadc074e5..64cd11f07 100644 --- a/citadel/client_crypto.c +++ b/citadel/client_crypto.c @@ -13,7 +13,7 @@ #include #include "citadel.h" #include "client_crypto.h" -#include "screen.h" +#include "ipc.h" #ifdef HAVE_OPENSSL SSL *ssl; @@ -30,6 +30,13 @@ extern int server_is_local; #endif /* HAVE_OPENSSL */ +static void (*status_hook)(char *s) = NULL; + +void setCryptoStatusHook(void (*hook)(char *s)) { + status_hook = hook; +} + + #ifdef HAVE_OPENSSL /* * input binary data from encrypted connection @@ -43,7 +50,7 @@ void serv_read_ssl(char *buf, int bytes) while (len < bytes) { if (SSL_want_read(ssl)) { if ((SSL_write(ssl, junk, 0)) < 1) { - err_printf("SSL_write in serv_read:\n"); + error_printf("SSL_write in serv_read:\n"); ERR_print_errors_fp(stderr); } } @@ -63,7 +70,7 @@ void serv_read_ssl(char *buf, int bytes) serv_read(&buf[len], bytes - len); return; } - err_printf("SSL_read in serv_read:\n"); + error_printf("SSL_read in serv_read:\n"); ERR_print_errors_fp(stderr); connection_died(); return; @@ -85,7 +92,7 @@ void serv_write_ssl(char *buf, int nbytes) while (bytes_written < nbytes) { if (SSL_want_write(ssl)) { if ((SSL_read(ssl, junk, 0)) < 1) { - err_printf("SSL_read in serv_write:\n"); + error_printf("SSL_read in serv_write:\n"); ERR_print_errors_fp(stderr); } } @@ -107,7 +114,7 @@ void serv_write_ssl(char *buf, int nbytes) nbytes - bytes_written); return; } - err_printf("SSL_write in serv_write:\n"); + error_printf("SSL_write in serv_write:\n"); ERR_print_errors_fp(stderr); connection_died(); return; @@ -168,13 +175,13 @@ int starttls(void) ssl_method = SSLv23_client_method(); ssl_ctx = SSL_CTX_new(ssl_method); if (!ssl_ctx) { - err_printf("SSL_CTX_new failed: %s\n", + error_printf("SSL_CTX_new failed: %s\n", ERR_reason_error_string(ERR_get_error())); return 0; } /* Any reasonable cipher we can get */ if (!(SSL_CTX_set_cipher_list(ssl_ctx, CIT_CIPHERS))) { - err_printf("No ciphers available for encryption\n"); + error_printf("No ciphers available for encryption\n"); SSL_CTX_free(ssl_ctx); ssl_ctx = NULL; return 0; @@ -184,17 +191,17 @@ int starttls(void) /* Load DH parameters into the context */ dh = DH_new(); if (!dh) { - err_printf("Can't allocate a DH object: %s\n", + error_printf("Can't allocate a DH object: %s\n", ERR_reason_error_string(ERR_get_error())); return 0; } if (!(BN_hex2bn(&(dh->p), DH_P))) { - err_printf("Can't assign DH_P: %s\n", + error_printf("Can't assign DH_P: %s\n", ERR_reason_error_string(ERR_get_error())); return 0; } if (!(BN_hex2bn(&(dh->g), DH_G))) { - err_printf("Can't assign DH_G: %s\n", + error_printf("Can't assign DH_G: %s\n", ERR_reason_error_string(ERR_get_error())); return 0; } @@ -227,7 +234,7 @@ int starttls(void) /* New SSL object */ ssl = SSL_new(ssl_ctx); if (!ssl) { - err_printf("SSL_new failed: %s\n", + error_printf("SSL_new failed: %s\n", ERR_reason_error_string(ERR_get_error())); SSL_CTX_free(ssl_ctx); ssl_ctx = NULL; @@ -242,13 +249,13 @@ int starttls(void) RAND_egd("/var/run/egd-pool"); if (!RAND_status()) { - err_printf("PRNG not properly seeded\n"); + error_printf("PRNG not properly seeded\n"); return 0; } /* Associate network connection with SSL object */ if (SSL_set_fd(ssl, serv_sock) < 1) { - err_printf("SSL_set_fd failed: %s\n", + error_printf("SSL_set_fd failed: %s\n", ERR_reason_error_string(ERR_get_error())); SSL_CTX_free(ssl_ctx); ssl_ctx = NULL; @@ -257,20 +264,20 @@ int starttls(void) return 0; } - sln_printf("Requesting encryption...\r"); - sln_flush(); + if (status_hook != NULL) + status_hook("Requesting encryption...\r"); /* Ready to start SSL/TLS */ serv_puts("STLS"); serv_gets(buf); if (buf[0] != '2') { - err_printf("Server can't start TLS: %s\n", &buf[4]); + error_printf("Server can't start TLS: %s\n", &buf[4]); return 0; } /* Do SSL/TLS handshake */ if ((a = SSL_connect(ssl)) < 1) { - err_printf("SSL_connect failed: %s\n", + error_printf("SSL_connect failed: %s\n", ERR_reason_error_string(ERR_get_error())); SSL_CTX_free(ssl_ctx); ssl_ctx = NULL; @@ -283,7 +290,7 @@ int starttls(void) int bits, alg_bits; bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), &alg_bits); - err_printf("Encrypting with %s cipher %s (%d of %d bits)\n", + error_printf("Encrypting with %s cipher %s (%d of %d bits)\n", SSL_CIPHER_get_version(SSL_get_current_cipher(ssl)), SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)), bits, alg_bits); diff --git a/citadel/client_crypto.h b/citadel/client_crypto.h index 0fed70922..0ee5ced6a 100644 --- a/citadel/client_crypto.h +++ b/citadel/client_crypto.h @@ -15,3 +15,7 @@ void serv_read_ssl(char *buf, int bytes); void serv_write_ssl(char *buf, int nbytes); void ssl_lock(int mode, int n, const char *file, int line); #endif /* HAVE_OPENSSL */ + +extern int ssl_is_connected; + +void setCryptoStatusHook(void (*hook)(char *s)); diff --git a/citadel/configure.ac b/citadel/configure.ac index 8a4c19c8b..59a37a1a3 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -39,6 +39,10 @@ if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then db_dir="$with_db" with_db=yes else + test -f /usr/local/lib/libdb.a -o -f /usr/local/lib/libdb.so \ + -o -f /usr/local/lib/libdb4.a -o -f /usr/local/lib/libdb4.so \ + -o -f /usr/local/lib/libdb3.a -o -f /usr/local/lib/libdb3.so && db_dir=/usr/local + test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1 test -d /usr/local/BerkeleyDB.3.2 && db_dir=/usr/local/BerkeleyDB.3.2 test -d /usr/local/BerkeleyDB.3.3 && db_dir=/usr/local/BerkeleyDB.3.3 @@ -70,21 +74,21 @@ case "$host" in dnl build pthreads programs with gcc due to header problems. alpha*-dec-osf*) test -z "$CC" && CC=cc - PTHREAD_LIBS="-lpthread -lexc" + LIBS="-lpthread -lexc $LIBS" check_pthread=no ;; dnl FreeBSD is similar to Digital UNIX with DEC C, which has a -pthread flag: *-*-freebsd*) if test "$with_kthread" = yes; then - PTHREAD_LIBS=-kthread + LIBS="-kthread $LIBS" else - PTHREAD_LIBS=-pthread + LIBS="-pthread $LIBS" fi check_pthread=no PTHREAD_DEFS=-D_THREAD_SAFE ;; *-*-openbsd*) - PTHREAD_LIBS=-pthread + LIBS="-pthread $LIBS" check_pthread=no PTHREAD_DEFS=-pthread ;; @@ -92,6 +96,7 @@ case "$host" in PTHREAD_DEFS="-D_REENTRANT -D_PTHREADS" ;; esac +DEFS="$DEFS $PTHREAD_DEFS" dnl Checks for programs. AC_PROG_CC @@ -122,22 +127,17 @@ dnl Checks for system services. dnl Checks for libraries. -dnl libdl, libgdbm, and libcrypt are only used in the server, so the -dnl Makefile only passes $(LIBS) to that target. If other programs start -dnl requiring additional libraries, we'll have to use other variables, as is -dnl done with curses. - 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) if test "$ac_cv_func_gethostbyname" = no; then - AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="-lnsl $NETLIBS") + AC_CHECK_LIB(nsl, gethostbyname) fi if test "$ac_cv_func_connect" = no; then - AC_CHECK_LIB(socket, connect, NETLIBS="-lsocket $NETLIBS",, $NETLIBS) + AC_CHECK_LIB(socket, connect) fi if test "$ac_cv_func_dlopen" = no; then @@ -190,19 +190,18 @@ fi if test "x$with_db" != xno -a "x$with_gdbm" != xyes; then test "$db_dir" && LDFLAGS="$LDFLAGS -L$db_dir/lib" - test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" || \ - ( test -d /usr/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/include/db4" ) || \ - ( test -d /usr/local/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/local/include/db4" ) || \ - ( test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3" ) || \ - ( test -d /usr/local/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/local/include/db3" ) + dblib="" + test -d "$db_dir/include/db4" && CPPFLAGS="$CPPFLAGS -I$db_dir/include/db4" && dblib="db4" || \ + ( test -d "$db_dir/include/db3" && CPPFLAGS="$CPPFLAGS -I$db_dir/include/db3" && dblib="db3" ) || \ + ( test "$db_dir" -a -d "$db_dir/include" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" ) || \ + ( test -d /usr/include/db4 && CPPFLAGS="$CPPFLAGS -I/usr/include/db4" && dblib="db4" ) || \ + ( test -d /usr/include/db3 && CPPFLAGS="$CPPFLAGS -I/usr/include/db3" && dblib="db3" ) - AC_CHECK_LIB(db3, db_env_create, - [GDBM="$GDBM -ldb3" + AC_SEARCH_LIBS(db_env_create, [$dblib db db4 db3], [ DATABASE=database_sleepycat.c - with_gdbm=no], [AC_CHECK_LIB(db, db_env_create, - [GDBM="$GDBM -ldb" - DATABASE=database_sleepycat.c - with_gdbm=no], [], [$NETLIBS])], [$NETLIBS]) + with_gdbm=no + ]) + fi if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then @@ -212,7 +211,7 @@ if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then test "$db_dir" && CPPFLAGS="$CPPFLAGS -I$db_dir/include" AC_CHECK_LIB(gdbm, gdbm_open, - [GDBM="$GDBM -lgdbm" + [LIBS="-lgdbm $LIBS" DATABASE=database.c with_db=no]) fi @@ -220,21 +219,15 @@ fi test -f /usr/local/lib/libresolv.a && LDFLAGS="$LDFLAGS -L/usr/local/lib" AC_CHECK_LIB(resolv, res_query, RESOLV="$RESOLV -lresolv") -save_LIBS=$LIBS -LIBS=$CURSES AC_SEARCH_LIBS(tgetent, [ncurses curses termcap]) AC_SEARCH_LIBS(initscr, [ncurses curses]) AC_CHECK_FUNCS(vw_printw wcolor_set) -CURSES=$LIBS -LIBS=$save_LIBS dnl Check for libpthread(s) if we're not using Digital UNIX or FreeBSD. (On dnl which the -pthread flag takes care of this.) if test "$check_pthread" != no; then - AC_CHECK_LIB(pthread, pthread_create, - PTHREAD_LIBS="-lpthread $PTHREAD_LIBS") - AC_CHECK_LIB(pthreads, pthread_create, - PTHREAD_LIBS="-lpthreads $PTHREAD_LIBS") + AC_CHECK_LIB(pthread, pthread_create) + AC_CHECK_LIB(pthreads, pthread_create) fi # The big search for OpenSSL @@ -319,8 +312,7 @@ if test "$with_ssl" != "no"; then if test "x$ac_cv_openssldir" != "xno" ; then AC_DEFINE(HAVE_OPENSSL) - LIBS="$saved_LIBS" - SSL_LIBS="-lssl -lcrypto" + LIBS="-lssl -lcrypto $LIBS" dnl Need to recover ssldir - test above runs in subshell ssldir=$ac_cv_openssldir if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then @@ -357,19 +349,19 @@ dnl dnl TODO: for the DB header checks, we should check whether the headers dnl define db_env_create, somehow dnl -AC_CHECK_HEADERS(curses.h ncurses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h) +AC_CHECK_HEADERS(curses.h ncurses.h dl.h fcntl.h limits.h termios.h sys/ioctl.h sys/select.h sys/time.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db3/db.h db4/db.h pthread.h netinet/in.h) + +AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c],, +[#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif]) -AC_CHECK_HEADER(resolv.h, [SMTP=modules/libsmtp.la; DOMAIN=domain.c]) AC_SUBST(SMTP) AC_SUBST(DOMAIN) -dnl some systems require -pthread, -D_REENTRANT, etc to be passed to cc if we -dnl include pthread.h: -save_CPPFLAGS=$CPPFLAGS -CPPFLAGS="$CPPFLAGS $PTHREAD_DEFS" -AC_CHECK_HEADERS(pthread.h) -CPPFLAGS=$save_CPPFLAGS - dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T @@ -409,10 +401,7 @@ AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp) -dnl Now check for pthreads -- set up variables so that the compiler will be run -dnl with proper flags for pthread programs -save_LIBS=$LIBS -LIBS="$PTHREAD_LIBS $LIBS" +dnl Now check for pthreads dnl On some platforms, AC_CHECK_FUNC[S] doesn't work for pthreads programs; dnl we need to include pthread.h @@ -449,38 +438,18 @@ if test "$ac_cv_func_pthread_create" = yes; then test "$DATABASE" && TARGETS="client server utils serv_modules" if test "x$enable_threaded_client" != xno; then AC_DEFINE(THREADED_CLIENT) - CLIENT_PTLIBS=$PTHREAD_LIBS - CL_LIBOBJS='$(LIBOBJS:.o=.ro)' - CX=.ro fi fi -if test "x$CX" != x.ro; then - CL_LIBOBJS='$(LIBOBJS)' - CX=.o -fi - -dnl Now restore the old libs so we don't pass the wrong stuff to makefile -LIBS=$save_LIBS - AC_REPLACE_FUNCS(snprintf getutline) dnl Done! Now write the Makefile and sysdep.h AC_SUBST(AUTH) AC_SUBST(CHKPWD) -AC_SUBST(CURSES) -AC_SUBST(GDBM) AC_SUBST(RESOLV) -AC_SUBST(NETLIBS) AC_SUBST(chkpwd_LIBS) AC_SUBST(TARGETS) -AC_SUBST(PTHREAD_DEFS) -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(CLIENT_PTLIBS) -AC_SUBST(CL_LIBOBJS) -AC_SUBST(CX) AC_SUBST(DATABASE) -AC_SUBST(SSL_LIBS) AC_CONFIG_HEADER(sysdep.h) AC_CONFIG_FILES([Makefile weekly]) AC_OUTPUT diff --git a/citadel/genstamp.c b/citadel/genstamp.c index 737b3fa54..b4300fe83 100644 --- a/citadel/genstamp.c +++ b/citadel/genstamp.c @@ -9,8 +9,7 @@ #define IN_LIBCIT #endif -#define timezonevar 1 - +#include "sysdep.h" #include #include #include diff --git a/citadel/ipc.h b/citadel/ipc.h index d19144042..ab99d9724 100644 --- a/citadel/ipc.h +++ b/citadel/ipc.h @@ -4,3 +4,6 @@ extern int server_is_local; int getsockfd(void); char serv_getc(void); int is_connected(void); +extern int (*error_printf)(char *s, ...); +void setIPCDeathHook(void (*hook)(void)); +void setIPCErrorPrintf(int (*func)(char *s, ...)); diff --git a/citadel/ipc_c_tcp.c b/citadel/ipc_c_tcp.c index f927a0848..c47c7f4df 100644 --- a/citadel/ipc_c_tcp.c +++ b/citadel/ipc_c_tcp.c @@ -30,17 +30,12 @@ #include "citadel_decls.h" #include "ipc.h" #include "tools.h" -#if defined(HAVE_OPENSSL) && defined(CIT_CLIENT) +#if defined(HAVE_OPENSSL) #include "client_crypto.h" #endif #ifndef HAVE_SNPRINTF #include "snprintf.h" #endif -#ifdef CIT_CLIENT -#include "screen.h" -#else -extern int err_printf(char *fmt, ...); -#endif /* * If server_is_local is set to nonzero, the client assumes that it is running @@ -61,16 +56,22 @@ int server_is_local = 0; int serv_sock; -#if defined(HAVE_OPENSSL) && defined(CIT_CLIENT) -extern int ssl_is_connected; -#endif +static void (*deathHook)(void) = NULL; +int (*error_printf)(char *s, ...) = (int (*)(char *, ...))printf; +void setIPCDeathHook(void (*hook)(void)) { + deathHook = hook; +} + +void setIPCErrorPrintf(int (*func)(char *s, ...)) { + error_printf = func; +} void connection_died(void) { -#ifdef CIT_CLIENT - screen_delete(); -#endif - err_printf("\rYour connection to this Citadel server is broken.\n" + if (deathHook != NULL) + deathHook(); + + error_printf("\rYour connection to this Citadel server is broken.\n" "Last error: %s\n" "Please re-connect and log in again.\n", strerror(errno)); @@ -80,7 +81,7 @@ void connection_died(void) { static void ipc_timeout(int signum) { - err_printf("\rConnection timed out.\n"); + error_printf("\rConnection timed out.\n"); logoff(3); } @@ -110,12 +111,12 @@ static int connectsock(char *host, char *service, char *protocol, int defaultPor if (phe) { memcpy(&sin.sin_addr, phe->h_addr, phe->h_length); } else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) { - err_printf("Can't get %s host entry: %s\n", + error_printf("Can't get %s host entry: %s\n", host, strerror(errno)); logoff(3); } if ((ppe = getprotobyname(protocol)) == 0) { - err_printf("Can't get %s protocol entry: %s\n", + error_printf("Can't get %s protocol entry: %s\n", protocol, strerror(errno)); logoff(3); } @@ -127,14 +128,14 @@ static int connectsock(char *host, char *service, char *protocol, int defaultPor s = socket(PF_INET, type, ppe->p_proto); if (s < 0) { - err_printf("Can't create socket: %s\n", strerror(errno)); + error_printf("Can't create socket: %s\n", strerror(errno)); logoff(3); } signal(SIGALRM, ipc_timeout); alarm(30); if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - err_printf("can't connect to %s:%s: %s\n", + error_printf("can't connect to %s:%s: %s\n", host, service, strerror(errno)); logoff(3); } @@ -155,12 +156,12 @@ int uds_connectsock(char *sockpath) s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) { - err_printf("Can't create socket: %s\n", strerror(errno)); + error_printf("Can't create socket: %s\n", strerror(errno)); logoff(3); } if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - err_printf("can't connect: %s\n", strerror(errno)); + error_printf("can't connect: %s\n", strerror(errno)); logoff(3); } @@ -253,7 +254,7 @@ void serv_gets(char *buf) */ void serv_puts(char *buf) { - /* err_printf("< %s\n", buf); */ + /* error_printf("< %s\n", buf); */ serv_write(buf, strlen(buf)); serv_write("\n", 1); } @@ -281,8 +282,8 @@ void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf) strcpy(citport, argv[a]); } else { - err_printf("%s: usage: ",argv[0]); - err_printf("%s [host] [port] ",argv[0]); + error_printf("%s: usage: ",argv[0]); + error_printf("%s [host] [port] ",argv[0]); logoff(2); } } diff --git a/citadel/serv_crypto.c b/citadel/serv_crypto.c index b082ca0b1..26a540d2f 100644 --- a/citadel/serv_crypto.c +++ b/citadel/serv_crypto.c @@ -42,7 +42,7 @@ SSL_CTX *ssl_ctx; /* SSL context */ pthread_mutex_t **SSLCritters; /* Things needing locking */ static unsigned long id_callback(void) { - return pthread_self(); + return (unsigned long)pthread_self(); } void init_ssl(void) diff --git a/citadel/tools.c b/citadel/tools.c index 0bd365ac7..33c815925 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -30,21 +30,6 @@ #include "tools.h" #include "citadel.h" -#ifdef CIT_CLIENT -#include "screen.h" -#else -int err_printf(char *fmt, ...); -int err_printf(char *fmt, ...) -{ - va_list ap; - int retval; - va_start(ap, fmt); - retval = fprintf(stderr, fmt, ap); - va_end(ap); - return retval; -} -#endif - #define TRUE 1 #define FALSE 0 @@ -55,7 +40,7 @@ static byte dtable[256]; /* base64 encode / decode table */ char *safestrncpy(char *dest, const char *src, size_t n) { if (dest == NULL || src == NULL) { - err_printf("safestrncpy: NULL argument\n"); + fprintf(stderr, "safestrncpy: NULL argument\n"); abort(); } strncpy(dest, src, n);