Redhat

yum-cron 郵件進入根目錄而不是指定使用者

  • September 21, 2016

我有幾台 RHEL 6 伺服器,我已配置 yum-cron 在其上執行。我已將它們配置為將電子郵件輸出發送到我的地址。問題是除了一台伺服器之外的所有伺服器仍在向 root 發送郵件。我確定我錯過了一些簡單的東西,但對於我的生活來說,弄清楚是什麼。有什麼建議麼?

在下面的配置和日誌中,ServerOne 正在將消息傳遞到正確的地址,而 ServerTwo 沒有。

這是來自 ServerOne 的郵件日誌:

May 11 04:51:43 ServerOne postfix/pickup[31719]: 8093C29EBD5: uid=0 from=<root>
May 11 04:51:43 ServerOne postfix/cleanup[53080]: 8093C29EBD5: message-id=<20160511095143.8093C29EBD5@serverone.something.com>
May 11 04:51:43 ServerOne postfix/qmgr[6134]: 8093C29EBD5: from=<ServerOne@something.com>, size=29582, nrcpt=1 (queue active)
May 11 04:51:44 ServerOne postfix/smtp[53089]: 8093C29EBD5: to=<me@somethingelse.com>, relay=10.1.0.7[10.1.0.7]:25, delay=1.2, delays=0.29/0.01/0.01/0.9, dsn=2.6.0, status=sent (250 2.6.0 <20160511095143.8093C29EBD5@serverone.something.com> [InternalId=6452520] Queued mail for delivery)
May 11 04:51:44 ServerOne postfix/qmgr[6134]: 8093C29EBD5: removed

記下 me@somethingelse.com 的收件人地址。現在,這是來自 ServerTwo 的郵件日誌:

May 10 03:55:13 ServerTwo postfix/pickup[27828]: 0A93C29F4AA: uid=0 from=<root>
May 10 03:55:13 ServerTwo postfix/cleanup[36376]: 0A93C29F4AA: message-id=<20160510085513.0A93C29F4AA@servertwo.something.com>
May 10 03:55:13 ServerTwo postfix/qmgr[5934]: 0A93C29F4AA: from=<ServerTwo@something.com>, size=15519, nrcpt=1 (queue active)
May 10 03:55:13 ServerTwo postfix/cleanup[36376]: 2EBA629F07B: message-id=<20160510085513.0A93C29F4AA@servertwo.something.com>
May 10 03:55:13 ServerTwo postfix/qmgr[5934]: 2EBA629F07B: from=<ServerTwo@something.com>, size=15685, nrcpt=1 (queue active)
May 10 03:55:13 ServerTwo postfix/local[36378]: 0A93C29F4AA: to=<root@servertwo.something.com>, orig_to=<root>, relay=local, delay=0.27, delays=0.19/0.06/0/0.02, dsn=2.0.0, status=sent (forwarded as 2EBA629F07B)
May 10 03:55:13 ServerTwo postfix/qmgr[5934]: 0A93C29F4AA: removed
May 10 03:55:13 ServerTwo postfix/smtp[36379]: 2EBA629F07B: to=<ServerTwo@something.com>, orig_to=<root>, relay=10.1.0.7[10.1.0.7]:25, delay=0.27, delays=0.02/0.06/0.01/0.18, dsn=2.6.0, status=sent (250 2.6.0 <20160510085513.0A93C29F4AA@servertwo.something.com> [InternalId=6432387] Queued mail for delivery)

並記下 root@servertwo.something.com 的收件人地址。

所以這是我的 ServerOne 的 yum-cron 文件:

YUM_PARAMETER="--security"
CHECK_ONLY=no
CHECK_FIRST=no
DOWNLOAD_ONLY=no
ERROR_LEVEL=1
DEBUG_LEVEL=1
RANDOMWAIT="1"
MAILTO="me@somethingelse.com" 
SYSTEMNAME="Server One" 
CLEANDAY="0"
SERVICE_WAITS=yes
SERVICE_WAIT_TIME=300

這是 ServerTwo 的 yum-cron:

YUM_PARAMETER="--security"
CHECK_ONLY=no
CHECK_FIRST=no
DOWNLOAD_ONLY=no
ERROR_LEVEL=1
DEBUG_LEVEL=1
RANDOMWAIT="1"
MAILTO="me@somethingelse.com"
SYSTEMNAME="Server Two"
CLEANDAY="0"
SERVICE_WAITS=yes
SERVICE_WAIT_TIME=300

這是 ServerOne 的後綴 main.cf 文件:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = serverone.something.com
mydomain = something.com
inet_interfaces = localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
relayhost = 10.1.0.7
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sender_canonical_maps = hash:/etc/postfix/canonical

這是 ServerTwo 的 main.cf:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = servertwo.something.com
mydomain = something.com
inet_interfaces = localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
relayhost = 10.1.0.7
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sender_canonical_maps = hash:/etc/postfix/canonical
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

最後,來自 ServerOne 的 postfix 規範文件:

root@something.com       ServerOne@something.com
@something.com           ServerOne@something.com
root@serverone.something.com    ServerOne@something.com

和來自 ServerTwo 的後綴/規範:

root@something.com       ServerTwo@something.com
@something.com           ServerTwo@something.com
root@servertwo.something.com    ServerTwo@something.com

發現了問題。從文件 yum-cron:

如果設置了 MAILTO 並且 mail 命令可用,則使用 mail 命令傳遞 yum 輸出

在這種情況下,我必須安裝 mailx yum 包。

引用自:https://serverfault.com/questions/776219