Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't work #2

Open
jranma opened this issue Jan 29, 2021 · 3 comments
Open

don't work #2

jranma opened this issue Jan 29, 2021 · 3 comments

Comments

@jranma
Copy link

jranma commented Jan 29, 2021

Hello
Just installed razorfly. Doesn't work

Here is log:

janv. 29 13:23:12 saturne razorfy.pl[33233]: RAZORFY started, PID: 33233 Waiting for client connections...
janv. 29 13:23:40 saturne razorfy.pl[33233]: active threads: -1
janv. 29 13:23:40 saturne razorfy.pl[33233]: client array length: 1
janv. 29 13:23:40 saturne razorfy.pl[33233]: Accepted New Client Connection From:127.0.0.1:56350
janv. 29 13:23:40 saturne razorfy.pl[33233]: Use of uninitialized value within %logret in concatenation (.) or string at /usr/local/bin/razorfy.pl line 117, line 36.
janv. 29 13:23:40 saturne razorfy.pl[33233]: return value:
janv. 29 13:23:40 saturne razorfy.pl[33233]: Thread 1 terminated abnormally: IO::Socket::INET: connect: Operation already in progress at /usr/local/bin/razorfy.pl line 77, line 36.

OS: Debian buster

@Happy86
Copy link
Contributor

Happy86 commented Oct 18, 2023

For what it's worth (more than 2 years later 🤷‍♂️):

  1. You are probably using an old Version.
    1. IO::Socket::INET is - as far as I know - deprectated. The current version uses IO::Socket::IP.
    2. Replace the razorfy.pl with https://raw.githubusercontent.com/HeinleinSupport/razorfy/master/razorfy.pl on your server.
  2. If it still does not work (after updating): Can you please add
my $fail = 0;
if ( not defined($ret) )
{
  $ret = 'unfortunately $ret is NOT defined';
  $fail = 1;
}

print STDERR 'Content of $ret:"'.$ret.'"'."\n";

if ( $fail )
{
  exit(1);
}

between lines 115 and 117 and paste the output in this issue.

edit: changed debug codeblock

@Happy86
Copy link
Contributor

Happy86 commented Oct 19, 2023

Theory

https://metacpan.org/release/TODDR/Razor2-Client-Agent-2.86/source/lib/Razor2/Client/Agent.pm#L449 defines

# returns 0 if match (spam)
# returns 1 if no match (legit)
# returns 2 if error

for the checkit sub.

But razorfy.pl just defines

my %logret = ( 0 => 'spam', 1 => 'ham');

If the checkit sub from Razor2::Client::Agent returns 2 (error) instead of "ham" or "spam" my $ret = $agent->checkit(\%hashr); in ) stores a 2.

When this value is later used in

ErrorLog( "return value: ". $logret{$ret} ) if $debug;

there is not a key in the %logret hash defined at the top of the script and hence the value is not initialized (for this non-existent key).

Solution

Changing the %logret hash to

my %logret = ( 0 => 'spam', 1 => 'ham', 2 => 'error' );

should solve this problem.

Side note

Also it's interesting that if the Razor2 Agent (Razor2::Client::Agent) returns an error through print $client_socket ( $ret == 0) ? "spam" : "ham"; it will be marked as ham.

Though this might be a good design decision because if the Razor2 Agent just fails a lot of good emails (ham) might be flagged as spam and people might loose important mails. So this is probably for the best?

@Happy86
Copy link
Contributor

Happy86 commented Oct 20, 2023

Thinking about it a bit more: The problem is not that razorfy.pl is broken but that at the moment it gives you misleading error messages.

The problem probably lies with razor / Rspamd (or the Library Razor2::Client::Agent used to communicate with those) that returns an error that razorfy.pl does not handle and therefore gives unhelpful output. 🫤

So the following patch for razorfy.pl

- my %logret = ( 0 => 'spam', 1 => 'ham');
+ my %logret = ( 0 => 'spam', 1 => 'ham', 2 => 'Error: razor / Rspamd or Razor2::Client:Agent may be broken as it returns an error.' );

is maybe more truthful. 😅 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants