Dovecot: auth sockets permissions

dovecotpermissions

From my postfix setup I'm running deliver as nobody:nobody and it can't connect to auth-worker socket of dovecot. Thats my dovecot config:


# 2.0.13: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-lts x86_64  
auth_mechanisms = plain login
auth_username_format = %Lu
disable_plaintext_auth = no
first_valid_gid = 65534
mail_location = maildir:/var/spool/vmail/%d/%u/
mail_privileged_group = postfix

passdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
protocols = imap pop3

service auth {
  user = nobody

  unix_listener login/auth-master {
    mode = 0666
  }
  unix_listener login/auth {
    group = postfix
    user = postfix
    mode = 0660
  }
}
ssl = no
userdb {
  args = /etc/dovecot/dovecot-sql.conf
  driver = sql
}
verbose_proctitle = yes
protocol imap {
  imap_client_workarounds = delay-newmail tb-extra-mailbox-sep
}
protocol pop3 {
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
  pop3_uidl_format = %08Xu%08Xv
}
protocol lda {
  postmaster_address = postmaster@mydomain.com
  sendmail_path = /usr/sbin/sendmail
}

Thats what I have in the logs:


Aug  5 10:10:21 localhost dovecot: lda: Error: userdb lookup: connect(/var/run/dovecot/auth-userdb) failed: Permission denied (euid=99(nobody) egid=99(nobody) missing +r perm: /var/run/dovecot/auth-userdb, euid is not dir owner)
Aug  5 10:10:21 localhost dovecot: lda: Fatal: Internal error occurred. Refer to server log for more information.

I've tried to do


unix_listener auth-worker {
  user = nobody
}

in service auth section, but dovecot fails to run with this message: doveconf: Fatal: Error in configuration file /etc/dovecot/dovecot.conf: duplicate listener: /var/run/dovecot/auth-worker

How do I fix this issue?

Thanks.

Best Answer

Issue with auth-userdb permissions and ownership is solved like this:


service auth {
  unix_listener auth-userdb {
    mode = 0660 # socket access mode
    user = nobody # set uid to nobody
    group = nobody # set gid to nobody
  }
}

Problem with auth-worker permissions and ownership was much trickier and I've found out how to solve it only after reading sources of dovecot. Maybe there are some pages describing this issue, but I didn't find any. As I've found out auth-worker is a service and its socket permission may be set like this:


service auth-worker {
  unix_listener auth-worker {
    user = nobody # same as above, mode and group are supported too
  }
}