diff options
-rw-r--r-- | tools/skrewt.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/tools/skrewt.c b/tools/skrewt.c index daa3224..a7e144f 100644 --- a/tools/skrewt.c +++ b/tools/skrewt.c @@ -184,6 +184,7 @@ public: string proximta_HELO; string proximta_rDNS; string proximta_IP; + string proximta_AuthUser; string return_path; // envelope MAIL FROM string boundary; string to; @@ -222,6 +223,14 @@ Received: from 24-145-119-127-dhcp.gsv.md.atlanticbb.net (HELO mail.phys-l.org) Received: from ip68-231-191-153.tc.ph.cox.net (HELO asclepias.av8n.net) (smtp@68.231.191.153) by cloud.av8n.com with SMTP; 15 Jul 2012 14:39:58 -0000 #endif +#if 0 /* good for testing */ +/home/jsd/Maildir/cur/1343769926.24228.cloud\:2\, + +// The following msg has no message-id, but does have an +// authorized submitter: +/home/jsd/Maildir/cur/1342363199.24320.cloud:2, +#endif + int skrewt::krunch_rfrom(){ stringstream parse; parse.str(received_from); @@ -237,11 +246,22 @@ int skrewt::krunch_rfrom(){ if (word == "(HELO") { parse >> proximta_HELO; proximta_HELO = rtrim(proximta_HELO, "()"); + parse >> word; } else { proximta_HELO = proximta_rDNS; } - - + size_t len = word.length(); + if (len<2 || word[0] != '(' || word[len-1] != ')') { + cerr << progid << " bad 'Received: from' line ;;; '" + << word << "'" << endl; + return ex_syserr; + } + proximta_IP = word.substr(1, len-2); + size_t where = proximta_IP.find("@"); + if (where != string::npos){ + proximta_AuthUser = proximta_IP.substr(0, where); + proximta_IP = proximta_IP.substr(1+where); + } return 0; } @@ -335,9 +355,11 @@ int skrewt::interstage(){ cerr << " Received: " << received_from <<endl; int rslt = krunch_rfrom(); if (rslt) return rslt; - cerr << " rDNS: " << proximta_rDNS << endl; - cerr << " HELO: " << proximta_HELO << endl; - cerr << " Mid '" << message_id << "'" << endl; + cerr << " rDNS: " << proximta_rDNS << endl; + cerr << " HELO: " << proximta_HELO << endl; + cerr << " IP: " << proximta_IP << endl; + cerr << " AuthUser: " << proximta_AuthUser << endl; + cerr << " Mid '" << message_id << "'" << endl; // The logic here is: In order: // 1) If whitelisted, accept. No greylisting, no spam-checking. |