Bug 5169 - test for real name in message matching real name in Unix GECOS
Summary: test for real name in message matching real name in Unix GECOS
Status: RESOLVED WONTFIX
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Rules (Eval Tests) (show other bugs)
Version: 3.1.7
Hardware: Other other
: P5 enhancement
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-06 18:22 UTC by Andrew Daviel
Modified: 2006-11-06 18:36 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Daviel 2006-11-06 18:22:49 UTC
had some spam recently with things like
To: Mary Poppins <joan@example.com>

the following tries to tag that, assuming that there was an entry like
"Joan Higgins" in GECOS and not "Higgins - Joan"

sub check_realname {
                                                                               
                                         
# Andrew Daviel, TRIUMF, Nov 2006
# add to site_perl/xxx/Mail/SpamAssassin/EvalTests.pm
                                                                               
                                         
# header NOTGECOS  eval:check_realname('to')
# describe NOTGECOS Real name in To does not match GECOS
                                                                               
                                         
# header NOTGECOSCC  eval:check_realname('cc')
# describe NOTGECOSCC Real name in Cc does not match GECOS
                                                                               
                                         
  my ($self, $dest) = @_;
  my $lastname ;
  my $notreal = 0 ;
                                                                               
                                         
  my $to = $self->get('To') ;
  my $cc =  $self->get('Cc') ;
  my ($user,$passwd,$uid,$gid, $quota,$comment,$gcos,$dir,$shell,$expire) =
getpwuid($>) ;
  my ($cn,$room,$tel) = split(/,/,$gcos) ;
  if ($cn =~ /[\s](.*)$/) { $lastname = $1 ; }
  if (defined($lastname)) {
    if ($dest eq 'to' and $to =~ /(?<!$lastname)"{0,1} <$user/) {
      $notreal = 1 ;
    }
    if ($dest eq 'cc' and $cc =~ /(?<!$lastname)"{0,1} <$user/) {
      $notreal = 1 ;
    }
  }
  return $notreal ;
}
                                                                               
                                         
1;
Comment 1 Theo Van Dinter 2006-11-06 18:36:42 UTC
Thanks for your code snippet.  However, I think it's too specific for your
environment to be used in the general code (for instance, it assumes the user
running the code is the recipient, doesn't deal with virtual users, doesn't work
on Windows, etc.)  I would recommend making it a plugin and posting it on the
wiki.  :)