OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: header_if_reject

From: Piotr KUCHARSKI (chopinsgh.waw.pl)
Date: Mon Feb 07 2005 - 07:45:47 CST


On Wed, Feb 02, 2005 at 01:34:07PM +0100, Piotr KUCHARSKI wrote:
> Is there (or is planned) a keyword like "header_if_reject", which
> would insert some header to mail instead of rejecting it?
> It would be invaluable combined with reject_rbl_* and reject_unverified_*
> so people could still get their mail but have them already tagged.
> warn_if_reject is nice, but it's for sysadmin (and hardly usable
> for online mail scoring/filtering).

Instead of adding header_if_reject, I reused warn_if_reject -- if it
warns in system logs, it can warn in mails, too, right?

--- smtpd_check.c.org Sat Dec 27 03:54:03 2003
+++ smtpd_check.c Mon Feb 7 14:34:55 2005
-793,6 +793,17
      */
     log_whatsup(state, whatsup, STR(error_text));

+ if (warn_if_reject) {
+ VSTRING *hbuf = vstring_alloc(100);
+
+ if (state->prepend == 0)
+ state->prepend = argv_alloc(1);
+
+ vstring_sprintf(hbuf, "X-Reject-Warning: %s", STR(error_text));
+ argv_add(state->prepend, STR(hbuf), (char *) 0);
+ vstring_free(hbuf);
+ }
+
     return (warn_if_reject ? 0 : SMTPD_CHECK_REJECT);
 }

It does what I want, but perhaps someone could improve it? I am not
quite sure about vstring* stuff.

Anyway, the result is mail like this:

    From blahblahsgh.waw.pl Mon Feb 7 14:28:59 2005
    Return-Path: <blahblahsgh.waw.pl>
    X-Original-To: chopinakson.sgh.waw.pl
    Delivered-To: chopinakson.sgh.waw.pl
    Received: from alternator.sgh.waw.pl (alternator.sgh.waw.pl [194.145.96.100])
            by akson.sgh.waw.pl (Postfix) with ESMTP id 3AA543C6F
            for <chopinakson.sgh.waw.pl>; Mon, 7 Feb 2005 14:28:59 +0100 (CET)
    Received: from localhost (localhost [127.0.0.1])
            by alternator.sgh.waw.pl (Postfix) with SMTP id EA4152AA264
            for <chopinakson.sgh.waw.pl>; Mon, 7 Feb 2005 14:28:58 +0100 (CET)
    X-Reject-Warning: 550 <blahblahsgh.waw.pl>: Sender address rejected: undeliverable
            address: host akson.sgh.waw.pl[194.145.96.12] said: 550
            <blahblahakson.sgh.waw.pl>: Recipient address rejected: User unknown in
            local recipient table (in reply to RCPT TO command)
    Received: from rotanretla.sgh.waw.pl (rotanretla.sgh.waw.pl [194.145.96.25])
            by alternator.sgh.waw.pl (Postfix) with ESMTP id E9DC02AA25C
            for <chopinsgh.waw.pl>; Mon, 7 Feb 2005 14:28:54 +0100 (CET)
    Subject: testink
    From: blahblahsgh.waw.pl
    Message-Id: <20050207132854.E9DC02AA25Calternator.sgh.waw.pl>
    Date: Mon, 7 Feb 2005 14:28:54 +0100 (CET)
    To: chopinsgh.waw.pl
    Content-Length: 11
    Lines: 1
    
    test

Which is sufficient to filter on.

p.

--
Beware of he who would deny you access to information, for in his
heart he dreams himself your master. -- Commissioner Pravin Lal
http://nerdquiz.sgh.waw.pl/ -- polska wersja quizu dla nerdów ;)