httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soc-r...@apache.org
Subject svn commit: r369864 - in /httpd/mod_smtpd/trunk: modules/rcpt/ok/mod_smtpd_rcpt_ok.c src/mod_smtpd.h src/smtp_core.c src/smtp_protocol.c
Date Tue, 17 Jan 2006 18:56:46 GMT
Author: soc-rian
Date: Tue Jan 17 10:56:43 2006
New Revision: 369864

URL: http://svn.apache.org/viewcvs?rev=369864&view=rev
Log:
Made the "helo" string part of the connection structure. Made vrfy
check its syntax using a compiled regex (like the previous changes).
Converted mod_smtpd_rcpt_ok to conform to the current mod_smtpd.


Modified:
    httpd/mod_smtpd/trunk/modules/rcpt/ok/mod_smtpd_rcpt_ok.c
    httpd/mod_smtpd/trunk/src/mod_smtpd.h
    httpd/mod_smtpd/trunk/src/smtp_core.c
    httpd/mod_smtpd/trunk/src/smtp_protocol.c

Modified: httpd/mod_smtpd/trunk/modules/rcpt/ok/mod_smtpd_rcpt_ok.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/modules/rcpt/ok/mod_smtpd_rcpt_ok.c?rev=369864&r1=369863&r2=369864&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/modules/rcpt/ok/mod_smtpd_rcpt_ok.c (original)
+++ httpd/mod_smtpd/trunk/modules/rcpt/ok/mod_smtpd_rcpt_ok.c Tue Jan 17 10:56:43 2006
@@ -1,5 +1,6 @@
 #include "httpd.h"
 #include "http_config.h"
+#include "apr_tables.h"
 
 #include "mod_smtpd.h"
 
@@ -10,7 +11,7 @@
 module AP_MODULE_DECLARE_DATA smtpd_rcpt_ok_module;
 
 static smtpd_retcode default_rcpt(smtpd_conn_rec *scr, smtpd_return_data *out,
-                                  char *address)
+                                  char *address, apr_table_t *rcpt_param)
 {
     rcpt_ok_config *pConfig =
       ap_get_module_config(scr->s->module_config,
@@ -49,7 +50,7 @@
 // registers httpd hooks
 static void register_hooks (apr_pool_t *p)
 {
-  APR_OPTIONAL_HOOK(smtpd, rcpt, default_rcpt, NULL, NULL, APR_HOOK_LAST);
+    smtpd_hook_rcpt(default_rcpt, NULL, NULL, APR_HOOK_LAST);
 }
 
 module AP_MODULE_DECLARE_DATA smtpd_rcpt_ok_module = {

Modified: httpd/mod_smtpd/trunk/src/mod_smtpd.h
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/mod_smtpd.h?rev=369864&r1=369863&r2=369864&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/mod_smtpd.h (original)
+++ httpd/mod_smtpd/trunk/src/mod_smtpd.h Tue Jan 17 10:56:43 2006
@@ -61,7 +61,6 @@
 
 typedef enum {
     SMTPD_STATE_GOT_NOTHING,
-    SMTPD_STATE_GOT_HELO,
     SMTPD_STATE_GOT_MAIL,
     SMTPD_STATE_GOT_RCPT
 } smtpd_trans_state;
@@ -87,13 +86,6 @@
     
     /* where are we in the current transaction */
     smtpd_trans_state trans_state;
-    
-    /* is this esmtp or smtp */
-    /* by default smtp */
-    smtpd_protocol_type protocol_type;
-
-    /* hostname we were helo'd with */
-    char *helo;
 
     /* string of who this mail is from */
     char *mail_from;
@@ -127,6 +119,13 @@
    
     /* extensions registered with this connection */
     apr_array_header_t *extensions;
+    
+    /* is this esmtp or smtp */
+    /* by default smtp */
+    smtpd_protocol_type protocol_type;
+
+    /* hostname we were helo'd with */
+    char *helo;
 
     /* current transaction */
     smtpd_trans_rec *transaction;

Modified: httpd/mod_smtpd/trunk/src/smtp_core.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/smtp_core.c?rev=369864&r1=369863&r2=369864&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/smtp_core.c (original)
+++ httpd/mod_smtpd/trunk/src/smtp_core.c Tue Jan 17 10:56:43 2006
@@ -45,6 +45,7 @@
 ap_regex_t *ehlo_compiled_regex;
 ap_regex_t *mail_compiled_regex;
 ap_regex_t *rcpt_compiled_regex;
+ap_regex_t *vrfy_compiled_regex;
 
 void smtpd_clear_trans_rec(smtpd_conn_rec *scr)
 {
@@ -53,10 +54,8 @@
     str->trans_state = SMTPD_STATE_GOT_NOTHING;
     str->tfp = NULL;
     str->body_offset = 0;
-    str->protocol_type = SMTPD_PROTOCOL_SMTP;
     str->rcpt_to = apr_array_make(str->p, 5, sizeof(char *));
     str->mail_from = NULL;
-    str->helo = NULL;
     str->headers = apr_table_make(str->p, 5);
     str->mail_parameters = apr_table_make(str->p, 5);
     str->rcpt_parameters = apr_table_make(str->p, 5);
@@ -115,10 +114,13 @@
       "([-[:alnum:]]*[[:alnum:]]:(([^\\[\\]\\\\])|"
       "(\\\\.))+))"
       "$";
+    const char *vrfy_syntax = "^(([-[:alnum:]!#$%&'*+/=?^_`{}|~]+)|"
+      "(\".*[^\\\\]\"))$";
 
     ehlo_compiled_regex = ap_pregcomp(p, ehlo_syntax, AP_REG_EXTENDED);
     mail_compiled_regex = ap_pregcomp(p, mail_syntax, AP_REG_EXTENDED);
     rcpt_compiled_regex = ap_pregcomp(p, rcpt_syntax, AP_REG_EXTENDED);
+    vrfy_compiled_regex = ap_pregcomp(p, vrfy_syntax, AP_REG_EXTENDED);
 }
 
 /* Creates the main request record for the connection */
@@ -139,6 +141,9 @@
     
     scr->bb_in = apr_brigade_create(scr->p, scr->c->bucket_alloc);
     scr->bb_out = apr_brigade_create(scr->p, scr->c->bucket_alloc);
+
+    scr->protocol_type = SMTPD_PROTOCOL_SMTP;
+    scr->helo = apr_palloc(scr->p, 256);
 
     /* create transaction rec */
     str = apr_pcalloc(scr->p, sizeof(*str));

Modified: httpd/mod_smtpd/trunk/src/smtp_protocol.c
URL: http://svn.apache.org/viewcvs/httpd/mod_smtpd/trunk/src/smtp_protocol.c?rev=369864&r1=369863&r2=369864&view=diff
==============================================================================
--- httpd/mod_smtpd/trunk/src/smtp_protocol.c (original)
+++ httpd/mod_smtpd/trunk/src/smtp_protocol.c Tue Jan 17 10:56:43 2006
@@ -44,6 +44,7 @@
 extern ap_regex_t *ehlo_compiled_regex;
 extern ap_regex_t *mail_compiled_regex;
 extern ap_regex_t *rcpt_compiled_regex;
+extern ap_regex_t *vrfy_compiled_regex;
 
 static int smtpd_handle_unrecognized_command(smtpd_conn_rec *scr,
                                              smtpd_return_data *in_data,
@@ -119,7 +120,6 @@
         int return_code;
         apr_pool_clear(per_command_pool);
         command = buffer;
-
         
         buffer = ap_strchr(buffer, ' ');
         if (buffer != NULL) {
@@ -203,7 +203,6 @@
 static int smtpd_handler_ehlo(smtpd_conn_rec *scr, char *buffer,
                               smtpd_return_data *out_data)
 {
-    smtpd_trans_rec *str = scr->transaction;
     int error;
 
     if (buffer == NULL) {
@@ -249,24 +248,24 @@
     /* state */
     smtpd_reset_transaction(scr);
     
-    str->helo = apr_pstrdup(str->p, buffer);
-    str->trans_state = SMTPD_STATE_GOT_HELO;
-    str->protocol_type = SMTPD_PROTOCOL_ESMTP;
+    strncpy(scr->helo, buffer, 255);
+    scr->helo[255] = '\0';
+    scr->protocol_type = SMTPD_PROTOCOL_ESMTP;
     
     if (scr->extensions->nelts) {
         apr_pool_t *p;
         apr_array_header_t *first;
         
-        apr_pool_create(&p, str->p);
+        apr_pool_create(&p, scr->p);
         first = apr_array_make(p, 1, sizeof(char *));
-        (*((char **)apr_array_push(first))) = str->helo;
+        (*((char **)apr_array_push(first))) = scr->helo;
         apr_array_cat(first, scr->extensions);
         
         smtpd_respond_multiline(scr, 250, first);
         apr_pool_destroy(p);
     }
     else {
-        smtpd_respond_oneline(scr, 250, str->helo);
+        smtpd_respond_oneline(scr, 250, scr->helo);
     }
     
     return 250;
@@ -275,7 +274,6 @@
 static int smtpd_handler_helo(smtpd_conn_rec *scr, char *buffer,
                               smtpd_return_data *out_data)
 {
-    smtpd_trans_rec *str = scr->transaction;
     int error;
 
     if (buffer == NULL) {
@@ -319,10 +317,11 @@
     /* state */
     smtpd_reset_transaction(scr);
     
-    str->helo = apr_pstrdup(str->p, buffer);
-    str->trans_state = SMTPD_STATE_GOT_HELO;
-    smtpd_respond_oneline(scr, 250, str->helo);
-    
+    strncpy(scr->helo, buffer, 255);
+    scr->helo[255] = '\0';
+    scr->protocol_type = SMTPD_PROTOCOL_SMTP;
+
+    smtpd_respond_oneline(scr, 250, scr->helo);
     return 250;
 }
 
@@ -829,23 +828,13 @@
 static int smtpd_handler_vrfy(smtpd_conn_rec *scr, char *buffer,
                               smtpd_return_data *out_data)
 {
-    const char *vrfy_syntax = "^(([-[:alnum:]!#$%&'*+/=?^_`{}|~]+)|"
-      "(\".*[^\\\\]\"))$";
-    ap_regex_t *compiled;
     int error;
 
     if (buffer == NULL) {
         goto syntax_error;
     }
 
-    compiled = ap_pregcomp(out_data->p, vrfy_syntax, AP_REG_EXTENDED);
-    if (!compiled) {
-        smtpd_respond_oneline(scr, 421, "Error: Internal");
-        return SMTPD_DONE_DISCONNECT;
-    }
-
-    error = ap_regexec(compiled, buffer, 0, NULL, 0);
-    ap_pregfree(out_data->p, compiled);
+    error = ap_regexec(vrfy_compiled_regex, buffer, 0, NULL, 0);
 
     if (error) {
     syntax_error:



Mime
View raw message