restorecond:不会还原具有多个硬链接(/etc/resolv.conf)的文件没有此类文件或者目录错误和解决方案

时间:2020-01-09 10:41:54  来源:igfitidea点击:

我在启用SELinux的CentOS或者RHEL服务器中看到以下错误:

Jun 21 13:58:43 server3 restorecond: Will not restore a file with more than one hard link (/etc/resolv.conf) No such file or directory
Jun 21 16:14:51 server3 restorecond: Will not restore a file with more than one hard link (/etc/resolv.conf) No such file or directory
Jun 22 13:32:23 server3 restorecond: Will not restore a file with more than one hard link (/etc/resolv.conf) No such file or directory

我该如何解决这个问题?

您或者您的脚本之一可能已追加硬链接到/etc/resolv.conf文件。
在CentOS/RHEL/Fedora下,文件/etc/sysconfig/networking/profiles/default/resolv.conf与/etc/resolv.conf硬链接。
要查找所有硬链接,请执行:

find / -xdev -samefile /etc/resolv.conf

输出示例:

/etc/sysconfig/networking/profiles/default/resolv.conf

要解决此问题,请执行以下命令:

# rm /etc/sysconfig/networking/profiles/default/resolv.conf
# restorecon /etc/resolv.conf
# ln /etc/resolv.conf /etc/sysconfig/networking/profiles/default/resolv.conf