[exim-dev] Re: [exim] non-ascii in the envelope

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Tony Finch
Dátum:  
Címzett: exim-dev
CC: mcn4
Tárgy: [exim-dev] Re: [exim] non-ascii in the envelope
On Fri, 29 Jul 2005, Philip Hazel wrote:
> On Fri, 29 Jul 2005, Matthew Newton wrote:
>
> > Why not just put the data sent to exim in a variable, say $smtp_data,
> > just before each ACL is called.
>
> RTFM:
>
> 39.12 Data for non-message ACLs
>
> When an ACL is being run for AUTH, EHLO, ETRN, EXPN, HELO, STARTTLS, or VRFY, |
> the remainder of the SMTP command line is placed in $smtp_command_argument.


[moved to exim-dev]

However we were talking about envelope commands (MAIL and RCPT) so this is
almost but not quite a solution. Matthew identified the right internal
variable, though it's local to smtp_in.c. The documentation lists the
situations in which it is passed through to acl_check() but in the case of
RCPT the variable which is used for this is overloaded with the recipient
address, so these two uses need to be separated.

Is something like the following patch OK or would a bigger change make it
cleaner overall? (I haven't even compiled this yet.)

Tony.
--
f.a.n.finch <dot@???> http://dotat.at/
BISCAY: WEST 5 OR 6 BECOMING VARIABLE 3 OR 4. SHOWERS AT FIRST. MODERATE OR
GOOD.


Index: acl.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/acl.c,v
retrieving revision 1.43
diff -u -r1.43 acl.c
--- acl.c    2 Aug 2005 15:19:20 -0000    1.43
+++ acl.c    16 Aug 2005 15:10:33 -0000
@@ -3345,8 +3345,8 @@
 */


int
-acl_check(int where, uschar *data_string, uschar *s, uschar **user_msgptr,
- uschar **log_msgptr)
+acl_check(int where, uschar *data_string, uschar *recipient, uschar *s,
+ uschar **user_msgptr, uschar **log_msgptr)
{
int rc;
address_item adb;
@@ -3355,12 +3355,13 @@
*user_msgptr = *log_msgptr = NULL;
sender_verified_failed = NULL;
ratelimiters_cmd = NULL;
+addr = NULL;

 if (where == ACL_WHERE_RCPT)
   {
   adb = address_defaults;
   addr = &adb;
-  addr->address = data_string;
+  addr->address = recipient;
   if (deliver_split_address(addr) == DEFER)
     {
     *log_msgptr = US"defer in percent_hack_domains check";
@@ -3369,11 +3370,8 @@
   deliver_domain = addr->domain;
   deliver_localpart = addr->local_part;
   }
-else
-  {
-  addr = NULL;
-  smtp_command_argument = data_string;
-  }
+
+smtp_command_argument = data_string;


rc = acl_check_internal(where, addr, s, 0, user_msgptr, log_msgptr);

Index: functions.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/functions.h,v
retrieving revision 1.19
diff -u -r1.19 functions.h
--- functions.h    9 Aug 2005 13:31:52 -0000    1.19
+++ functions.h    16 Aug 2005 15:10:33 -0000
@@ -39,7 +39,8 @@
 /* Everything else... */


 extern acl_block *acl_read(uschar *(*)(void), uschar **);
-extern int     acl_check(int, uschar *, uschar *, uschar **, uschar **);
+extern int     acl_check(int, uschar *, uschar *, uschar *, uschar **,
+                 uschar **);
 extern uschar *auth_b64encode(uschar *, int);
 extern int     auth_b64decode(uschar *, uschar **);
 extern int     auth_call_pam(uschar *, uschar **);
Index: mime.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/mime.c,v
retrieving revision 1.12
diff -u -r1.12 mime.c
--- mime.c    16 Aug 2005 12:32:32 -0000    1.12
+++ mime.c    16 Aug 2005 15:10:33 -0000
@@ -656,7 +656,7 @@
     mime_is_coverletter = !(context && context->context == MBC_ATTACHMENT);


     /* call ACL handling function */
-    rc = acl_check(ACL_WHERE_MIME, NULL, acl, user_msgptr, log_msgptr);
+    rc = acl_check(ACL_WHERE_MIME, NULL, NULL, acl, user_msgptr, log_msgptr);


     mime_stream = NULL;
     mime_current_boundary = NULL;
Index: receive.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/receive.c,v
retrieving revision 1.22
diff -u -r1.22 receive.c
--- receive.c    1 Aug 2005 14:41:25 -0000    1.22
+++ receive.c    16 Aug 2005 15:10:33 -0000
@@ -2927,7 +2927,8 @@
     if (acl_smtp_data != NULL && recipients_count > 0)
       {
       uschar *user_msg, *log_msg;
-      rc = acl_check(ACL_WHERE_DATA, NULL, acl_smtp_data, &user_msg, &log_msg);
+      rc = acl_check(ACL_WHERE_DATA, NULL, NULL, acl_smtp_data,
+        &user_msg, &log_msg);
       add_acl_headers(US"DATA");
       if (rc == DISCARD)
         {
@@ -2967,7 +2968,8 @@
     if (acl_not_smtp != NULL)
       {
       uschar *user_msg, *log_msg;
-      rc = acl_check(ACL_WHERE_NOTSMTP, NULL, acl_not_smtp, &user_msg, &log_msg);
+      rc = acl_check(ACL_WHERE_NOTSMTP, NULL, NULL, acl_not_smtp,
+    &user_msg, &log_msg);
       if (rc == DISCARD)
         {
         recipients_count = 0;
Index: smtp_in.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/smtp_in.c,v
retrieving revision 1.22
diff -u -r1.22 smtp_in.c
--- smtp_in.c    2 Aug 2005 15:19:20 -0000    1.22
+++ smtp_in.c    16 Aug 2005 15:10:33 -0000
@@ -1547,8 +1547,8 @@
   int rc;
   uschar *user_msg, *log_msg;
   smtp_data = US"in \"connect\" ACL";    /* For logged failure message */
-  rc = acl_check(ACL_WHERE_CONNECT, US"", acl_smtp_connect, &user_msg,
-    &log_msg);
+  rc = acl_check(ACL_WHERE_CONNECT, US"", NULL, acl_smtp_connect,
+    &user_msg, &log_msg);
   if (rc != OK)
     {
     (void)smtp_handle_acl_fail(ACL_WHERE_CONNECT, rc, user_msg, log_msg);
@@ -2179,8 +2179,8 @@


     if (acl_smtp_auth != NULL)
       {
-      rc = acl_check(ACL_WHERE_AUTH, smtp_data, acl_smtp_auth, &user_msg,
-        &log_msg);
+      rc = acl_check(ACL_WHERE_AUTH, smtp_data, NULL, acl_smtp_auth,
+        &user_msg, &log_msg);
       if (rc != OK)
         {
         done = smtp_handle_acl_fail(ACL_WHERE_AUTH, rc, user_msg, log_msg);
@@ -2443,8 +2443,8 @@


     if (acl_smtp_helo != NULL)
       {
-      rc = acl_check(ACL_WHERE_HELO, smtp_data, acl_smtp_helo, &user_msg,
-        &log_msg);
+      rc = acl_check(ACL_WHERE_HELO, smtp_data, NULL, acl_smtp_helo,
+        &user_msg, &log_msg);
       if (rc != OK)
         {
         done = smtp_handle_acl_fail(ACL_WHERE_HELO, rc, user_msg, log_msg);
@@ -2751,7 +2751,7 @@
           else
             {
             ignore_msg = US"rejected by ACL";
-            rc = acl_check(ACL_WHERE_MAILAUTH, NULL, acl_smtp_mailauth,
+            rc = acl_check(ACL_WHERE_MAILAUTH, NULL, NULL, acl_smtp_mailauth,
               &user_msg, &log_msg);
             }


@@ -2905,7 +2905,8 @@
     /* Apply an ACL check if one is defined, before responding */


     rc = (acl_smtp_mail == NULL)? OK :
-      acl_check(ACL_WHERE_MAIL, NULL, acl_smtp_mail, &user_msg, &log_msg);
+      acl_check(ACL_WHERE_MAIL, smtp_data, NULL, acl_smtp_mail,
+        &user_msg, &log_msg);


     if (rc == OK || rc == DISCARD)
       {
@@ -3063,7 +3064,8 @@
     for them. Otherwise, check the access control list for this recipient. */


     rc = recipients_discarded? DISCARD :
-      acl_check(ACL_WHERE_RCPT, recipient, acl_smtp_rcpt, &user_msg, &log_msg);
+      acl_check(ACL_WHERE_RCPT, smtp_data, recipient, acl_smtp_rcpt,
+        &user_msg, &log_msg);


     /* The ACL was happy */


@@ -3137,8 +3139,8 @@
     if (acl_smtp_predata == NULL) rc = OK; else
       {
       enable_dollar_recipients = TRUE;
-      rc = acl_check(ACL_WHERE_PREDATA, NULL, acl_smtp_predata, &user_msg,
-        &log_msg);
+      rc = acl_check(ACL_WHERE_PREDATA, NULL, NULL, acl_smtp_predata,
+        &user_msg, &log_msg);
       enable_dollar_recipients = FALSE;
       }


@@ -3158,8 +3160,8 @@


     case VRFY_CMD:
-    rc = acl_check(ACL_WHERE_VRFY, smtp_data, acl_smtp_vrfy, &user_msg,
-      &log_msg);
+    rc = acl_check(ACL_WHERE_VRFY, smtp_data, NULL, acl_smtp_vrfy,
+      &user_msg, &log_msg);
     if (rc != OK)
       done = smtp_handle_acl_fail(ACL_WHERE_VRFY, rc, user_msg, log_msg);
     else
@@ -3206,8 +3208,8 @@



     case EXPN_CMD:
-    rc = acl_check(ACL_WHERE_EXPN, smtp_data, acl_smtp_expn, &user_msg,
-      &log_msg);
+    rc = acl_check(ACL_WHERE_EXPN, smtp_data, NULL, acl_smtp_expn,
+      &user_msg, &log_msg);
     if (rc != OK)
       done = smtp_handle_acl_fail(ACL_WHERE_EXPN, rc, user_msg, log_msg);
     else
@@ -3237,8 +3239,8 @@


     if (acl_smtp_starttls != NULL)
       {
-      rc = acl_check(ACL_WHERE_STARTTLS, NULL, acl_smtp_starttls, &user_msg,
-        &log_msg);
+      rc = acl_check(ACL_WHERE_STARTTLS, NULL, NULL, acl_smtp_starttls,
+        &user_msg, &log_msg);
       if (rc != OK)
         {
         done = smtp_handle_acl_fail(ACL_WHERE_STARTTLS, rc, user_msg, log_msg);
@@ -3343,7 +3345,8 @@


     if (acl_smtp_quit != NULL)
       {
-      rc = acl_check(ACL_WHERE_QUIT, US"", acl_smtp_quit,&user_msg,&log_msg);
+      rc = acl_check(ACL_WHERE_QUIT, US"", NULL, acl_smtp_quit,
+        &user_msg, &log_msg);
       if (rc == ERROR)
         log_write(0, LOG_MAIN|LOG_PANIC, "ACL for QUIT returned ERROR: %s",
           log_msg);
@@ -3435,8 +3438,8 @@
     log_write(L_etrn, LOG_MAIN, "ETRN %s received from %s", smtp_data,
       host_and_ident(FALSE));


-    rc = acl_check(ACL_WHERE_ETRN, smtp_data, acl_smtp_etrn, &user_msg,
-      &log_msg);
+    rc = acl_check(ACL_WHERE_ETRN, smtp_data, NULL, acl_smtp_etrn,
+      &user_msg, &log_msg);
     if (rc != OK)
       {
       done = smtp_handle_acl_fail(ACL_WHERE_ETRN, rc, user_msg, log_msg);