]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Support authenticated users in CGP helper
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Apr 2018 16:17:01 +0000 (17:17 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Apr 2018 16:17:01 +0000 (17:17 +0100)
utils/cgp_rspamd.pl

index 78ca89462e92a7c22cd7d85a8d1005889dc00d0a..6851e6dd4583f40f4b21889868b8bb307458a55b 100644 (file)
@@ -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,