Change mail_location too


---
Aki Tuomi
Dovecot oy

-------- Original message --------
From: Christoph Lukas <clukas@firc.de>
Date: 10/03/2018 12:37 (GMT+02:00)
To: dovecot@dovecot.org
Subject: quota-status: Issues with uppercase recipient address

Hello list,

Dovecot Version: 2.2.34 (874deae) on FreeBSD
MTA: Postfix 3.3.0

I've got an issue with the quota-status service:

Something breaks when receiving mail with a recipient address that includes non-lowercase characters,
for example foo@Example.com instead of foo@example.com:

postfix log:
postfix/smtp/smtpd[83387]: NOQUEUE: reject_warning: RCPT from mout01.posteo.de[185.67.36.65]:
  450 4.7.1 <foo@Example.com>: Recipient address rejected: Invalid user settings. Refer to server
  log for more information.; from=<[REDACTED]> to=<foo@Example.com> proto=ESMTP helo=<mout01.posteo.de>

dovecot.log:
quota-status(foo@Example.com): Error: User initialization failed:
  Namespace '': mkdir(/srv/mail/Example.com/foo/mailboxes) failed: Permission denied
  (euid=1001(vmail) egid=1001(vmail) missing +w perm: /srv/mail, dir owned by 0:1001 mode=0755)

The user_query has already been altered to include L, however the issue persists.

user_query = \
SELECT CONCAT('/srv/mail/','%Ld','/','%Ln','/') AS home, \
1001 AS uid, \
1001 AS gid, \
concat('*:bytes=', quota) AS quota_rule \
FROM mailbox WHERE username = '%Lu' \
AND active = 1

Thank you for any suggestions.
Christoph


# 2.2.34 (874deae): /usr/local/etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.22 (22940fb7)
# OS: FreeBSD 11.1-STABLE amd64  zfs
# Hostname: mail
auth_default_realm = firc.de
auth_mechanisms = plain login
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@+
auth_username_format =
auth_verbose = yes
base_dir = /var/run/dovecot/
first_valid_gid = 1001
first_valid_uid = 1001
hostname = mail.firc.de
info_log_path = /var/log/dovecot/dovecot-info.log
last_valid_gid = 1001
last_valid_uid = 1001
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
lda_original_recipient_header = X-Original-To
log_path = /var/log/dovecot/dovecot.log
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k
mail_gid = 1001
mail_location = sdbox:/srv/mail/%d/%n
mail_plugins = acl fts fts_solr quota
mail_uid = 1001
mailbox_list_index = yes
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext spamtest spamtestplus imapsieve vnd.dovecot.imapsieve
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Entwürfe {
    special_use = \Drafts
  }
  mailbox "Gelöschte Elemente" {
    special_use = \Trash
  }
  mailbox "Gesendete Elemente" {
    special_use = \Sent
  }
  mailbox Junk-E-Mail {
    special_use = \Junk
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  acl = vfile
  acl_shared_dict = file:/srv/mail/dovecot/shared-mailboxes
  antispam_backend = mailtrain
  antispam_mail_notspam = learn_ham
  antispam_mail_sendmail = /usr/local/bin/rspamc
  antispam_mail_sendmail_args = -h;10.0.110.27:11334;-P;[REDACTED]
  antispam_mail_spam = learn_spam
  antispam_spam = Junk
  antispam_trash = Trash
  fts = solr
  fts_autoindex = yes
  fts_solr = url=http://127.0.0.1:8983/solr/dovecot/
  imapsieve_mailbox1_before = file:/usr/local/etc/dovecot/sieve/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = Junk
  imapsieve_mailbox2_before = file:/usr/local/etc/dovecot/sieve/report-ham.sieve
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_from = Junk
  imapsieve_mailbox2_name = *
  quota = count:User quota
  quota_grace = 10%%
  quota_rule2 = Trash:storage=+100M
  quota_status_nouser = DUNNO
  quota_status_overquota = 552 5.2.2 Mailbox is full
  quota_status_success = DUNNO
  quota_vsizes = yes
  sieve = /srv/mail/%d/%n/dovecot.sieve
  sieve_default = /srv/mail/dovecot/default.sieve
  sieve_extensions = +spamtest +spamtestplus
  sieve_global_extensions = +vnd.dovecot.pipe
  sieve_pipe_bin_dir = /usr/local/etc/dovecot/sieve
  sieve_plugins = sieve_imapsieve sieve_extprograms
  sieve_spamtest_max_header = X-Spamd-Result: default: [[:alnum:]]+ \[-?[[:digit:]]+\.[[:digit:]]+ / (-?[[:digit:]]+\.[[:digit:]]+)\]
  sieve_spamtest_status_header = X-Spamd-Result: default: [[:alnum:]]+ \[(-?[[:digit:]]+\.[[:digit:]]+) / -?[[:digit:]]+\.[[:digit:]]+\]
  sieve_spamtest_status_type = score
}
postmaster_address = postmaster@firc.de
protocols = imap pop3 lmtp sieve
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    group = vmail
    user = vmail
  }
}
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}
service quota-status {
  client_limit = 1
  executable = quota-status -p postfix
  inet_listener {
    port = 12340
  }
}
ssl_alt_cert = </usr/local/etc/ssl/acme/mail.firc.de_ecc/cert.pem
ssl_alt_key = </usr/local/etc/ssl/acme/mail.firc.de_ecc/key.pem
ssl_ca = /usr/local/etc/ssl/acme/ca.pem
ssl_cert = </usr/local/etc/ssl/acme/mail.firc.de/cert.pem
ssl_dh_parameters_length = 2048
ssl_key =  # hidden, use -P to show it
ssl_protocols = !SSLv3
userdb {
  args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocol lmtp {
  mail_plugins = acl fts fts_solr quota sieve
}
protocol !indexer-worker {
  mail_vsize_bg_after_count = 100
}
protocol imap {
  mail_max_userip_connections = 50
  mail_plugins = acl fts fts_solr quota imap_sieve imap_acl imap_quota
  plugin {
    acl = vfile
  }
}
protocol lda {
  mail_plugins = acl fts fts_solr quota sieve quota
}