Skip to content
Commit 79b50f46 authored by Jesse Norell's avatar Jesse Norell
Browse files

iterate_query should not include disabled accounts

parent 3c1f1f59
  • Author Developer

    This isn't quite complete, it does help/fix some scenarios but appears %s (the service name) can be empty, causing an error for unknown column 'disable'. I'm looking into a fix for that.

  • Author Developer

    Maybe someone else has an idea on this one (help!)- with this change, I like the results of doveadm user queries better, but when I run an expunge for trash/spam cleanup I get an error, which seems like %s didn't get set:

    # /usr/bin/doveadm expunge -A \( mailbox Trash or mailbox SPAM or mailbox Junk or mailbox Deleted or mailbox Deleted\ Items \) savedbefore 30d Error: User listing returned failure doveadm: Error: Failed to iterate through some users

    And mail.log shows:

    Dec 20 17:10:55 mail-1 dovecot: auth-worker(3178): Error: sql: Iterate query failed: Unknown column 'disable' in 'where clause'

    Maybe it's a dovecot bug (running debian stretch, dovecot 2.2.27-3+deb9u1)?

  • Contributor

    Did you try to escape just the variable?

    Edited by Florian Schaal
  • Running debian jessie (dovecot 2.2.13-12~deb8u3), the patch also leads to the problems described by @jnorell .

    doveadm expunge -A mailbox Junk savedbefore 30d

    Results in the following error message:

    doveadm: Error: User listing returned failure doveadm: Error: Failed to iterate through some users

    As a temporary solution, I removed the part ``disable%Ls =' n'" because of this.

    Does anyone have an idea what the iterate_query should read correctly?

  • I am having the same issue on Debian 9.3 with dovecot 2.2.27 (c0f36b0). When using doveadm the %L does not seem to be set.

  • Contributor

    iterate_query = SELECT email as user FROM mail_user WHERE server_id = '7'

    Where server_id is The id of your mailserver.

    Works for me Without any problems you need to put this in dovecot-sql.conf

    Edited by Pascal Dreissen
  • Frank @bitverdreher ·

    iterate_query = SELECT email as user FROM mail_user WHERE disableimap = 'n'

    Otherwise you get: doveadm(user@domain.tld): Info: User no longer exists, skipping

  • Author Developer

    That 'User no longer exists' error is the original issue I started working on. Forcing the query to use the disableimap column would work for imap accounts, but consider a pop3-only installation where they intentionally have set disableimap=y for some or all users - then those pop3 accounts become out of reach for doveadm to act on them.

    I'm sure there's a query that would include %s only if set, but I didn't figure it out in some work on it; I've been meaning to get back to this, but have just reverted to the original query on our system till I can do so.

    @florian030 if I understand you correctly (ie. try disable`%Ls` ), I believe I did that as well, with the same results.

    Edited by Jesse Norell
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment