0

Setting up a dovecot instance which uses openldap as backend for user accounts (under Ubuntu Bionic). The user mailboxes look like this

# find /home/virtual_mail/emont/ -type d -ls
  2228468      4 drwxrwx---   8 exim     mail         4096 Jun  5 15:48 /home/virtual_mail/emont/
  2228741      4 drwxrwx---   5 exim     mail         4096 Jun  4 12:08 /home/virtual_mail/emont/.foo1
  2228744      4 drwxrwx---   2 exim     mail         4096 Jun  4 12:08 /home/virtual_mail/emont/.foo1/cur
  2228746      4 drwxrwx---   2 exim     mail         4096 Jun  4 12:08 /home/virtual_mail/emont/.foo1/tmp
  2228745      4 drwxrwx---   2 exim     mail         4096 Jun  4 12:08 /home/virtual_mail/emont/.foo1/new
  2228471     20 drwxrwx---   2 exim     mail        20480 Jun  4 12:09 /home/virtual_mail/emont/cur
  2228473      4 drwxrwx---   2 exim     mail         4096 Jun  3 15:49 /home/virtual_mail/emont/tmp

Note that exim uid is 1000 amd mail gid is 8.

Now I would like for dovecot to access these with the least privileges but I am unable to do so:

# doveadm -D mailbox list -u emont 
[..]
doveadm(emont): Debug: Effective uid=0, gid=0, home=/home/emont

even when I have this (in dovecot-ldap.conf.ext, see also below):

user_attrs = homeDirectory=home,1000=uid,8=gid

That is, I was expecting to see something like this instead:

# doveadm -D mailbox list -u emont 
[..]
doveadm(emont): Debug: Effective uid=1000, gid=8, home=/home/emont

Note that I am using password lookup as ldap auth backend (https://wiki.dovecot.org/AuthDatabase/LDAP/PasswordLookups) and that part works fine (I get the users/group and auth succeeds).

Here is the config dump:

# doveconf -n
# 2.2.33.2 (d6601f4ec): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.21 (92477967)
# OS: Linux 4.15.0-101-generic x86_64 Ubuntu 18.04.4 LTS ext4
auth_debug = yes
auth_verbose = yes
mail_location = maildir:/home/virtual_mail/%u
namespace inbox {
  hidden = no
  inbox = yes
  list = 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 = INBOX.
  separator = .
  type = private
}
passdb {
  args = /etc/dovecot/dovecot-ldap.conf.ext
  driver = ldap
}
protocols = " imap pop3"
service imap-login {
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}
ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_key =  # hidden, use -P to show it
userdb {
  args = /etc/dovecot/dovecot-ldap.conf.ext
  driver = ldap
}

with this additionally for ldap:

# grep -v ^# dovecot-ldap.conf.ext | sort | uniq

base = dc=example,dc=de
blocking = yes
dn = uid=queryimap,cn=users,dc=example,dc=com
dnpass = xxxxxxx
hosts = myldap.example.com:7389
ldap_version = 3
scope = subtree
tls = yes
tls_ca_cert_file = /etc/myssl/mysslcert.pem
tls_require_cert = hard
user_attrs = homeDirectory=home,1000=uid,8=gid

Any advice on what I am doing wrong? Thanks in advance.

1 Answer 1

0

I believe I have found the solution: it turns out I had to add these to /etc/dovecot/conf.d/10-mail.conf

first_valid_uid = 1000
last_valid_uid = 1000
[...]
first_valid_gid = 8
last_valid_gid = 8

now I get the expected result, i.e.:

# doveadm -D mailbox list -u emont 
[...]
doveadm(emont): Debug: Effective uid=1000, gid=8, home=/home/emont

Still, I would welcome any feedback on that. Cheers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .