From 3f3c46c8ee8ef118ce73da7d3235364edf390cfe Mon Sep 17 00:00:00 2001 From: John Denker Date: Tue, 31 Jul 2012 18:05:47 -0700 Subject: possibly working parse of the 'Received: from' line --- tools/skrewt.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'tools') 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 <