[Exim] How can local_scan write to the SMTP socket directly?

Pàgina inicial
Delete this message
Reply to this message
Autor: Marc MERLIN
Data:  
A: exim-users
Assumpte: [Exim] How can local_scan write to the SMTP socket directly?
SA-Exim uses a dirty trick to talk directly to the smtp socket for
teergrubing.

I specifically do this:

for (i=0;i<SAteergrubetime/10;i++)
{
    char *str;


    /* Unfortunately, we can't use exim's smtp_printf because it *
    doesn't return an error code if the write gets an EPIPE. * So, we
    write ourselves, but this won't work if you have a * TLS connection
    opened (that said, if you are teergrubing * a TLS connection, it's
    probably a relay host, not a * spammer, and in this case you should
    not teergrube a * friendly relay, so basically we should be ok). *
    If you do teergrube an SSL connection with the current * code, you
    will break it, but that's acceptable */
    str=string_sprintf(string_sprintf("451- %s\r\n",SAmsgteergrubewait), spamstatus);
    /* We cheat, stderr happens to go to the SMTP socket */
    ret=write(2, str, strlen(str));
    if (ret < 0)
    {
    log_write(0, LOG_MAIN | LOG_REJECT, "SA: Action: teergrubed sender for %d secs until it closed the connection: %s (scanned in %d/%d secs). %s", i*10, spamstatus, scantime, fulltime, mailinfo);
    /* The other side closed the connection, nothing to print */
    *return_text="";
    return LOCAL_SCAN_TEMPREJECT_NOLOGHDR;
    }
    sleep(10);
}



This worked up to exim 4.14, but I'm getting a report that stderr now goes
to the exim mainlog with exim 4.20.

Here's my question:
I need a way to write to SMTP socket. Either myself, or with an smtp_printf
that actually notices if the other side isn't listening anymore (i.e.
I need a return code saying that the other side isn't there, so that I
don't stupidly output data into a socket that's not going anywhere).

How do I do this with exim 4.20? :)

Thanks
Marc
--
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems & security ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/   |   Finger marc_f@??? for PGP key