dongruolin5324 2015-09-27 21:11
浏览 331

Dovecot邮件位置问题

Issue

Dovecot does not use mail_location as I expect.

I want to provide email service for users in LDAP directory. User accounts are virtual accounts stored in an LDAP and they ARE NOT mapped to local users.

Details

Package versions

OS              Debian GNU/Linux 8.2 (jessie)
dovecot-core    1:2.2.13-12~deb8u1
dovecot-imapd   1:2.2.13-12~deb8u1
dovecot-ldap    1:2.2.13-12~deb8u1
squirrelmail    2:1.4.23~svn20120406-2
postfix         2.11.3-1
apache2         2.4.10-10+deb8u3

Configuration details

I set in /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:/var/mail/vhosts/%d/%n

so I expect to mail location be at /var/mail/vhosts/mydomain.com/myuser for myuser@mydomain.com.

Some dovecot settings, thrown by dovecot -n command, are:

mail_location = maildir:/var/mail/vhosts/%d/%n
mail_privileged_group = mail
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 =
}
protocols = " imap lmtp sieve"
service auth-worker {
  user = vmail
}
service imap-login {
  inet_listener imap {
    port = 143
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
userdb {
  args = /etc/dovecot/dovecot-ldap.conf.ext
  driver = ldap
}

Looking in /var/log/mail.log using tail -f command, it throws:

Sep 27 19:10:48 balam dovecot: imap-login: Login: user=<myuser>, method=PLAIN, rip=::1, lip=::1, mpid=24907, secured, session=<7/umVr8gvwAAAAAAAAAAAAAAAAAAAAAB>
Sep 27 19:10:48 balam dovecot: imap(myuser): Error: user myuser: Initialization failed: Namespace '': mkdir(/var/mail/vhosts//myuser) failed: Permission denied (euid=30000(myuser) egid=30002(IT) missing +w perm: /var/mail/vhosts/, dir owned by 5000:5000 mode=0755)
Sep 27 19:10:48 balam dovecot: imap(myuser): Error: Invalid user settings. Refer to server log for more information.

which is attempting to create mail directory at /var/mail/vhosts//myuser, instead of /var/mail/vhosts/mydomain.com/myuser as I want and expect.

If you need more details, please ask me!

Tests

In order to test login I have mounted a SquirrelMail client, which trigger previous events logged in /var/log/mail.log.

  • 写回答

1条回答 默认 最新

  • doudi2229 2015-09-27 22:00
    关注

    You have to set two parameters - mail_uid and mail_gid in the config. Until they are not set deliver perform database lookup to get adressee's UID and GID. If any - they'll be used for filesystem access. While mail storage hierarcy belong to 5000:5000 LDA have no access to write inside /var/mail/vhosts

    Just add an explicit declaration of user who can access mail storage:

    mail_location = maildir:/var/mail/vhosts/%d/%n
    mail_uid = 5000 # or his login name
    mail_gid = 5000 # or his group name
    

    and restart dovecot. Then deliver will be invoked with UID/GID=5000. Even more, now you can set mail storage permissions to 700 to prevent anyone except 5000:5000 to access mail storage.

    评论

报告相同问题?

悬赏问题

  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)