Op 9-9-2025 om 02:51 schreef Stephan Bosch via dovecot:
This looks a lot like a bug. Will investigate..


I can reproduce it. Now to find the cause...



Op 15-8-2025 om 12:29 schreef Niklas Meyer via dovecot:
    Hello everyone,

    I am currently working on porting the Dovecot 2.4 configuration from the
    latest 2.3 version.

    During this process, I encountered issues with the Sieve filters,
    particularly those related to SQL dict mappings.

    The previous (2.3) configuration looked like this and worked:

  map {
    pattern = priv/sieve/name/$script_name
    table = sieve_before
    username_field = username
    value_field = id
    fields {
      script_name = $script_name
    }
  }

  map {
    pattern = priv/sieve/data/$id
    table = sieve_before
    username_field = username
    value_field = script_data
    fields {
      id = $id
    }
  }

    This resulted in the following SQL queries on the MySQL server:

  2025-08-15 11:01:29.237511 SELECT id FROM sieve_after WHERE script_name = 'active' AND username = '[1][email protected]'   2025-08-15 11:01:29.236416 SELECT id FROM sieve_before WHERE script_name = 'active' AND username = '[2][email protected]'

    As you can see, there are SQL mappings for sieve_before and sieve_after,
    alongside a local file loaded prior to the SQL settings, as they are
    user-based.

    In Dovecot 2.3, everything worked and the scripts were executed. In 2.4,
    however, they no longer run.

    I adapted the configuration for dict SQL mapping for Sieve filters
    according to the documentation:

  dict_map priv/sieve/name/$script_name {
    sql_table = sieve_before
    username_field = username
    value_field id {
    }

    # The script name field in the table to query
    key_field script_name {
      value = $script_name
    }
  }

  dict_map priv/sieve/data/$id {
    sql_table = sieve_before
    username_field = username
    value_field script_data {
    }
    key_field id {
      value = $id
    }
  }

    This also results in the dict proxy querying the database with the same
    pattern as before:

  2025-08-15 11:11:47.175184 SELECT id FROM sieve_after WHERE script_name = 'active' AND username = '[3][email protected]'   2025-08-15 11:11:47.172952 SELECT id FROM sieve_before WHERE script_name = 'active' AND username = '[4][email protected]'   2025-08-15 11:11:47.155786 SELECT id FROM sieve_after WHERE script_name = 'active' AND username = '[5][email protected]'   2025-08-15 11:11:47.136030 SELECT id FROM sieve_before WHERE script_name = 'active' AND username = '[6][email protected]'

    However, unlike in 2.3, it now queries the DB twice.

    In the Sieve debug logs, I see the following:

    [7]https://pastebin.com/PTKkLsDQ

    Notably:

  Aug 15 12:22:24 43664c142e0a dovecot: lmtp([8][email protected])<2407><mPFNN2AKn2hnCQAAhwrv7A>: Debug: Local delivery failed: Temporarily unable to access necessary Sieve scripts

    This line concerns me.

    Here are the current Sieve script declarations:

  sieve_script before {
    type = before
    driver = file
    path = /var/vmail/sieve/global_sieve_before.sieve
  }

  sieve_script before2 {
    type = before
    driver = dict
    name = active
    dict proxy {
      name = sieve_before
      sieve_script_bin_path = /var/vmail/sieve_before_bindir
    }
  }

  sieve_script after {
    type = after
    driver = file
    path = /var/vmail/sieve/global_sieve_after.sieve
  }

  sieve_script after2 {
    type = after
    driver = dict
    name = active
    dict proxy {
      name = sieve_after
      sieve_script_bin_path = /var/vmail/sieve_after_bindir
    }
  }

  # Personal scripts
  sieve_script personal {
    type = personal
    driver = file
    path = ~/sieve
    active_path = ~/.dovecot.sieve
  }

    The dict proxy configuration, pointing to the dict_map SQL query above,
    looks like this:

  dict sieve_after {
    driver = sql
    !include /etc/dovecot/sql/dovecot-dict-sql-sieve_after.conf
  }

  dict sieve_before {
    driver = sql
    !include /etc/dovecot/sql/dovecot-dict-sql-sieve_before.conf
  }

    Thanks for your guidance.

    Kind regards

    Niklas Meyer

    Maintainer of the mailcow project

References

    Visible links
    1. mailto:[email protected]
    2. mailto:[email protected]
    3. mailto:[email protected]
    4. mailto:[email protected]
    5. mailto:[email protected]
    6. mailto:[email protected]
    7. https://pastebin.com/PTKkLsDQ
    8. mailto:[email protected]

_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]
_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]
_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to