OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: "DOT response with hostname" patch on postfix 2.5

From: Victor Duchovni (Victor.Duchovnimorganstanley.com)
Date: Tue Apr 22 2008 - 09:35:15 CDT


On Tue, Apr 22, 2008 at 06:28:42PM +0530, ram wrote:

> Some time ago a patch was posted on this list to get postfix respond
> with hostname in the DSN
>
>
> I am trying this patch on postfix 2.5.1 but that doesnt work
> When I try to patch by hand, I am lost at "postfix/src/smtpd/smtpd.c"
> The line numbers dont match , but I think the code base has also
> changed
>
> Can I get the updated patch for 2.5.1 stable if possible

Use at your own risk (cd postfix-2.5.1/; patch -p1 < /patch/file).

Index: postfix/html/postconf.5.html
*** postfix/html/postconf.5.html:1.1.1.8 Sun Oct 7 17:07:50 2007
--- postfix/html/postconf.5.html Mon Oct 22 14:44:34 2007
***************
*** 9656,9661 ****
--- 9656,9681 ----
  
  </DD>
  
+ <DT><b><a name="smtpd_dot_response_name">smtpd_dot_response_name</a>
+ (default: empty)</b></DT><DD>
+
+ <p> Include the specified MTA name in 250 responses to end-of-data. This
+ makes message tracking easier through clustered servers behind a
+ load-balancer. Sending systems (such as Postfix) that log the end-of-data
+ (DOT) response will now record which machine in the cluster received
+ the message. </p>
+
+ <p> Example: </p>
+
+ <pre>
+ <a href="postconf.5.html#smtpd_dot_response_name">smtpd_dot_response_name</a> = $<a href="postconf.5.html#myhostname">myhostname</a>
+ </pre>
+
+ <p> This feature is available in Postfix 2.5 and later. </p>
+
+
+ </DD>
+
  <DT><b><a name="smtpd_end_of_data_restrictions">smtpd_end_of_data_restrictions</a>
  (default: empty)</b></DT><DD>
  
Index: postfix/html/smtpd.8.html
*** postfix/html/smtpd.8.html:1.1.1.8 Sun Oct 7 17:07:54 2007
--- postfix/html/smtpd.8.html Mon Oct 22 14:44:34 2007
***************
*** 1125,1130 ****
--- 1125,1134 ----
  
         Available in Postfix version 2.5 and later:
  
+ <b><a href="postconf.5.html#smtpd_dot_response_name">smtpd_dot_response_name</a> (empty)</b>
+ Include the specified MTA name in 250 responses to
+ end-of-data.
+
         <b><a href="postconf.5.html#smtpd_client_port_logging">smtpd_client_port_logging</a> (no)</b>
                Enable logging of the remote SMTP client port in
                addition to the hostname and IP address.
Index: postfix/man/man5/postconf.5
*** postfix/man/man5/postconf.5:1.1.1.8 Sun Oct 7 17:08:02 2007
--- postfix/man/man5/postconf.5 Mon Oct 22 14:44:35 2007
***************
*** 5749,5754 ****
--- 5749,5772 ----
  .IP \(bu
  Use the smtpd_discard_ehlo_keyword_address_maps feature
  to discard EHLO keywords selectively.
+ .SH smtpd_dot_response_name (default: empty)
+ Include the specified MTA name in 250 responses to end-of-data. This
+ makes message tracking easier through clustered servers behind a
+ load-balancer. Sending systems (such as Postfix) that log the end-of-data
+ (DOT) response will now record which machine in the cluster received
+ the message.
+ .PP
+ Example:
+ .PP
+ .nf
+ .na
+ .ft C
+ smtpd_dot_response_name = $myhostname
+ .fi
+ .ad
+ .ft R
+ .PP
+ This feature is available in Postfix 2.5 and later.
  .SH smtpd_end_of_data_restrictions (default: empty)
  Optional access restrictions that the Postfix SMTP server
  applies in the context of the SMTP END-OF-DATA command.
Index: postfix/man/man8/smtpd.8
*** postfix/man/man8/smtpd.8:1.1.1.7 Sun Oct 7 17:08:05 2007
--- postfix/man/man8/smtpd.8 Mon Oct 22 14:44:35 2007
***************
*** 885,890 ****
--- 885,892 ----
  terminate the session with a 221 code.
  .PP
  Available in Postfix version 2.5 and later:
+ .IP "\fBsmtpd_dot_response_name (empty)\fR"
+ Include the specified MTA name in 250 responses to end-of-data.
  .IP "\fBsmtpd_client_port_logging (no)\fR"
  Enable logging of the remote SMTP client port in addition to
  the hostname and IP address.
Index: postfix/mantools/postlink
*** postfix/mantools/postlink:1.1.1.7 Sun Oct 7 17:08:07 2007
--- postfix/mantools/postlink Mon Oct 22 14:44:35 2007
***************
*** 456,461 ****
--- 456,462 ----
      s;\bsmtpd_delay_reject\b;<a href="postconf.5.html#smtpd_delay_reject">$&</a>;g;
      s;\bsmtpd_discard_ehlo_keyword_address_maps\b;<a href="postconf.5.html#smtpd_discard_ehlo_keyword_address_maps">$&</a>;g;
      s;\bsmtpd_discard_ehlo_keywords\b;<a href="postconf.5.html#smtpd_discard_ehlo_keywords">$&</a>;g;
+ s;\bsmtpd_dot_response_name\b;<a href="postconf.5.html#smtpd_dot_response_name">$&</a>;g;
      s;\bsmtpd_end_of_data_restrictions\b;<a href="postconf.5.html#smtpd_end_of_data_restrictions">$&</a>;g;
      s;\bsmtpd_error_sleep_time\b;<a href="postconf.5.html#smtpd_error_sleep_time">$&</a>;g;
      s;\bsmtpd_etrn_restrictions\b;<a href="postconf.5.html#smtpd_etrn_restrictions">$&</a>;g;
Index: postfix/proto/postconf.proto
*** postfix/proto/postconf.proto:1.1.1.8 Sun Oct 7 17:08:16 2007
--- postfix/proto/postconf.proto Mon Oct 22 14:44:35 2007
***************
*** 10523,10528 ****
--- 10523,10545 ----
  
  <p> This feature is available in Postfix 2.3 and later. </p>
  
+ %PARAM smtpd_dot_response_name
+
+ <p> Include the specified MTA name in 250 responses to end-of-data. This
+ makes message tracking easier through clustered servers behind a
+ load-balancer. Sending systems (such as Postfix) that log the end-of-data
+ (DOT) response will now record which machine in the cluster received
+ the message. </p>
+
+ <p> Example: </p>
+
+ <pre>
+ # Easiest to use $myhostname when different on each cluster node:
+ smtpd_dot_response_name = $myhostname
+ </pre>
+
+ <p> This feature is available in Postfix 2.5 and later. </p>
+
  %PARAM smtpd_tls_always_issue_session_ids yes
  
  <p> Force the Postfix SMTP server to issue a TLS session id, even
Index: postfix/src/global/mail_params.h
*** postfix/src/global/mail_params.h:1.1.1.7 Sun Oct 7 17:08:35 2007
--- postfix/src/global/mail_params.h Mon Oct 22 14:44:36 2007
***************
*** 1074,1079 ****
--- 1074,1083 ----
  #define DEF_SMTPD_BANNER "$myhostname ESMTP $mail_name"
  extern char *var_smtpd_banner;
  
+ #define VAR_SMTPD_DOT_NAME "smtpd_dot_response_name"
+ #define DEF_SMTPD_DOT_NAME ""
+ extern char *var_smtpd_dot_name;
+
  #define VAR_SMTPD_TMOUT "smtpd_timeout"
  #define DEF_SMTPD_TMOUT "300s"
  extern int var_smtpd_tmout;
Index: postfix/src/smtpd/smtpd.c
*** postfix/src/smtpd/smtpd.c:1.1.1.10 Sun Oct 7 17:09:05 2007
--- postfix/src/smtpd/smtpd.c Mon Oct 22 14:44:37 2007
***************
*** 831,836 ****
--- 831,838 ----
  /* terminate the session with a 221 code.
  /* .PP
  /* Available in Postfix version 2.5 and later:
+ /* .IP "\fBsmtpd_dot_response_name (empty)\fR"
+ /* Include the specified MTA name in 250 responses to end-of-data.
  /* .IP "\fBsmtpd_client_port_logging (no)\fR"
  /* Enable logging of the remote SMTP client port in addition to
  /* the hostname and IP address.
***************
*** 1129,1134 ****
--- 1131,1137 ----
  char *var_milt_data_macros;
  char *var_milt_eod_macros;
  char *var_milt_unk_macros;
+ char *var_smtpd_dot_name;
  bool var_smtpd_client_port_log;
  
   /*
***************
*** 2848,2856 ****
          state->error_count = 0;
          state->error_mask = 0;
          state->junk_cmds = 0;
          if (state->queue_id)
! smtpd_chat_reply(state,
! "250 2.0.0 Ok: queued as %s", state->queue_id);
          else
              smtpd_chat_reply(state, "%s", STR(state->proxy_buffer));
      } else if ((state->err & CLEANUP_STAT_DEFER) != 0) {
--- 2851,2867 ----
          state->error_count = 0;
          state->error_mask = 0;
          state->junk_cmds = 0;
+ /*
+ * We assume that transparent pre-queue proxies will expose any
+ * hostname sent by the final non-proxy SMTP server.
+ */
          if (state->queue_id)
! if (*var_smtpd_dot_name)
! smtpd_chat_reply(state, "250 2.0.0 %s Ok: queued as %s",
! var_smtpd_dot_name, state->queue_id);
! else
! smtpd_chat_reply(state, "250 2.0.0 Ok: queued as %s",
! state->queue_id);
          else
              smtpd_chat_reply(state, "%s", STR(state->proxy_buffer));
      } else if ((state->err & CLEANUP_STAT_DEFER) != 0) {
***************
*** 4717,4722 ****
--- 4728,4734 ----
  #endif
          VAR_SMTPD_TLS_LEVEL, DEF_SMTPD_TLS_LEVEL, &var_smtpd_tls_level, 0, 0,
          VAR_SMTPD_SASL_TYPE, DEF_SMTPD_SASL_TYPE, &var_smtpd_sasl_type, 1, 0,
+ VAR_SMTPD_DOT_NAME, DEF_SMTPD_DOT_NAME, &var_smtpd_dot_name, 0, 0,
          VAR_SMTPD_MILTERS, DEF_SMTPD_MILTERS, &var_smtpd_milters, 0, 0,
          VAR_MILT_CONN_MACROS, DEF_MILT_CONN_MACROS, &var_milt_conn_macros, 0, 0,
          VAR_MILT_HELO_MACROS, DEF_MILT_HELO_MACROS, &var_milt_helo_macros, 0, 0,

--
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:majordomopostfix.org?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.