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

CustomCondition fail with 6.2.52 #844

Closed
fprigent opened this issue Jan 21, 2020 · 4 comments · Fixed by #847
Closed

CustomCondition fail with 6.2.52 #844

fprigent opened this issue Jan 21, 2020 · 4 comments · Fixed by #847
Labels
Milestone

Comments

@fprigent
Copy link

I used a simple CustomCondition to provide a confirmation receipt for some list.
When I upgrade to 6.2.52 many problems appeared, bu nearly all of them disappeared with #841 fixes, except for 2 lists which use this Custom Condition

Version

Sympa 6.2.52 plus patch provided by #841

Installation method

yum from http://Sympa-JA.org plus the patch

Expected behavior

a receipt.

Actual behavior

Same as #841 "Authorization not allowed" (in french).

Additional information

The log message

Jan 21 11:51:45 sympa sympa_msg[20085]: err main::#243 > Sympa::Spindle::spin#95 > Sympa::Spindle::AuthorizeMessage::_twist#106 > Sympa::Scenario::new#218 > Sympa::Scenario::compile#256 /home/sympa/etc/scenari/send.confirmation: Bareword "confirmation" not allowed while "strict subs" in use at (eval 752) line 15.#12\n

The scenario

[root@sympa mail_tt2]# more ../scenari/send.confirmation

title.gettext public list
CustomCondition::confirmation([list->address],"2000-01-01","2038-01-01",[sender],[msg_header->Subject]) smtp,smime,md5,dkim -> do_it
true() smtp,dkim,md5,smime -> do_it

Third the "pre-compiled version" of the script

#!/usr/bin/perl -w
use strict;
use warnings;

sub {
    my $that        = shift;
    my $context     = shift;
    my $auth_method = shift;

    die "No list context" unless ref $that eq 'Sympa::List';
    $context->{message} ||= Sympa::Message->new("\n");
    $context->{'sender'} //= '';

    if (grep {$auth_method eq $_} qw(dkim md5 pgp smime smtp)) {
        return {action => 'reject,quiet', condition => 'search(\'blacklist.txt\',[sender])'} if Sympa::Scenario::do_search($that, $context, 'blacklist.txt', $context->{sender});
    }
    return {action => 'editorkey,quiet', condition => 'match([msg->spam_status], /spam/)'} if ((exists $context->{message}{spam_status} ? $context->{message}{spam_status} : undef) =~ qr'spam');
    return {action => 'editorkey,quiet', condition => 'match([msg->spam_status], /unsure/)'} if ((exists $context->{message}{spam_status} ? $context->{message}{spam_status} : undef) =~ qr'unsure');
    return {action => 'do_it', condition => 'CustomCondition::confirmation([list->address],"2000-01-01","2038-01-01",[sender],[msg_header->Subject])'} if do_verify_custom($that, {action => 'do_it', auth_method => 'ARRAY(0x10dcd130)', condition => 'CustomCondition::confirmation([list->address],"2000-01-01","2038-01-01",[sender],[msg_header->Subject])', lineno => '2'}, confirmation, Sympa::get_address($that), '2000-01-01', '2038-01-01', $context->{sender}, [$context->{message}->get_header('Subject')]);
    return {action => 'do_it', condition => 'true()'} if 1;

    die {reason => 'no-rule-match'};
}

The customCondition is a lightly modified version of the contrib one...

#!/usr/bin/perl

package CustomCondition::confirmation;
 
use strict;
 
use English qw(-no_match_vars);
use MIME::EncWords;
 
use Sympa::Log;
use Sympa::List;
 
use Exporter;
our @EXPORT_OK = qw(verify);
 
my $log = Sympa::Log->instance;
 
sub verify {
    eval { require DateTime::Format::DateParse; };
    if ($EVAL_ERROR) {
        $log->syslog(
            'err',
            'Error requiring DateTime::Format::DateParse : %s (%s)',
            "$EVAL_ERROR",
            ref($EVAL_ERROR)
        );
        return 1;
    }
    my $list_address = shift;
    my $vacation_start = shift;
    my $vacation_end = shift;
    my $sender = shift;
    my $subject = shift;
 
    $subject = shift @$subject if ref $subject eq 'ARRAY';
    $subject = MIME::EncWords::decode_mimewords($subject);
 
    my $dt_start = DateTime::Format::DateParse->parse_datetime($vacation_start);
    my $dt_end   = DateTime::Format::DateParse->parse_datetime($vacation_end);
 
    unless($dt_start) {
        $log->syslog(
            'err',
            'Unable to parse date "%s"',
            $vacation_start
        );
        return 1;
    }
 
    unless($dt_end) {
        $log->syslog(
            'err',
            'Unable to parse date "%s"',
            $vacation_end
        );
        return 1;
    }
 
    $vacation_start = $dt_start->epoch();
    $vacation_end   = $dt_end->epoch();
     return 1 unless time >= $vacation_start and time <= $vacation_end;

    my ($list_name, $robot) = split(/@/, $list_address);
    my $list = Sympa::List->new($list_name, $robot);
    my $tpl = "confirmation";
    unless (
        Sympa::send_file(
            $list,
            $tpl,
            $sender,
            {
                'auto_submitted' => 'auto-replied',
                'vacation_start' => $vacation_start,
                'vacation_end' => $vacation_end,
                'subject' => $subject
            }
        )
    ) {
        $log->syslog(
            'notice',
            'Unable to send template "%s" to %s',
            $tpl,
            $sender
        );
    }
 
    return 1;
}
1; 
@ikedas
Copy link
Member

ikedas commented Jan 22, 2020

Hi @fprigent,

Could you please apply this additional patch, and then check if the problems will be solved?

@ikedas ikedas added the bug label Jan 22, 2020
@fprigent
Copy link
Author

fprigent commented Jan 22, 2020 via email

@ikedas
Copy link
Member

ikedas commented Jan 23, 2020

@fprigent , thanks for confirmation!

@ikedas ikedas added this to the 6.2.54 milestone Jan 27, 2020
@xmontagut
Copy link

Same problem, has been solved by the patch.
I lost 6 hours, it would be nice to have a disclaimer or "Known Bugs" on the web page or download page.

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

Successfully merging a pull request may close this issue.

3 participants