AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 507925
Accepted
Andrew Savinykh
Andrew Savinykh
Asked: 2013-05-16 01:27:22 +0800 CST2013-05-16 01:27:22 +0800 CST 2013-05-16 01:27:22 +0800 CST

邮箱中新文件的 Postfix/Dovecot 权限

  • 772

根据这篇文章:

在邮箱中创建新文件时,Dovecot 会从邮箱目录中复制读/写权限。

我没有看到这个。这是我所看到的:

andrewsav@hroon-precis:~$ dovecot --version
2.0.19
andrewsav@hroon-precis:~$ sudo ls -al /var/mail/vhosts/myhost.com/andrews
total 76
d-wxrws--- 6 vmail vmail  4096 May 15 19:53 .
drwxrwsr-x 4 vmail vmail  4096 Mar  8 07:27 ..
drwxrws--- 2 vmail vmail  4096 May 15 19:53 cur
-rw-rwS--- 1 vmail vmail   288 May 12 20:49 dovecot.index
-rw-rwS--- 1 vmail vmail 31316 May 15 19:53 dovecot.index.log
-rw-rwS--- 1 vmail vmail    24 Dec 13 14:27 dovecot.mailbox.log
-rw-rw---- 1 vmail vmail    54 May 15 19:53 dovecot-uidlist
-rw-rwS--- 1 vmail vmail     8 Dec 13 14:32 dovecot-uidvalidity
-r--rwSr-- 1 vmail vmail     0 Dec 12 22:34 dovecot-uidvalidity.50c84fbc
drwxrws--- 2 vmail vmail  4096 May 15 21:15 new
-rw-rwS--- 1 vmail vmail     6 Dec 13 14:27 subscriptions
drwxrws--- 2 vmail vmail  4096 May 15 21:15 tmp
drwxrws--- 5 vmail vmail  4096 Dec 13 14:32 .Trash
andrewsav@hroon-precis:~$ sudo ls -al /var/mail/vhosts/myhost.com/andrews/new
total 24
drwxrws--- 2 vmail vmail 4096 May 15 21:15 .
d-wxrws--- 6 vmail vmail 4096 May 15 19:53 ..
-rw------- 1 vmail vmail 3435 May 15 19:54 1368604473.Vca02I500e0M443155.hroon-precis
-rw------- 1 vmail vmail 4028 May 15 20:42 1368607343.Vca02I500e1M96785.hroon-precis
-rw------- 1 vmail vmail 4623 May 15 21:15 1368609338.Vca02I500fcM737208.hroon-precis
andrewsav@hroon-precis:~$

邮件目录对组有 rw,而新目录中的个别文件由于某种原因没有 rw。因此,他们无法被希望访问的人员/进程访问。我错过了什么?

我正在运行 ubuntu 12.04LTS

更新 1

提供一点背景知识:我已经运行 postfix+dovecot 有一段时间了。根据此文档,它的安装有小偏差。通常邮箱不在本地访问,远程客户端通过 POP/IMAP 访问。

但是我发现偶尔在服务器上运行mutt很有用。如果我运行它,我可以做的很好

sudo mutt -f /var/mail/vhosts/myhost.com/andrews

但是我希望能够在没有sudo 的情况下运行它,这就是麻烦开始的地方。我将 myslef 添加到 vmail 组中,并将以下行添加到 .muttrc 中:

set spoolfile = '/var/mail/vhosts/myhost.com/andrews/'
alternates myhost.com
set reverse_name = yes
set from = '[email protected]'

但这不起作用,除非我明确地对 new 和 cur 执行 chmod g+rw。而且它只在新邮件到达之前有效,因为新邮件没有那个 rw。

无论如何我可以解决这个问题吗?

更新 2

在聊天中与 NickW 讨论了这个问题后,我们得出的结论是,实际上是 Postfix 在编写这些文件,而不是 Dovecot。LDA 很可能是Postfix virtual。这是 Postfix 配置。

主.cf:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/apache2/ssl/my.crt
smtpd_tls_key_file=/etc/apache2/ssl/my.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = myhost.myhost.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = myhost.com, hroon-precis, localhost.localdomain, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
#smtpd_tls_wrappermode=yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_tls_auth_only = no
#smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_tls_security_level=may

virtual_mailbox_domains = myhost.com
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_alias_maps = hash:/etc/postfix/virtual
mydomain = myhost.com

transport_maps = hash:/etc/postfix/transport

大师.cf

#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
#submission inet n       -       -       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       -       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -   n   n   -   2   pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

运输:

[email protected] discard:
[email protected] discard:
[email protected] discard:

v邮箱:

[email protected] myhost.com/user1/
[email protected] myhost.com/user2/
... etc
[email protected] myhost.com/andrews/
@myhost.com myhost.com/andrews/

我搜索了 Postfix 文档,但无法找到一种方法来为邮箱中新创建的邮件消息文件指定 Postfix 的权限。

我的想法是这可能是不可能的,然后必须有另一种设置 mutt 的方法,这样它就可以访问 maildirs 而无需执行 sudo/be root。

任何提示表示赞赏。

postfix
  • 2 2 个回答
  • 17883 Views

2 个回答

  • Voted
  1. Best Answer
    Sandor Marton
    2013-05-16T17:57:43+08:002013-05-16T17:57:43+08:00

    我在这里回答而不是评论,所以我可以正确格式化。
    因为你有 dovecot,你应该已经安装了 lda(它在 dovecot-core 中)。将此添加到 /etc/postfix/master.cf:

    dovecot   unix  -       n       n       -       -       pipe
      flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
    

    将此添加到 /etc/postfix/main.cf:

    virtual_transport               = dovecot
    dovecot_destination_recipient_limit = 1
    

    更改/etc/dovecot/conf.d/15-lda.conf:

    protocol lda {
      postmaster_address = [email protected]
      log_path = /var/log/dovecot-deliver
      info_log_path = /var/log/dovecot-deliver
    }
    

    (尽管 {} 之间的第 3 行几乎是可选的)
    postmaster_address是退回邮件的发件人地址

    更改/etc/dovecot/conf.d/10-master.conf:

    service auth {
    ...
        unix_listener auth-userdb {
        mode = 0666
        user = vmail
        group = vmail
        }
    ...
    }
    

    将所有用户从 /etc/postfix/vmailbox 添加到 /etc/postfix/virtual,如下所示:

    [email protected] [email protected] 
    [email protected] [email protected] 
    ... etc
    

    将 catch-all 移动到 /etc/postfix/virtual:

    @myhost.com [email protected]
    

    更改/etc/dovecot/conf.d/15-lda.conf:

    lda_mailbox_autocreate = yes
    

    这将自动创建不存在的邮箱

    为了保留丢弃规则,添加到 main.cf :

    mydestination=localhost.localdomain
    

    添加到 /etc/postfix/virtual:

    [email protected] [email protected]
    [email protected] [email protected]
    [email protected] [email protected]
    

    然后到 /etc/aliases :

    devnull: /dev/null
    

    /etc/postfix/main.cf 中的这些行不再需要,可以删除:

    #virtual_mailbox_base = /var/mail/vhosts
    #virtual_minimum_uid = 100
    #virtual_uid_maps = static:5000
    #virtual_gid_maps = static:5000
    #transport_maps = hash:/etc/postfix/transport
    

    跑

    • 新别名
    • postmap /etc/postfix/virtual
    • 服务后缀重启
    • 服务鸽舍重启

    并希望它有效。

    • 4
  2. gparent
    2013-05-16T19:20:31+08:002013-05-16T19:20:31+08:00

    您可以将 Dovecot 设置为您的 LDA,以解决您的问题。这种方式virtual不会尝试在本地投递邮件,而是将其传递给 Dovecot。

    根据 dovecot 文档,执行此操作的首选方法是通过 LMTP。

    我保留的虚拟设置仍然有效,但是当实际将邮件发送到这些域时,它将使用设置的内容virtual_transport而不是直接发送邮件。

    这是 Debian Wheezy 上的工作配置,它使用 Dovecot 2.x:

    鸽舍配置文件:

    protocols = imap lmtp
    
    service lmtp {
      unix_listener /var/spool/postfix/private/dovecot-lmtp {
        mode = 0600
        user = postfix
        group = postfix
      }
      user = vmail
    }
    
    protocol lmtp {
      postmaster_address = [email protected]
    }
    

    主.cf:

    virtual_mailbox_domains = example.org
    virtual_alias_maps = hash:/etc/postfix/virtual
    virtual_transport = lmtp:unix:private/dovecot-lmtp
    
    # Don't need these anymore 
    
    #virtual_uid_maps = static:5000
    #virtual_gid_maps = static:5000
    #virtual_minimum_uid = 1000
    #virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox_users
    #virtual_mailbox_base = /var/mail
    
    • 2

相关问题

  • Postfix 在特定端口上接受邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 后缀电子邮件地址

  • 什么是最好的开源电子邮件解决方案包

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve