Maildir 資料夾、虛擬使用者郵件資料夾擁有者和權限的 Postix 或 Dovecot 偵錯日誌

Maildir 資料夾、虛擬使用者郵件資料夾擁有者和權限的 Postix 或 Dovecot 偵錯日誌

我無法找到有關 Maildir 以及所有者和權限所在資料夾的完整教程(如果有)並且您已經找到了,請分享。

無論如何,我想知道是否有一種方法可以使用 Postfix 、 Dovecot log 或任何其他工具來獲取與 Maildir 配置相關的錯誤輸出,例如(嘿這個資料夾的所有者錯誤,或者缺乏權限,或者即使沒有創建)

我知道您會告訴我:將您的資料夾和配置發送給我們,但我想知道如何針對未來的其他情況進行偵錯。

我真正想知道的是例如:我的虛擬用戶有 /home/user/domain/usermail/Maildir

home、user、domain、usermail 和 Maildir 應具有哪些權限和擁有者

請記住,我最關心的是學習調試與資料夾權限相關的問題。

我在 dovecot.conf 中有:

 verbose_ssl=yes
 mail_debug=yes
 auth_debug=yes
 auth_verbose=yes

並在 master.cf postfix conf 中這一行

smtp    inet    n       -       n       -       -       smtpd -v
submission inet n       -       n       -       -       smtpd -v

順便說一句,drwxr-s--- usermail 資料夾的權限可以嗎?

答案1

對於虛擬用戶,您需要建立一個系統使用者帳戶並讓它擁有郵件,然後在 Postfix 和 Dovecot 中設定該使用者的 UID 和 GID。

以下是我的相關部分dovecot.conf

userdb {
  driver = static
  args = uid=8 gid=12 home=/var/spool/mail/%n
}

mail_location = maildir:~
mail_uid = 8
mail_gid = 12

userdb 是一個非常簡單的類似 passwd 的文件,只有使用者名稱和密碼,其他所有內容都硬編碼在userdb {...}上面的實際區塊中,因此 UID 和 GID 以及使用者的「home」位於/var/spool/mail並以使用的任何登入名稱開頭(假設它是預先在passwd檔案中定義的,否則存取將被拒絕)。

mail_location告訴它郵件採用 maildir 格式並位於~(home) 中,該路徑對應於從上面的 userdb 取得的「home」路徑。 mail_gid/uid再次將郵件的所有權設定為應該擁有該郵件的相應系統使用者;顯然在 Postfix 中應該是一樣的。

後綴main.cf

virtual_mailbox_base = /var/spool/mail
virtual_mailbox_maps = hash:/etc/postfix/vmailboxes
virtual_uid_maps = static:8
virtual_gid_maps = static:12

與 Dovecot 相同的基本目錄,只是/etc/postfix/vmailboxes具有語法<mail user account> <mail directory>/,例如,如果它包含,serverfault serverfault/則告訴 Postfix 收到的任何郵件serverfault@domain都會以 結尾/var/spool/mail/serverfault,這對應於當您使用用戶名登入時 Dovecot 查找郵件的位置serverfault

再次將virtual_uid/gid_maps郵件的所有權設定為我們預先選擇/建立的系統用戶,它應該與Dovecot相同。

我不知道顯示錯誤所需的任何特定日誌記錄選項,如果我弄亂了虛擬郵件資料夾的權限,我的Dovecot 就會開始在日誌中尖叫,而無需任何特殊配置(在我的dovecot.conf 中沒有與日誌記錄相關的選項) :

Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: chdir(/var/spool/mail/username/) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: chdir(/var/spool/mail/username) failed: Permission denied
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: opendir(/var/spool/mail/username) failed: Permission denied (euid=8(mail) egid=12(mail) missing +r perm: /var/spool/mail/username)
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: opendir(/var/spool/mail/username) failed: Permission denied (euid=8(mail) egid=12(mail) missing +r perm: /var/spool/mail/username)
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:04 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: chdir(/var/spool/mail/username/) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: chdir(/var/spool/mail/username) failed: Permission denied
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/.Sent Messages/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/.Sent Messages/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:09 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:10 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/.Sent Messages/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)
Mar 07 12:54:10 sanctuary dovecot[2175]: imap(username): Error: stat(/var/spool/mail/username/tmp) failed: Permission denied (euid=8(mail) egid=12(mail) missing +x perm: /var/spool/mail/username, dir owned by 0:0 mode=0700)

當我嘗試發送權限混亂的電子郵件時,與 Postfix 相同:

Mar 07 12:56:45 sanctuary postfix/virtual[2736]: warning: maildir access problem for UID/GID=8/12: create maildir file /var/spool/mail/username/tmp/1425729405.P2736.sanctuary: Permission denied
Mar 07 12:56:45 sanctuary postfix/virtual[2736]: warning: perhaps you need to create the maildirs in advance
Mar 07 12:56:45 sanctuary postfix/virtual[2736]: E752F186: to=<username@sanctuary>, relay=virtual, delay=0.05, delays=0.03/0.01/0/0.01, dsn=4.2.0, status=deferred (maildir delivery failed: create maildir file /var/spool/mail/username/tmp/1425729405.P2736.sanctuary: Permission denied)

答案2

我假設您正在使用dovecot-lda將郵件發送到 Maildir。 IIRCdovecot-lda會向您顯示缺少哪些權限的詳細資訊。

dovecot-lda無法存取 dovecot 的全域日誌記錄設施。因此,您必須dovecot-lda單獨配置日誌記錄。因此,您必須在 dovecot 配置中尋找“protocol lda {”,log_pathinfo_log_path根據您的需求變更參數。如果您放在這裡的文件應該是 dovecot-lda 可以寫入的文件,並且如果您想使用 syslog(也稱為將參數留空),則必須修改 /dev/log 的權限。

dovecot 維基有更多細節:http://wiki2.dovecot.org/LDA

順便一提:如果您想找出本地郵件傳遞的問題,則不需要 smtp 和在 postfix 中提交詳細日誌。

相關內容