Re: mdbox and shared \Seen flag

2016-04-09 Thread Dmitry Nezhevenko
On Sat, Apr 09, 2016 at 07:47:47PM +0200, Thomas Leuxner wrote:
> * Dmitry Nezhevenko  2016.04.09 19:38:
> 
> > As far as I understand, "shared" namespace will keep \Seen flag private.
> > So any suggestions how to make \Seen shared?
> 
> This can be done using INDEXPVT:
> 
> location = mdbox:/var/vmail/shared:INDEXPVT=~/mdbox/shared
> 
> http://wiki2.dovecot.org/SharedMailboxes/Shared


Hi,

I've actually asked how to make \Seen shared (one user marks message as
read, others see it read too). 

It looks like just removing INDEXPVT fixes it for me.

Thanks a lot!

-- 
WBR, Dmitry


Slow reading of large dovecot-uidlist files

2016-04-09 Thread Bostjan Skufca
Hi there,

(context: I was optimizing Roundcube mailbox list server response, and in
that 300-400ms response time, around 170ms is spent on single fgets() call
which is waiting IMAP repsonse to "SELECT MyMailbox" command)

I straced dovecot and of the whole request/response process, around 30ms is
spent for everything else, and overwhelming majority of time (150-170ms) is
spent for reading dovecot-uidlist file for given mailbox.

I skimmed over src/lib-storage/index/maildir/maildir-uidlist.c
and src/src/lib/istream.c, but I am out of ideas on how to optimize
mentioned file reading elegantly to make it faster.

Is there any way to cache parsed content of uidlist file(s) or some other
obvious quicktrick I am missing to speed this process up?

Does anyone have any other ideas, how to speed this up?


b.


Re: mdbox and shared \Seen flag

2016-04-09 Thread Thomas Leuxner
* Dmitry Nezhevenko  2016.04.09 19:38:

> As far as I understand, "shared" namespace will keep \Seen flag private.
> So any suggestions how to make \Seen shared?

This can be done using INDEXPVT:

location = mdbox:/var/vmail/shared:INDEXPVT=~/mdbox/shared

http://wiki2.dovecot.org/SharedMailboxes/Shared


signature.asc
Description: Digital signature


mdbox and shared \Seen flag

2016-04-09 Thread Dmitry Nezhevenko
Hi,

I've just switched mail storage from maildir to mdbox and found it's very
amazing.

The only question I've is related to shared mailboxes. In the past I've
had a few mailboxes that were shared between two users by just symlinking
maildir. So everything was shared including flags and \Seen status. Now I
want to get something like this.

As far as I understand, "shared" namespace will keep \Seen flag private.
So any suggestions how to make \Seen shared?

My idea is to create some 'private' mdbox-based namespace that points to
fixed location on server, that doesn't depends on username?  Is it safe
(in terms of locking, accessing indexes, etc)? I'm 100% sure that nobody
except dovecot will access it.

PS. It's latest version of dovecot.

Thanks.

-- 
WBR, Dmitry


Re: Dovecot Proxy LTMP client connect to TCP port 0

2016-04-09 Thread Wido den Hollander
I looked into the further and it seems that there is no default port for LMTP in
Dovecot.

I patched the code and this seems right:
https://github.com/wido/core/commit/a5917908850eb570ca441517e6bc33f6ce63ed7a

This will make the LMTP client connect to TCP port 24 if no port has been
provided.

I will submitted it as a Pull Request on Github:
https://github.com/dovecot/core/pull/6

Wido

> Op 9 april 2016 om 11:25 schreef Wido den Hollander :
> 
> 
> Hi,
> 
> I am trying to set up a Dovecot proxy which proxies through POP3, IMAP and
> LTMP
> towards a different Dovecot machine.
> 
> On the proxy machine I use a MySQL database as a userdb and passwdb backend
> and
> it returns the proper information as described here:
> http://wiki2.dovecot.org/PasswordDatabase/ExtraFields/Proxy
> 
> IMAP and POP3 works just fine, but with LMTP I run into a problem.
> 
> On the 'proxy' machine Postfix is also running and it deliver locally to LTMP
> via Socket:
> 
> virtual_transport = lmtp:unix:private/dovecot-lmtp
> 
> Dovecot there is also configured to proxy LTMP:
> 
> lmtp_proxy = yes
> 
> service lmtp {
>   unix_listener /var/spool/postfix/private/dovecot-lmtp {
> group = postfix
> mode = 0600
> user = postfix
>   }
> }
> 
> So far so good. A telnet to localhost 110 or 143 allows me to log in to the
> POP3/IMAP.
> 
> When Postfix delivers the message locally to Dovecot through LTMP it tries to
> proxy it though.
> 
> When doing so it tries to connect to TCP port 0 (zero).
> 
> dovecot: lmtp(22580): Error: lmtp client: connect(mbox01..nl, 0) failed:
> Connection refused
> 
> I know I can return the 'port' field in the userdb query, but the same query
> is
> used for POP3, IMAP and LMTP. So that can't be hardcoded.
> 
> I fixed it for now with a CASE statement in SQL:
> 
> password_query = SELECT b.hostname AS host, NULL AS password, \
>'Y' AS nopassword, u.email AS destuser, 'Y' AS proxy, \
>CASE '%s' WHEN 'lmtp' THEN 2525 WHEN 'pop3' THEN 110 WHEN 'imap' THEN
> 143
> END AS port \
> FROM User u, Backend b, Domain d \
> WHERE u.domainID = d.domainID \
> AND b.backendID = d.backendID \
> AND u.email = '%u'
> 
> %s is a variable containing the service Dovecot is trying to look up.
> 
> This is however rather hacky.
> 
> On my destination machine LMTP is listening on port 2525. Is there any way to
> tell the Dovecot LTMP client to connect to port 2525 by default?
> 
> Thanks,
> 
> Wido


Dovecot Proxy LTMP client connect to TCP port 0

2016-04-09 Thread Wido den Hollander
Hi,

I am trying to set up a Dovecot proxy which proxies through POP3, IMAP and LTMP
towards a different Dovecot machine.

On the proxy machine I use a MySQL database as a userdb and passwdb backend and
it returns the proper information as described here:
http://wiki2.dovecot.org/PasswordDatabase/ExtraFields/Proxy

IMAP and POP3 works just fine, but with LMTP I run into a problem.

On the 'proxy' machine Postfix is also running and it deliver locally to LTMP
via Socket:

virtual_transport = lmtp:unix:private/dovecot-lmtp

Dovecot there is also configured to proxy LTMP:

lmtp_proxy = yes

service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
  }
}

So far so good. A telnet to localhost 110 or 143 allows me to log in to the
POP3/IMAP.

When Postfix delivers the message locally to Dovecot through LTMP it tries to
proxy it though.

When doing so it tries to connect to TCP port 0 (zero).

dovecot: lmtp(22580): Error: lmtp client: connect(mbox01..nl, 0) failed:
Connection refused

I know I can return the 'port' field in the userdb query, but the same query is
used for POP3, IMAP and LMTP. So that can't be hardcoded.

I fixed it for now with a CASE statement in SQL:

password_query = SELECT b.hostname AS host, NULL AS password, \
   'Y' AS nopassword, u.email AS destuser, 'Y' AS proxy, \
   CASE '%s' WHEN 'lmtp' THEN 2525 WHEN 'pop3' THEN 110 WHEN 'imap' THEN 143
END AS port \
FROM User u, Backend b, Domain d \
WHERE u.domainID = d.domainID \
AND b.backendID = d.backendID \
AND u.email = '%u'

%s is a variable containing the service Dovecot is trying to look up.

This is however rather hacky.

On my destination machine LMTP is listening on port 2525. Is there any way to
tell the Dovecot LTMP client to connect to port 2525 by default?

Thanks,

Wido


mail-search backtrace

2016-04-09 Thread Hugh Bragg

I'm repeatedly getting this error:

Apr 07 04:37:27 imap(mymail@address): Panic: file mail-search.c: line 84 
(mail_search_arg_init): assertion failed: (arg->initialized.keywords == 
NULL)
Apr 07 04:37:27 imap(mymail@address): Error: Raw backtrace: 
/usr/lib64/dovecot/libdovecot.so.0(+0x827c2) [0x7fcb7f65e7c2] -> 
/usr/lib64/dovecot/libdovecot.so.0(+0x828ad) [0x7fcb7f65e8ad] -> 
/usr/lib64/dov
ecot/libdovecot.so.0(i_fatal+0) [0x7fcb7f605b01] -> 
/usr/lib64/dovecot/libdovecot-storage.so.0(mail_search_arg_init+0x228) 
[0x7fcb7f91a328] -> 
/usr/lib64/dovecot/libdovecot-storage.so.0(index_search_result_updat
e_flags+0x100) [0x7fcb7f98e470] -> 
/usr/lib64/dovecot/libdovecot-storage.so.0(index_sync_search_results_update+0x52) 
[0x7fcb7f9983e2] -> 
/usr/lib64/dovecot/libdovecot-storage.so.0(index_mailbox_sync_deinit+0x185
) [0x7fcb7f998bb5] -> 
/usr/lib64/dovecot/libdovecot-storage.so.0(mailbox_sync_deinit+0x32) 
[0x7fcb7f921222] -> 
/usr/lib64/dovecot/lib20_virtual_plugin.so(virtual_storage_sync_init+0xab3) 
[0x7fcb7e9f7313] -> /usr
/lib64/dovecot/libdovecot-storage.so.0(mailbox_sync_init+0x3b) 
[0x7fcb7f92119b] -> dovecot/imap(imap_sync_init+0x68) [0x55b6ef47c238] 
-> dovecot/imap(cmd_sync_delayed+0x242) [0x55b6ef47cfb2] -> 
dovecot/imap(clie
nt_handle_input+0x220) [0x55b6ef4706b0] -> 
dovecot/imap(client_input+0x82) [0x55b6ef470b82] -> 
/usr/lib64/dovecot/libdovecot.so.0(io_loop_call_io+0x4c) 
[0x7fcb7f67228c] -> /usr/lib64/dovecot/libdovecot.so.0(io_l
oop_handler_run_internal+0x101) [0x7fcb7f673731] -> 
/usr/lib64/dovecot/libdovecot.so.0(io_loop_handler_run+0x25) 
[0x7fcb7f672315] -> /usr/lib64/dovecot/libdovecot.so.0(io_loop_run+0x38) 
[0x7fcb7f6724b8] -> /usr/
lib64/dovecot/libdovecot.so.0(master_service_run+0x13) [0x7fcb7f60b663] 
-> dovecot/imap(main+0x2db) [0x55b6ef463a0b] -> 
/lib64/libc.so.6(__libc_start_main+0xf0) [0x7fcb7f23b580] -> 
dovecot/imap(_start+0x29) [0x5

5b6ef463b99]


[root:~] # dovecot -n
# 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.12 (c1c0a23)
# OS: Linux 4.4.6-300.fc23.x86_64 x86_64 Fedora release 23 (Twenty Three)
auth_mechanisms = plain login
auth_socket_path = /var/run/dovecot/auth-userdb
imap_client_workarounds = tb-extra-mailbox-sep
listen = *
log_path = /var/log/dovecot.log
mail_access_groups = mail, vmail
mail_home = /var/mail/vmail/%d/%n
mail_location = maildir:~/mail
mail_plugins = virtual, acl
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

mbox_write_locks = fcntl
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
special_use = \Drafts
  }
  mailbox Junk {
special_use = \Junk
  }
  mailbox Sent {
special_use = \Sent
  }
  mailbox "Sent Messages" {
special_use = \Sent
  }
  mailbox Trash {
special_use = \Trash
  }
  prefix =
}
namespace virtual {
  location = virtual:/var/mail/vhosts/%d/%n/virtual
  prefix = virtual.
  separator = .
}
passdb {
  args = scheme=PLAIN username_format=%u /etc/dovecot/dovecot-users
  driver = passwd-file
}
plugin {
  acl = vfile
  acl_shared_dict = file:/var/mail/vhosts/shared-mailboxes.db
  fetchmail_helper = /var/mail/vhosts/bin/restart_fetchmail %h reload
  fetchmail_interval = 300
  fetchmail_pidfile = %h/.fetchmail.pid
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/sieve
  sieve_global_dir = /var/mail/vhosts/sieve-global
}
protocols = imap lmtp sieve
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
  }
  unix_listener auth-userdb {
group = vmail
mode = 0660
user = vmail
  }
}
service imap-login {
  inet_listener imap {
port = 143
  }
  inet_listener imaps {
port = 0
ssl = yes
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
  }
}
service managesieve-login {
  inet_listener sieve {
port = 4190
  }
}
service pop3-login {
  inet_listener pop3 {
port = 0
  }
  inet_listener pop3s {
port = 0
  }
}
ssl = required
ssl_cert = 

Re: Fwd: Plus addressing on Sentora using Postfix

2016-04-09 Thread Christian Kivalo


Am 9. April 2016 01:25:51 MESZ, schrieb Philip McGaw :
>I am running Ubuntu 14.04.4 LTS “Trusty” and "postconf -d | grep
>mail_version” gives me “mail_version = 2.11.0”, with Dovecot 2.2.9
>
>I have installed Sentora (http://sentora.org) which sets most of the
>configuration up for Postfix up, I have made some changes to allow me
>to use certificates for IMAP and SMTP SSL
>(https://skippy.org.uk/lets-encrypt-postfix-and-dovecot/),
>
>My Postfix main config file is http://pastebin.com/hdxdNK4d
>My Postfix master process configuration file is
>http://pastebin.com/YuCTq0JQ
>Dovecot -n gives me the following http://pastebin.com/05xixDtD
>
>I am trying to send an email to s...@skippy.org.uk and
>site+t...@skippy.org.uk (sending from an iCloud account), it works to
>s...@skippy.org.uk (s...@skippy.org.uk is a real email address), the
>lines from mail.log are as follows:
>
>> Mar 11 17:48:07 njoror postfix/smtpd[32706]: connect from
>mr11p26im-asmtp004.me.com[17.110.86.109]
>> Mar 11 17:48:07 njoror postfix/smtpd[32706]: Anonymous TLS connection
>established from mr11p26im-asmtp004.me.com[17.110.86.109]: TLSv1.2 with
>cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)
>> Mar 11 17:48:08 njoror postfix/smtpd[32706]: 1BAF055AB6:
>client=mr11p26im-asmtp004.me.com[17.110.86.109]
>> Mar 11 17:48:08 njoror postfix/cleanup[32710]: 1BAF055AB6:
>message-id=<90594925-c294-4a38-8275-c23da55a9...@icloud.com>
>> Mar 11 17:48:08 njoror postfix/qmgr[32599]: 1BAF055AB6:
>from=, size=1513, nrcpt=1 (queue active)
>> Mar 11 17:48:08 njoror postfix/pipe[32605]: 1BAF055AB6:
>to=, relay=dovecot, delay=0.43,
>delays=0.34/0.01/0/0.09, dsn=4.1.1, status=SOFTBOUNCE (user unknown)
>> Mar 11 17:48:08 njoror postfix/smtpd[32706]: disconnect from
>mr11p26im-asmtp004.me.com[17.110.86.109]
>
>vs
>
>> Mar 11 17:49:23 njoror postfix/smtpd[32706]: connect from
>mr11p26im-asmtp004.me.com[17.110.86.109]
>> Mar 11 17:49:23 njoror postfix/smtpd[32706]: Anonymous TLS connection
>established from mr11p26im-asmtp004.me.com[17.110.86.109]: TLSv1.2 with
>cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)
>> Mar 11 17:49:24 njoror postfix/smtpd[32706]: 33D2355AB9:
>client=mr11p26im-asmtp004.me.com[17.110.86.109]
>> Mar 11 17:49:24 njoror postfix/cleanup[32710]: 33D2355AB9:
>message-id=<2456dc97-4e3a-4a91-b3a0-cafe056f1...@icloud.com>
>> Mar 11 17:49:24 njoror postfix/qmgr[32599]: 33D2355AB9:
>from=, size=1249, nrcpt=1 (queue active)
>> Mar 11 17:49:25 njoror postfix/smtpd[32706]: disconnect from
>mr11p26im-asmtp004.me.com[17.110.86.109]
>> Mar 11 17:49:26 njoror postfix/pipe[32605]: 33D2355AB9:
>to=, relay=dovecot, delay=1.8, delays=0.63/0/0/1.2,
>dsn=2.0.0, status=sent (delivered via dovecot service)
>> Mar 11 17:49:26 njoror postfix/qmgr[32599]: 33D2355AB9: removed
>
>
>Looking at the lines from mail.log it looks like it thinks there should
>be a user called site+t...@skippy.org.uk, this has been puzzling me for
>a while, I was wondering if any one on here could see what was wrong,
>and what I needed to change, Looking at a few examples and online
>guides I thought I had covered all the bases.
>
>Looking at the log it looks like the message is either succeeding, or
>failing via Dovecot
>> Mar 11 17:48:08 njoror postfix/pipe[32605]: 1BAF055AB6:
>to=, relay=dovecot, delay=0.43,
>delays=0.34/0.01/0/0.09, dsn=4.1.1, status=SOFTBOUNCE (user unknown)
>
>Does any one have any ideas?
In dovecots 15-lda.conf uncomment the "recipient_delimiter = +" setting. The 
delimiter is configured in postfix but apparently not in your dovecot lda config

-- 
 Christian


Permissions for new folders

2016-04-09 Thread David Cigánek

Hi,

I have a problem with permissions for newly created folders in Dovecot. 
Everything worked fine until few days ago, when i did a little change in 
userdb lookup - but i don't know why it is causing problems.


Server uses following directory structure:

index - /data/mail/index
mail - /data/mail/mail
alt - /data/mail/archive

all 3 on separate volumes, for performance reasons.

Up until few days, i used following:

# doveadm user d...@example.com
fieldvalue
userd...@example.com
uid13726
gid1004
home/data/mail/mail/003/3726/da/dave
mail 
mdbox:~/mbox/:DIRNAME=.00f-dbox-Mails:INDEX=/data/mail/stub/index/data/mail/mail/003/3726/da/dave:ALT=/data/mail/stub/archive/data/mail/mail/003/3726/da/dave


config is quite simple:

mail_location = 
mdbox:~/mbox/:DIRNAME=.00f-dbox-Mails:INDEX=/data/mail/stub/index%h:ALT=/data/mail/stub/archive%h


passdb {
driver = sql
args = /data/mail/sql/dovecot-sql.conf.ext
}

userdb {
driver = static
args = gid=vmail
}

from SQL i get those fileds
username
domain
password
userdb_home
userdb_uid
userdb_quota_rule
userdb_quota_over_flag


For nicer paths, i created a symlinks
/data/mail/stub/index/data/mail -> /data/mail/index
/data/mail/stub/archive/data/mail -> /data/mail/archive

so path /data/mail/stub/index/data/mail/mail/003/3726/da/dave is in fact 
in /data/mail/index/003/3726/da/dave


In that setup, everything worked fine, but i didn't like those simlinks, 
so i altered the SQL query to return all paths in userdb_mail filed:


# doveadm user d...@example.com
fieldvalue
userd...@example.com
uid13726
gid1004
home/data/mail/mail/003/3726/da/dave
mail 
mdbox:~/mbox/:DIRNAME=.00f-dbox-Mails:INDEX=/data/mail/index/003/3726/da/dave:ALT=/data/mail/archive/003/3726/da/dave


So everything is in fact the same but little nicer. But since then, 
newly created directories doesn't get the same permissions like parent 
folder as day should (2770), but instead they are created with 2700:


# stat -c "%a (%A)"  /data/mail/mail/
2770 (drwxrws---)

# stat -c "%a (%A)"  /data/mail/mail/003
2700 (drwx--S---)

I need to have there 2770 perms, especialy because when other user like 
this is created:


userd...@example.com
uid13999
gid1004
home/data/mail/mail/003/3999/da/dave

Dovecot is unable to create directory /data/mail/mail/003/3999, because 
it doesn't have write permissions for group on /data/mail/mail/003.



I can't find any reason for this behavior - is it something in Dovecot 
or am I doing something wrong?


Thank you,

David


Dovecot version: 2.2.21
# doveconf -n

# 2.2.21 (5345f22): /usr/local/dovecot/2.2.21/etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.12 (c1c0a23)
# OS: Linux 3.10.0-327.4.5.el7.x86_64 x86_64 CentOS Linux release 
7.2.1511 (Core)

auth_master_user_separator = xx
dict {
  sieve_movespam = mysql:/data/mail/sql/dovecot-movespam-sql.conf.ext
  sieve_redirect = mysql:/data/mail/sql/dovecot-redirects-sql.conf.ext
}
mail_location = 
mdbox:~/mbox/:DIRNAME=.00f-dbox-Mails:INDEX=/data/mail/stub/index%h:ALT=/data/mail/stub/archive%h

mail_plugins = " quota notify replication"
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

mdbox_rotate_size = 15 M
passdb {
  args = xx
  driver = passwd-file
  master = yes
  pass = yes
  skip = authenticated
}
passdb {
  args = /data/mail/sql/dovecot-sql.conf.ext
  driver = sql
}
passdb {
  args = /data/mail/sql/dovecot-catchall-sql.conf.ext
  driver = sql
}

plugin {
  mail_replica = tcp:xxx:xxx
  quota = dict:user-quota::file:~/user_quota.dat
  quota2 = dict:domain-quota:%d:file:~/../../domain_quota.dat
  quota2_over_flag_value = 1
  quota2_over_script = quota-warning domain %d %n@%d %i missmatch2
  quota2_rule = *:bytes=500M
  quota2_rule2 = Trash:bytes=+5%%
  quota2_warning = bytes=90%% quota-warning domain %d %n@%d %i warn 90
  quota2_warning2 = bytes=100%% quota-warning domain %d %n@%d %i over 100
  quota2_warning3 = -bytes=100%% quota-warning domain %d %n@%d %i under 100
  quota_grace = 5%%
  quota_over_flag_value = 1
  quota_over_script = quota-warning user %n %n@%d %i missmatch1
  quota_rule = *:bytes=0
  quota_rule2 = Trash:bytes=+5%%
  quota_warning = bytes=90%% quota-warning user %n %n@%d %i warn 90
  quota_warning2 = bytes=100%% quota-warning user %n %n@%d %i over 100
  quota_warning3 = -bytes=100%% quota-warning user %n %n@%d %i under 100
  sieve = file:~/sieve;active=~/.dovecot.sieve
  sieve_before = dict:proxy::sieve_movespam;name=sieve_movespam;bindir=~
  sieve_before2 = dict:proxy::sieve_redirect;name=sieve_before;bindir=~
  sieve_max_actions = 500
  sieve_max_redirects = 500
  sieve_redirect_envelope_from = recipient
}
pop3_no_flag_updates = yes
protocols = imap pop3 lmtp sieve