* support autoconf 2.53
authorNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 26 Mar 2002 04:38:32 +0000 (04:38 +0000)
committerNathan Bryant <loanshark@uncensored.citadel.org>
Tue, 26 Mar 2002 04:38:32 +0000 (04:38 +0000)
 * 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

13 files changed:
citadel/ChangeLog
citadel/Makefile.in
citadel/bootstrap
citadel/citadel.c
citadel/citserver.c
citadel/client_crypto.c
citadel/client_crypto.h
citadel/configure.ac
citadel/genstamp.c
citadel/ipc.h
citadel/ipc_c_tcp.c
citadel/serv_crypto.c
citadel/tools.c

index f8aba6139e96e5f64b8d3e07ec9be5890b51ed4a..329b2c9f87877826d4348341089c19c884a029e1 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index accb014dc35d92c8bcb3c217887b7e14defbdc20..0d1914b73c67bb7e87e217776f7f68a2a9854142 100644 (file)
@@ -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
index faf3acc0e09038563fa31556694cdc662d3d10d1..f4195af365abf50cc882499f223b00323baffbf2 100755 (executable)
@@ -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.
index 59819c905dcf2ead18320bc1f924053bf897ac7b..09961d8ebbf31df8eb48ef653693096a90f1bc43 100644 (file)
@@ -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()) {
index f9161690ea413a373a3940de56e1eeb731617fb8..d543bba2079d8bc58b633f732eace3f8bd9afd59 100644 (file)
@@ -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
 }
 
 /*
index aadc074e5ddbc353942bf57a45f1f1f14dd6926d..64cd11f0758f3086d04a7e022f7cb75b697c573a 100644 (file)
@@ -13,7 +13,7 @@
 #include <sys/types.h>
 #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);
index 0fed709228f02e62cae933ae993419bd10ae8468..0ee5ced6a617380652a5ab23de6540a268ffcf9e 100644 (file)
@@ -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));
index 8a4c19c8be7db9351abfdbcf0e416a47cf10f8e8..59a37a1a3445a1cc44ec0e8209666706e77288c4 100644 (file)
@@ -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 <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#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
index 737b3fa54ebd8fdfaa8535329527776f2d0f617e..b4300fe83b9236ca62ebfb32a0f38216cc09dcec 100644 (file)
@@ -9,8 +9,7 @@
 #define IN_LIBCIT
 #endif
 
-#define timezonevar 1
-
+#include "sysdep.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
index d19144042eec14bfd0da9fdc201af36328122b84..ab99d97245f3c49b6db86a7c48aec9205ebd2e45 100644 (file)
@@ -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, ...));
index f927a084805f0342cfbae0a49195b09888169293..c47c7f4df840cfc3ba3d9cdca8677e6d2da483e7 100644 (file)
 #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);
                }
        }
index b082ca0b182f4679d6a5626dfa4b9b5b3de67076..26a540d2faeea952aa363b952d9c3fceb3a19962 100644 (file)
@@ -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)
index 0bd365ac7963cf5a8797df7ecd5d2ab432bb4ebe..33c81592568f0f0626cddef3c32d29ff5c3778fd 100644 (file)
 #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);