jww*_*jww 5 email permissions postfix file-permissions
几天来,我一直在 Postfix/Dovecot 中遇到权限问题。设置使用虚拟域和用户,因此用户的路径home是/var/mail/<domain>/<user>; 路径MailDir是/var/mail/<domain>/<user>/MailDir
邮件日志继续显示Permission Denied:
Apr 3 05:44:16 debian-x2 postfix/virtual[5670]: D6DDD1780100: to=<jeff@deltoid.com>,
relay=virtual, delay=0.15, delays=0.1/0.01/0/0.04, dsn=4.2.0, status=deferred
(maildir delivery failed: create maildir file
/var/mail/deltoid.com/jeff/Maildir/tmp/1396518256.P5670.debian-x2: Permission denied)
Run Code Online (Sandbox Code Playgroud)
权限如下:
# ls -l /var/mail/
total 96
drw-rws--- 4 vmail vmail 4096 Apr 2 18:19 deltoid.com
-rw-rw---- 1 nobody mail 80586 Apr 2 07:45 nobody
# ls -l /var/mail/deltoid.com/
total 12
drw-rws--- 3 vmail vmail 4096 Apr 3 04:47 jeff
drw-rws--- 3 vmail vmail 4096 Apr 3 04:47 support
-rw-rws--- 1 vmail vmail 122 Apr 2 03:33 users
# ls -l /var/mail/deltoid.com/jeff/
total 4
drw-rws--- 2 vmail vmail 4096 Apr 3 04:47 Maildir
# ls -l /var/mail/deltoid.com/jeff/Maildir/
total 0
Run Code Online (Sandbox Code Playgroud)
vmail既是用户又是组,设置为id5000:
# id -u vmail
5000
Run Code Online (Sandbox Code Playgroud)
postfix并且dovecot都在vmail组中:
# members vmail
vmail postfix dovecot
Run Code Online (Sandbox Code Playgroud)
和 Postfix 的main.conf:
# Mailbox location
virtual_mailbox_base = /var/mail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
Run Code Online (Sandbox Code Playgroud)
我有一个小脚本试图设置适当的权限位,但它显然是错误的:
# Ensure permissions are set on directories
chown -R vmail:vmail /var/mail/*.com
chmod -R 0660 /var/mail/*.com
chmod -R g+rwxs /var/mail/*.com
# chown -R dovecot:dovecot /var/mail/*.com/users
Run Code Online (Sandbox Code Playgroud)
我chmod -R g+rwxs从超级用户那里得到了关于设置目录权限和让子目录和文件继承这些权限的问题(例如,如何设置文件权限以便新文件继承相同的权限?,为目录下新创建的文件和子目录设置默认权限在 Linux 中?,以及
如何从父目录继承新文件权限?)。
两个问题:
当前权限有什么问题?
权限应该是什么?
目录的权限drw-rws---是错误的,因为由于缺少位x(=1使用数字形式时),即使是目录的所有者也无法进入它们。
您可以以普通用户(而非 root)身份自行测试:
$ mkdir -m 2670 /tmp/testdir
$ ls -ld /tmp/testdir
drw-rws--- 2 vmail vmail 4096 Apr 3 23:16 /tmp/testdir
$ cd /tmp/testdir
bash: cd: /tmp/testdir: Permission denied
Run Code Online (Sandbox Code Playgroud)
我认为您当前脚本中的这些行:
chmod -R 0660 /var/mail/*.com
chmod -R g+rwxs /var/mail/*.com
Run Code Online (Sandbox Code Playgroud)
应该是:
chmod -R 2770 /var/mail/*.com
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11708 次 |
| 最近记录: |