user's sieve rules dissapear

Discussion in 'Developers' Forum' started by George A., Jan 26, 2018.

  1. George A.

    George A. New Member

    Hi,
    First off, I'm new here, so I must say a BIG thank you for ISPconfig devs and to 'the perfect server' writers.

    Issue:
    I added sieve rules when first installed (mainly spam related)
    I created email accounts, then, in roundcube, added some more rules.
    Went back to ispconfig and added another spam rule, which was added, but all my custom rules were deleted.

    Possible solution (that doesn't work):
    I can create a new 'filter set', but when I activate it, it disables the ispconfig one (including the spam rules).

    Is there a way to get both sieve rule sets working? Or is there a way ISPconfig could ADD to the existing rules and not overwrite them?
    I have no idea if this is a bug or not, so please help.
    Thank you.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Where and how did you add custom rules?
     
  3. George A.

    George A. New Member

    Thanks for the quick reply. It took me this long to double check what I did.
    So, here are the steps to reproduce the bug:
    1*. (not sure if it makes a difference, can't test) setup sieve and have the default spam rules with ISPconfig
    2. add some sieve rules from Roundcube (to the ISPconfig rule set, as creating a new one pauses the ISPconfig default - one - which contains the default spam filters)
    3. in ISPconfig > email > mailbox> spam filter > add new filter > save
    4. check again in roundcube, all custom filters are gone, and only the old and the just added filters from ISPconfig remain.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Might be a problem in the way roundcube handles the rules. the roundcube plugin is not developed by us. ISPConfig itself handles the rules by marking their start and end with a comment marker and only changes the code in between when a specific rule is edited, so custom rules are not changed by ISPConfig. If RoundCube is not able to handle the rules in that way, then you might loose rules.
     
  5. George A.

    George A. New Member

    Thank you,
    I'll contact the roundcube devs about this issue.
     
    Last edited: Jan 31, 2018
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The rules are stored in the ISPConfig database. You can see them in ISPConfig by clicking on the custom rules tab of the mailbox. The content of the custom rules field is then written to the .sieve file of the mailbox.
     
  7. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    I believe roundcube talks to the managesieve daemon, which will edit the sieve rules files directly, it does not store anything in the database. (sieve support is part of roundcube, not part of the ISPConfig integration plugins)
     
  8. TonyG

    TonyG Active Member

    I've been working on sieve rules, and while learning how these components work I stumbled on the same issue as George A. I'm documenting this for anyone else who finds this thread and is trying to figure this out. The Roundcube plugin for ISPconfig saves rules bracketed as follows:
    Code:
    ### BEGIN FILTER_ID:5
    if header :regex    "subject" [".*test.*"] {
        fileinto :create "Testing";
        stop;
    }
    ### END FILTER_ID:5
    That index ID is maintained "somewhere". One might thinkg we can create a new filter and assign it a next sequential ID, "### BEGIN FILTER_ID:6". Unfortunately when Roundcube displays the list it will not include that manually entered rule. Create a new rule in Roundcube, the index is incremented there, and a manually entered rule is over-written.

    I need to find more info, find that index, and see what the link might be with managesieve. Ideally I think any changes we make in one environment should be reflected in the other. If anyone has insight on this, please post, otherwise I'll post later when I get through more of this and have time to come back here.
     
  9. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    As mentioned, the roundcube plugins do not talk to managesieve, they interface with ISPConfig's remote api. The rule you cited is simply a mail filter, as you would add under a mailbox's "Mail Filter" tab. The id is the id from the entry in the mail_user_filter table.

    There's really not much link with managesieve. ISPConfig puts mail filter rules into either .ispconfig-before.sieve or .ispconfig.sieve, both of which should be hidden in managesieve. So if you want to use managesieve (and roundcube has a very nice managesive plugin), you can create a custom ruleset, named whatever you wish, and make it active. It will run after the "ispconfig-before", and before the "ispconfig" rules.
     
  10. TonyG

    TonyG Active Member

    I just went through /usr/share/roundcube/plugins/ispconfig3_filter/ispconfig3_filter.php and I get it now.
    The index of the rule is indeed in ISPConfig - and the plugins are good examples of SOAP clients.

    As Till said, the content of the Custom Rules is written back to the .sieve file. But the rules are not processed back into the mail_user_filter table. This leads a user (moi) to copy/generate/paste rules into Custom Rules, thinking they will be used, but they're not. This, as the OP Title indicates, causes the "user's sieve rules to disappear".

    So is that a bug, or defined? Create a rule in Filter Rules, and it can be seen in Custom Rules. Edits in Custom Rules look like they're saved, but they're not reflected back in Filter Rules. If filters are intentionally not saved in Custom Rules I would suggest that there whould be two controls there: one display-only text area for filters we can't change, and an editable text area that does get saved. Thanks.

    EDIT: I'm understanding this more as I work with it. In Custom Rules, anyout outside of the ###Bracketed### filters is saved. The list of filters from mail_user_filter is display_only and regenerated into the Custom Rules textbox. The filter list is always at the bottom of the custom rules. It doesn't position above/below the custom rules as indicated by the selector in the Mail Filter tab. OK, it seems that text is just informational anyway. But seeing what this does and doesn't do, I'm thinking it would be neat for rules we paste in to get saved in mail_user_filter. I see however that there is a lot more that we can do with Sieve, and the fields in mail_user_filter only handle a limited subset of that. So now I'm understanding how the filter rules and custom rules are different. I do believe the read-only nature of the filters in custom rules should be noted on the page - or as I said above, separate the editable data from the read-only display.
     
    Last edited: Dec 9, 2020

Share This Page