Search
j0ke.net Open Build Service
>
Projects
>
server:mail
>
qmail-spp-plugins
> ext_log.c
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File ext_log.c of Package qmail-spp-plugins
/* * Extended Log for qmail. - sromero at gmail dot com - 06-06-2007 * * Extends qmail-smtpd logs including From and To fields, for easier * tracking of emails and spammers: * * XXXX tcpserver: ok 18742 127.0.0.1:127.0.0.1:25 localhost:127.0.0.1::34402 * XXXX ext_log: IP <127.0.0.1> From <sromero@src.com> To <sromero@dest.com> * XXXX tcpserver: end 18742 status 0 * * * Usage: * Compile the plugin with "gcc -o ext_log ext_log.c" * Copy it to /var/qmail/plugins * Add this line to your /var/qmail/control/smtpplugins file: * * [rcpt] * plugins/ext_log * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * (Based in "spf.c" for qmail-spp, thanks for the source and ideas) */ #include <stdlib.h> #include <stdio.h> //--------------------------------------------------------------------------- int main( void ) { char *me, *remote, *helo, *sender, *recipient, *spf_env, *header; // Get environment variables provided by qmail-spp remote = getenv("TCPREMOTEIP"); me = getenv("TCPLOCALHOST"); if (!me) me = getenv("TCPLOCALIP"); if (!remote || !me) { fprintf(stderr, "ext_log: ERROR: can't get tcpserver variables.\n"); if(!remote) fprintf(stderr, "ext_log: can't read TCPREMOTEIP.\n"); else fprintf(stderr, "ext_log: can't read TCPLOCALHOST nor TCPLOCALIP.\n"); return 0; } sender = getenv("SMTPMAILFROM"); if (!sender) { fprintf(stderr, "ext_log: ERROR: can't get envelope sender address.\n"); fprintf(stderr, "ext_log: can't read SMTPMAILFROM.\n"); return 0; } if (!*sender) return 0; recipient = getenv("SMTPRCPTTO"); if (!recipient) { fprintf(stderr, "ext_log: ERROR: can't get destination address.\n"); fprintf(stderr, "ext_log: can't read SMTPRCPTTO.\n"); return 0; } // print data to stderr (qmail-smtpd log) fprintf(stderr, "ext_log: IP <%s> From <%s> To <%s>\n", remote, sender, recipient ); return 0; }