* Did the server port hooks etc. for SSL listeners. For some reason it
authorArt Cancro <ajc@citadel.org>
Sun, 13 Feb 2005 04:55:18 +0000 (04:55 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 13 Feb 2005 04:55:18 +0000 (04:55 +0000)
  doesn't work.  :(

citadel/ChangeLog
citadel/serv_crypto.c
citadel/serv_imap.c
citadel/serv_pop3.c
citadel/serv_smtp.c

index cb8752c9da7706d7ecbff811b35d66c727d847e5..f987ca635ffb2465c46224d2c29c8d26f4b79a8e 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 640.5  2005/02/13 04:55:18  ajc
+ * Did the server port hooks etc. for SSL listeners.  For some reason it
+   doesn't work.  :(
+
  Revision 640.4  2005/02/13 04:23:59  ajc
  * Added server and client configuration settings to specify port
    numbers for IMAPS, POP3S, and SMTPS (SSL-encrypted services that start
@@ -6388,4 +6392,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 19df6a87959c759d0c9556060e37bba2b6d013b6..a730f553188738993abc40499c9190abec04453b 100644 (file)
@@ -460,13 +460,14 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
        int retval, bits, alg_bits;
 
        if (!ssl_ctx) {
-               cprintf("%s", nosup_response);
+               lprintf(CTDL_CRIT, "SSL failed: no ssl_ctx exists?\n");
+               if (nosup_response != NULL) cprintf("%s", nosup_response);
                return;
        }
        if (!(CC->ssl = SSL_new(ssl_ctx))) {
                lprintf(CTDL_CRIT, "SSL_new failed: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
-               cprintf("%s", error_response);
+               if (error_response != NULL) cprintf("%s", error_response);
                return;
        }
        if (!(SSL_set_fd(CC->ssl, CC->client_socket))) {
@@ -474,10 +475,10 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
                        ERR_reason_error_string(ERR_get_error()));
                SSL_free(CC->ssl);
                CC->ssl = NULL;
-               cprintf("%s", error_response);
+               if (error_response != NULL) cprintf("%s", error_response);
                return;
        }
-       cprintf("%s", ok_response);
+       if (ok_response != NULL) cprintf("%s", ok_response);
        retval = SSL_accept(CC->ssl);
        if (retval < 1) {
                /*
index 3ca0d19a684dbf6f48ec51b2e9e95e0ab9be6d99..9b63a7847eac71b0842341bb9e4b729f1a3c1115 100644 (file)
@@ -363,6 +363,16 @@ void imap_greeting(void)
                config.c_fqdn);
 }
 
+/*
+ * IMAPS is just like IMAP, except it goes crypto right away.
+ */
+#ifdef HAVE_OPENSSL
+void imaps_greeting(void) {
+       CtdlStartTLS(NULL, NULL, NULL);
+       imap_greeting();
+}
+#endif
+
 
 /*
  * implements the LOGIN command (ordinary username/password login)
@@ -1470,6 +1480,10 @@ char *serv_imap_init(void)
 {
        CtdlRegisterServiceHook(config.c_imap_port,
                                NULL, imap_greeting, imap_command_loop, NULL);
+#ifdef HAVE_OPENSSL
+       CtdlRegisterServiceHook(config.c_imaps_port,
+                               NULL, imaps_greeting, imap_command_loop, NULL);
+#endif
        CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);
        return "$Id$";
 }
index 46f2d7f2b2b89573984b20aa24001e3064ad53a3..668711f6967fd8afcb293a558e83aa4f545546c5 100644 (file)
@@ -95,6 +95,18 @@ void pop3_greeting(void) {
 }
 
 
+/*
+ * POP3S is just like POP3, except it goes crypto right away.
+ */
+#ifdef HAVE_OPENSSL
+void pop3s_greeting(void) {
+       CtdlStartTLS(NULL, NULL, NULL);
+       pop3_greeting();
+}
+#endif
+
+
+
 /*
  * Specify user name (implements POP3 "USER" command)
  */
@@ -656,6 +668,13 @@ char *serv_pop3_init(void)
                                pop3_greeting,
                                pop3_command_loop,
                                NULL);
+#ifdef HAVE_OPENSSL
+       CtdlRegisterServiceHook(config.c_pop3s_port,
+                               NULL,
+                               pop3s_greeting,
+                               pop3_command_loop,
+                               NULL);
+#endif
        CtdlRegisterSessionHook(pop3_cleanup_function, EVT_STOP);
        return "$Id$";
 }
index 5c0767acd1d8cfe2f351458b14665d7ee33ee579..16cac0173db43b5ac540fc36abb185a006f9f485 100644 (file)
@@ -139,6 +139,18 @@ void smtp_greeting(void) {
        cprintf("220 %s ESMTP Citadel server ready.\r\n", config.c_fqdn);
 }
 
+
+/*
+ * SMTPS is just like SMTP, except it goes crypto right away.
+ */
+#ifdef HAVE_OPENSSL
+void smtps_greeting(void) {
+       CtdlStartTLS(NULL, NULL, NULL);
+       smtp_greeting();
+}
+#endif
+
+
 /*
  * SMTP MSA port requires authentication.
  */
@@ -1651,6 +1663,14 @@ char *serv_smtp_init(void)
                                smtp_command_loop,
                                NULL);
 
+#ifdef HAVE_OPENSSL
+       CtdlRegisterServiceHook(config.c_smtps_port,
+                               NULL,
+                               smtps_greeting,
+                               smtp_command_loop,
+                               NULL);
+#endif
+
        CtdlRegisterServiceHook(config.c_msa_port,      /* SMTP MSA */
                                NULL,
                                smtp_msa_greeting,