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

Error 352 when getting Filters #1455

Closed
jhd85 opened this issue Feb 27, 2024 · 8 comments
Closed

Error 352 when getting Filters #1455

jhd85 opened this issue Feb 27, 2024 · 8 comments
Labels
external Issue is outside our code sieve filter scripting workaround

Comments

@jhd85
Copy link

jhd85 commented Feb 27, 2024

Describe the bug
I configured a sieve server in SnappyMail to be able to create and manage filter for mail. But opening the Filters section gives me a error:

To Reproduce

  1. In snappymail
  2. Go to 'Settings'
  3. Go to 'Filters'
  4. receive 'ERROR 352'.

Expected behavior
Getting a overview of my current filters

Screenshots
image

Please complete the following information:

  • Browser: firefox 123
  • IMAP daemon: https://stalw.art
  • PHP version: 8.2.15
  • SnappyMail Version: 2.35.0
  • Mode: nextcloud

Debug/logging information
Place them here (few lines) or as attachments (many lines)

SIEVE[INFO]: > GETSCRIPT "roundcube"\r\n
SIEVE[INFO]: < {335}\r\n
SIEVE[INFO]: < require ["fileinto"];\r\n
# rule:[myrule]\r\n
if allof (header :contains "to" "info@redacted.nu")\r\n
{\r\n
        fileinto "myrule";\r\n
}\r\n
# rule:[paypal]\r\n
if allof (header :contains "to" "paypal@redacted.nu")\r\n
{\r\n
        fileinto "Diensten";\r\n
        stop;\r\n
}\r\n
# rule:[steam]\r\n
if allof (header :contains "to" "steam@redacted.nu")\r\n
{\r\n
        fileinto "Games";\r\n
        stop;\r\n
}\r\n
SIEVE[INFO]: < OK\r\n
SIEVE[INFO]: > LOGOUT\r\n
SIEVE[INFO]: < BYE "Stalwart ManageSieve v0.6.0 bids you farewell."\r\n
SIEVE[ERROR]: MailSo\Net\Exceptions\SocketReadException in /var/www/html/custom_apps/snappymail/app/snappymail/v/2.35.0/app/libraries/MailSo/Net/NetClient.php:275

Additional context

  • I also tried the sieve server with roundcube and that works without issue
  • Adding filter seems to work (if you just ignore the errors) but can't select capabilities and it still can't get filters afterwards
  • I (have to) use short logins for everything (imap, smtp and sieve), so user@domain.com -> user. But can't select this in the admin panel for snappymail for sieve. Only for imap and smtp. But seeing the logging it looks like getting the data from the server works fine.
@the-djmaze
Copy link
Owner

https://datatracker.ietf.org/doc/html/rfc5804#section-2.3

The server MUST reply with an OK response.

Yours does not. It says: BYE "Stalwart ManageSieve v0.6.0 bids you farewell."

@mdecimus
Copy link

mdecimus commented Feb 27, 2024

The server MUST reply with an OK response.

That is incorrect, you are quoting the example. According to the ManageSieve grammar, both OK, NO and BYE are valid responses for the LOGOUT command:

    response-logout       = response-oknobye
    response-oknobye    = response-ok / response-nobye
    response-nobye        = ("NO" / "BYE") [SP "(" resp-code ")"]
                            [SP string] CRLF
                            ;; The string contains human-readable text
                            ;; encoded as UTF-8.

@m-i-k-e-y
Copy link

The RFC states above the example:

   The server MUST reply with an  OK response.  The server MUST ignore commands issued by the client
   after the LOGOUT command.

   The client SHOULD wait for the OK response before closing the
   connection.

So @the-djmaze is correct.

@the-djmaze
Copy link
Owner

the-djmaze commented Feb 27, 2024

@m-i-k-e-y we both are right.
The problem relies in the RFC.

BYE is important in case of errors, misbehaviour, etc.
https://datatracker.ietf.org/doc/html/rfc5804#section-1.2
In this case LOGOUT is no such thing and the server must respond with OK.
The BYE info is missing in the LOGOUT section.

So based on all info @mdecimus is wrong in this case. And OK is the valid option for normal flow.
Or is their ManageSieve crashing?

@mdecimus
Copy link

I agree, there is a "bug" in the RFC. I will have this fixed to use the same response as Pigeonhole since this is what most software was tested against.

However, even if the server is crashing, I think SnappyMail should follow the robustness principle and not fail on unexpected responses for non-critical commands.

@the-djmaze
Copy link
Owner

the-djmaze commented Feb 27, 2024

However, even if the server is crashing, I think SnappyMail should follow the robustness principle and not fail on unexpected responses for non-critical commands.

True, that's why i made a workaround to not crash on BYE.
Although it is a server hang-up of the connection for whatever reason.

I did make a mistake in IMAP with that, because it does have an untagged BYE followed with a tagged OK.

@mdecimus
Copy link

Stalwart has now been updated to return OK instead of BYE. I also submitted an errata to IETF:

The following errata report has been submitted for RFC5804,
"A Protocol for Remotely Managing Sieve Scripts".

--------------------------------------
You may review the report below and at:
https://www.rfc-editor.org/errata/eid7825

--------------------------------------
Type: Editorial

Section: 4

Original Text
-------------
response-logout       = response-oknobye


Corrected Text
--------------
response-logout       = response-ok


Notes
-----
The client sends the LOGOUT command when it is finished with a
  connection and wishes to terminate it.  The server MUST reply with an
  OK response.  The server MUST ignore commands issued by the client
  after the LOGOUT command.

Instructions:
-------------
This erratum is currently posted as "Reported". (If it is spam, it 
will be removed shortly by the RFC Production Center.) Please
use "Reply All" to discuss whether it should be verified or
rejected. When a decision is reached, the verifying party  
will log in to change the status and edit the report, if necessary.

--------------------------------------
RFC5804 (draft-ietf-sieve-managesieve-09)
--------------------------------------
Title               : A Protocol for Remotely Managing Sieve Scripts
Publication Date    : July 2010
Author(s)           : A. Melnikov, Ed., T. Martin
Category            : PROPOSED STANDARD
Source              : Sieve Mail Filtering Language
Area                : Applications
Stream              : IETF
Verifying Party     : IESG

@f0rc3r
Copy link

f0rc3r commented Feb 28, 2024

Updated to the newest release 2.35.2 and still get Error 352

@the-djmaze the-djmaze added the sieve filter scripting label Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issue is outside our code sieve filter scripting workaround
Projects
None yet
Development

No branches or pull requests

5 participants