General discussion on installation and configuration of SOGo

Text archives Help


Re: [SOGo] sieve scripts


Chronological Thread 
  • From: Christian Rößner < >
  • To:
  • Subject: Re: [SOGo] sieve scripts
  • Date: Mon, 21 May 2012 20:05:28 +0200
  • Vbr-info: md=roessner-network-solutions.com; mv=dwl.spamhaus.org; mc=all

Hi Malte,

> I had/have the same problem but currently there is no running SOGo
> installation on my server as I upgraded to Ubuntu 12.04.
> So I could not try my dirty little perl script ;) on Ubuntu 12.04 as on
> Ubuntu 10.04 there were problems with GnuStep such that sogo-tool could only
> read a small value of parameter digest such that my huge sieve rules could
> not be passed successfully to SOGoDefaults.
>
> Maybe you could give my perl script a try. Perhaps you have to adapt some
> transformations as not all sieve commands are implemented yet.
> I guarantee no completeness or bug free functionality, so take care and make
> backups of .GnuStepDefaults and the involved sieve scripts.
>
that is awesome :-) Thank you very much for this script. I won't find the
time tonight to test it, but sure tomorrow. So I will give you a feedback for
12.04.

Once again thanks a lot.

Christian

> #!/usr/bin/perl -w
> use strict;
>
> if(-e $ARGV[0] && defined $ARGV[1] && $ARGV[1] eq 'true') {
> my $file = $ARGV[0];
> my $sogoSieve = convert($file);
> exec("sudo -u sogo sogo-tool user-preferences set defaults malte
> malte:MyF1r5t53rv3r SOGoSieveFilters '{$sogoSieve}'"); } elsif(-e $ARGV[0])
> {
> my $file = $ARGV[0];
> my $sogoSieve = convert($file);
> print("sudo -u sogo sogo-tool user-preferences set defaults malte
> malte:MyF1r5t53rv3r SOGoSieveFilters '{$sogoSieve}'\n"); } else {
> print("############### convertSieve.pl ##################\n");
> print("First Parameter should be the file to be converted\n");
> print("Second Parameter is optional and could be an output
> file.\n");
> print("If not set, the converted string is printed to the command
> line\n"); }
>
> ###########################################################
> ##################### subroutines #########################
> ###########################################################
>
> sub convert() {
> my $file = shift;
> my $rules = "",my $action = "", my $name = "";
> my $filters = "";
> open (INPUT,"<$file") || die $!;
> while (<INPUT>){
> if($_ =~ /\s*require\s*\["fileinto"\];\s*/ || $_ =~
> /\s*{\s*/ || $_ =~ /\s*stop;/) {
> #check
> } elsif($_ =~ /#\s*rule:\s*\[([^\]]+)\]/) {
> $name = $1;
> } elsif($_ =~ /\s*if\s+([^\(]*")/) {
> $rules = convertRules($1);
> } elsif($_ =~ /\s*if\s*anyof\s*\(([^\)]*)\)/) {
> $rules = convertRules($1);
> } elsif($_ =~ /\s*(fileinto)\s*"([^"]+)";/) {
> $action = convertAction($1, $2);
> } elsif($_ =~ /\s*}\s*/) {
> # create and add filter entry
> if($filters eq "") {
> $filters .= "{\"actions\":
> [$action], \"active\": true, \"rules\": [$rules], \"match\": \"any\",
> \"name\": \"$name\"}";
> } else {
> $filters .= ",{\"actions\":
> [$action], \"active\": true, \"rules\": [$rules], \"match\": \"any\",
> \"name\": \"$name\"}";
> }
> } else {
> print("Parse Error in:\n$_");
> return;
> }
> }
> close INPUT;
>
> return "\"SOGoSieveFilters\":[$filters]";
> }
>
> sub convertRules() {
> my $in = shift;
> my $rules = "";
> my @entities = split(/,/, $in);
> for(@entities) {
> if($_ =~
> /\s*header\s+:(contains|is)\s+"([^"]+)"\s+"([^"]+)"\s*/) {
> if( $rules eq "" ) {
> $rules .= "{\"operator\": \"$1\", \"field\":
> \"" . lc($2) . "\", \"value\": \"$3\"}";
> } else {
> $rules .= ",{\"operator\": \"$1\",
> \"field\": \"" . lc($2) . "\", \"value\": \"$3\"}";
> }
> } else {
> print("ERROR: Unknown rule:\n$_\n");
> }
> }
> return $rules;
> }
>
> sub convertAction() {
> my $method = shift;
> my $argument = shift;
> $argument =~ s/\./\//g;
> return "{\"method\": \"$method\", \"argument\": \"$argument\"}"; }
>
>
> -----Ursprüngliche Nachricht-----
> Von: Christian Rößner
> [mailto: ]
>
> Gesendet: Montag, 21. Mai 2012 17:23
> An:
>
> Betreff: Re: [SOGo] sieve scripts
>
> Hi,
>
>> Sieve scripts are locatedin the sogo database.
>>
>> You'll have to import them in there. I don't know if there is some kind
>> of script existing for this purpose, but one thing is sure: it won't
>> work if you try to keep your scripts AND give your users the options to
>> use sieve filtering within SOGo's webmail.
>
>
> Hm, I just found this link:
>
> https://inverse.ca/sogo/lists/arc/users/2012-02/msg00447.html
>
> but that really is too much pain. I would have to write a python script to
> convert sieve->json. And I don't want to do coding at the moment (I gonna
> have a look if there is some sieve python module. Maybe that would help me a
> lot).
>
> -Christian Rößner
>
> ---
> Roessner-Network-Solutions
> Bachelor of Science Informatik
> Nahrungsberg 81, 35390 Gießen
> F: +49 641 5879091, M: +49 176 93118939
> USt-IdNr.: DE225643613
> http://www.roessner-network-solutions.com
>
>
> --
>
> https://inverse.ca/sogo/lists


-Christian Rößner

---
Roessner-Network-Solutions
Bachelor of Science Informatik
Nahrungsberg 81, 35390 Gießen
F: +49 641 5879091, M: +49 176 93118939
USt-IdNr.: DE225643613
http://www.roessner-network-solutions.com

Attachment: smime.p7s
Description: S/MIME cryptographic signature




Archive powered by MHonArc 2.6.18.

Top of page