]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* SSL/TLS support for the Citadel/UX wire protocol
[citadel.git] / citadel / sysdep.c
index c45e2f77681e44fd4fe424f5978e0334e6f521d2..fdb38cc277675fc5e1f11bc8aa5f1a8fd65892a7 100644 (file)
@@ -62,6 +62,7 @@
 #include "database.h"
 #include "housekeeping.h"
 #include "tools.h"
+#include "serv_crypto.h"
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -234,6 +235,10 @@ static RETSIGTYPE signal_cleanup(int signum) {
 void init_sysdep(void) {
        int a;
 
+#ifdef HAVE_OPENSSL
+       init_ssl();
+#endif
+
        /* Set up a bunch of semaphores to be used for critical sections */
        for (a=0; a<MAX_SEMAPHORES; ++a) {
                pthread_mutex_init(&Critters[a], NULL);
@@ -464,7 +469,6 @@ DONE:       ++num_sessions;
 }
 
 
-
 /*
  * client_write()   ...    Send binary data to the client.
  */
@@ -475,6 +479,13 @@ void client_write(char *buf, int nbytes)
        int sock;
 
 
+#ifdef HAVE_OPENSSL
+       if (CC->redirect_ssl) {
+               client_write_ssl(buf, nbytes);
+               return;
+       }
+#endif
+
        if (CC->redirect_fp != NULL) {
                fwrite(buf, nbytes, 1, CC->redirect_fp);
                return;
@@ -533,6 +544,11 @@ int client_read_to(char *buf, int bytes, int timeout)
        struct timeval tv;
        int retval;
 
+#ifdef HAVE_OPENSSL
+       if (CC->redirect_ssl) {
+               return (client_read_ssl(buf, bytes, timeout));
+       }
+#endif
        len = 0;
        while(len<bytes) {
                FD_ZERO(&rfds);
@@ -1074,6 +1090,3 @@ SETUP_FD: memcpy(&readfds, &masterfds, sizeof masterfds);
        --num_threads;
        return NULL;
 }
-
-
-