if [ "$(stat -c "%a" /etc/crontab)" == "644" ]
then
echo "Is there a vulnerability: No, Permission set on /etc/crontab file is correct."
else
echo "Is there a vulnerability: Yes, Permission set on /etc/crontab file is incorrect. echo awk -F: $(stat -c "%a" /etc/crontab)"
fi
这是我正在使用的审核脚本,如果不等于chmod 644,我想输出/ etc / crontab文件的当前权限。我尝试了许多方法都没有用。如果重要的话,我正在RHEL 7服务器中执行此操作。
比较bash中的数字时,应使用-eq
而不是==
。因此,您的if
来自此:
if [ "$(stat -c "%a" /etc/crontab)" == "644" ]
必须
if [ "$(stat -c "%a" /etc/crontab)" -eq "644" ]