From: Vsevolod Stakhov Date: Thu, 19 Apr 2018 16:17:01 +0000 (+0100) Subject: [Minor] Support authenticated users in CGP helper X-Git-Tag: 1.7.4~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cce0110d9ec635c47b8c557e3ecaa9c0936671a2;p=rspamd.git [Minor] Support authenticated users in CGP helper --- diff --git a/utils/cgp_rspamd.pl b/utils/cgp_rspamd.pl index 78ca89462..6851e6dd4 100644 --- a/utils/cgp_rspamd.pl +++ b/utils/cgp_rspamd.pl @@ -192,6 +192,7 @@ sub rspamd_scan { my $from; my @rcpts; my $ip; + my $user; foreach my $elt (@envelope) { if ( $elt =~ /^P\s[^<]*(<[^>]*>).*$/ ) { @@ -200,8 +201,13 @@ sub rspamd_scan { elsif ( $elt =~ /^R\s[^<]*(<[^>]*>).*$/ ) { push @rcpts, $1; } - elsif ( $elt =~ /^S .*\[(.+)\]/ ) { - $ip = $1; + elsif ( $elt =~ /^S (?:<([^>]+)>)?\s*S.*\[(.+)\]/ ) { + if ($1) { + $user = $1; + } + if ($2) { + $ip = $2; + } } } @@ -221,6 +227,10 @@ sub rspamd_scan { $headers->{IP} = $ip; } + if ($user) { + $headers->{User} = $user; + } + http_post( "http://$rspamd_host/checkv2", $data, timeout => $request_timeout,