安装sendmail后发现启动老出现权限错误,网上找了半天资料才将问题解决。现将过程记录下来以便遇到同样错误的哥们快速解决。
[root@localhost ~]# yum -y install sendmail sendmail-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* epel: mirror.bjtu.edu.cn
* extras: mirrors.neusoft.edu.cn
* updates: mirrors.neusoft.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package sendmail.i386 0:8.13.8-8.1.el5_7 set to be updated
---> Package sendmail-devel.i386 0:8.13.8-8.1.el5_7 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================
Installing:
sendmail i386 8.13.8-8.1.el5_7 base 624 k
sendmail-devel i386 8.13.8-8.1.el5_7 base 128 k
Transaction Summary
================================================================================================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 751 k
Downloading Packages:
(1/2): sendmail-devel-8.13.8-8.1.el5_7.i386.rpm | 128 kB 00:00
(2/2): sendmail-8.13.8-8.1.el5_7.i386.rpm | 624 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 589 kB/s | 751 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : sendmail 1/2
Installing : sendmail-devel 2/2
Installed:
sendmail.i386 0:8.13.8-8.1.el5_7 sendmail-devel.i386 0:8.13.8-8.1.el5_7
Complete!
[root@localhost ~]# /etc/init.d/sendmail start
启动 sendmail:451 4.0.0 /etc/mail/sendmail.cf: line 91: fileclass: cannot open '/etc/mail/local-host-names': Group writable directory
451 4.0.0 /etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': Group writable directory
[失败]
启动 sm-client:/etc/mail/submit.cf: line 544: fileclass: cannot open '/etc/mail/trusted-users': Group writable directory
[失败]
解决办法一:
[root@localhost ~]# vim /etc/mail/sendmail.mc
1.找到下面这行
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
将它改为下面这样即可
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
2.备份旧的设置文件数据
[root@localhost ~]# cd /etc/mail
[root@localhost mail]# mv sendmail.cf sendmail.cf.bak
3.m4
[root@localhost mail]# m4 sendmail.mc > sendmail.cf
sendmail.mc:10: m4: cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or directory
[root@localhost mail]# rpm -qa m4
m4-1.4.5-3.el5.1
[root@localhost mail]# yum -y install sendmail-cf
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.stuhome.net
* epel: mirror.bjtu.edu.cn
* extras: mirrors.stuhome.net
* updates: ftp.twaren.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package sendmail-cf.i386 0:8.13.8-8.1.el5_7 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================
Installing:
sendmail-cf i386 8.13.8-8.1.el5_7 base 306 k
Transaction Summary
================================================================================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 306 k
Downloading Packages:
sendmail-cf-8.13.8-8.1.el5_7.i386.rpm | 306 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : sendmail-cf 1/1
Installed:
sendmail-cf.i386 0:8.13.8-8.1.el5_7
Complete!
[root@localhost mail]# m4 sendmail.mc > sendmail.cf
[root@localhost mail]# /etc/init.d/sendmail start
启动 sendmail:451 4.0.0 /etc/mail/sendmail.cf: line 91: fileclass: cannot open '/etc/mail/local-host-names': Group writable directory
451 4.0.0 /etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': Group writable directory
[失败]
解决方法二:
1、查看相应目录权限,权限为755.
[root@localhost mail]# ls -ld / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue
drwxr-xr-x 26 root root 4096 01-23 10:09 /
drwxr-xr-x 112 root root 12288 01-23 16:40 /etc
drwxr-xr-x 3 root root 4096 01-23 16:49 /etc/mail
drwxr-xr-x 15 root root 4096 12-21 16:53 /usr
drwxr-xr-x 25 root root 4096 10-08 18:46 /var
drwxr-xr-x 16 root root 4096 01-23 16:40 /var/spool
drw-r-xr-x 2 root mail 4096 2011-08-12 /var/spool/mqueue
[root@localhost mail]#
2、放松文件权限检查:
1.替换/etc/mail/sendmail.cf 中
2.第91行Fw/etc/mail/local-host-names为Fw-o /etc/mail/local-host-names
3.第588行Ft/etc/mail/trusted-users为Ft-o /etc/mail/trusted-users
4.替换/etc/mail/submit.cf中
5.第545行Ft/etc/mail/trusted-users为Ft-o /etc/mail/trusted-users
注意:加入-o参数后面有空格。
[root@localhost mail]# vim /etc/mail/sendmail.cf
[root@localhost mail]# /etc/init.d/sendmail restart
关闭 sm-client: [失败]
关闭 sendmail: [失败]
启动 sendmail: [确定]
启动 sm-client: [确定]