[exim-dev] [PATCH] fake_response in spool_in/out and allow e…

Etusivu
Poista viesti
Vastaa
Lähettäjä: Bjørnar Ness
Päiväys:  
Vastaanottaja: exim-dev
Kopio: Bjørnar Ness
Aihe: [exim-dev] [PATCH] fake_response in spool_in/out and allow expansion
It is often if not allways useful to know if a message is
fake_rejected/deferred. This patch adds the existing fake_reject
variable to spool_out/spool_in and adds a $fake_response variable
that expands to the string equivalent of the variable, meaning::

REJECT -> fake_reject
DEFER  -> fake_defer
OK     -> no fake_reject/fake_defer


imho it makes sense to have a standard variable for this, instead
of needing to set custom acl_m variables
---
 src/src/expand.c    | 13 +++++++++++++
 src/src/spool_in.c  |  3 +++
 src/src/spool_out.c |  1 +
 3 files changed, 17 insertions(+)


diff --git a/src/src/expand.c b/src/src/expand.c
index cfde236..24ab0c0 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -438,6 +438,7 @@ typedef struct {
int *length;
} alblock;

+static uschar * fn_fake_response(void);
static uschar * fn_recipients(void);

 /* This table must be kept in alphabetical order. */
@@ -536,6 +537,7 @@ static var_entry var_table[] = {
   { "exim_path",           vtype_stringptr,   &exim_path },
   { "exim_uid",            vtype_uid,         &exim_uid },
   { "exim_version",        vtype_stringptr,   &version_string },
+  { "fake_response",       vtype_string_func, &fn_fake_response },
   { "headers_added",       vtype_string_func, &fn_hdrs_added },
   { "home",                vtype_stringptr,   &deliver_home },
   { "host",                vtype_stringptr,   &deliver_host },
@@ -1689,6 +1691,17 @@ if (!enable_dollar_recipients) return NULL; else
   }
 }


+/*************************************************
+*              Return string fake_response       *
+*************************************************/
+static uschar *
+fn_fake_response(void)
+{
+  if (fake_response == OK)
+    return US"OK";
+
+  return fake_response == DEFER ? US"DEFER" : US"REJECT";
+}


 /*************************************************
 *               Find value of a variable         *
diff --git a/src/src/spool_in.c b/src/src/spool_in.c
index e1d6e34..ebaa63b 100644
--- a/src/src/spool_in.c
+++ b/src/src/spool_in.c
@@ -260,6 +260,7 @@ deliver_firsttime = FALSE;
 deliver_freeze = FALSE;
 deliver_frozen_at = 0;
 deliver_manual_thaw = FALSE;
+fake_response = OK;
 /* dont_deliver must NOT be reset */
 header_list = header_last = NULL;
 host_lookup_deferred = FALSE;
@@ -534,6 +535,8 @@ for (;;)
       if (sscanf(CS big_buffer+7, TIME_T_FMT, &deliver_frozen_at) != 1)
     goto SPOOL_READ_ERROR;
       }
+    else if(Ustrncmp(p, "ake_response", 12) == 0)
+      fake_response = Uatoi(big_buffer + 14);
     break;


     case 'h':
diff --git a/src/src/spool_out.c b/src/src/spool_out.c
index e49d89a..34929dc 100644
--- a/src/src/spool_out.c
+++ b/src/src/spool_out.c
@@ -214,6 +214,7 @@ if (deliver_freeze) fprintf(f, "-frozen " TIME_T_FMT "\n", deliver_frozen_at);
 if (dont_deliver) fprintf(f, "-N\n");
 if (host_lookup_deferred) fprintf(f, "-host_lookup_deferred\n");
 if (host_lookup_failed) fprintf(f, "-host_lookup_failed\n");
+if (fake_response) fprintf(f, "-fake_response %d\n", fake_response);
 if (sender_local) fprintf(f, "-local\n");
 if (local_error_message) fprintf(f, "-localerror\n");
 if (local_scan_data != NULL) fprintf(f, "-local_scan %s\n", local_scan_data);
-- 
2.7.4