您好,我尝试编写脚本以使它“如果文件存在,必须归系统用户和组所有。其他用户的权限必须为r-x或更多限制。”
Aix系统7.2
#MODULE BODY
file_path="/bin/ssh-add"
if [ -e $file_path ];
then
user=`istat $file_path | grep Owner: | awk '{print $2}'`
uid=`id -u $user`
if [ $uid -lt 500 ];
then
permissions=`istat $file_path | grep Owner: | awk '{print $2}' `
if [ $permissions -le 755 ];
then
compliant="Yes"
actual_value='User = '$user', Permissions = '$permissions
else
compliant="No"
actual_value="Bad permissions"
fi;
else
compliant="No"
actual_value="Not system user"
fi;
else
compliant="Yes"
actual_value="NA"
fi;
# SCRIPT RESULT
echo :::$module_id:::$compliant:::$actual_value:::
echo " === End of $module_id module === "
答案 0 :(得分:0)
我建议将find
命令与-perm
选项一起使用。
请参阅文档here。
使用以下命令,您可以验证文件对其他人没有写权限。
find $file_path -perm o-w
使用以下命令,您可以验证文件是否没有对组的写许可权。
find $file_path -perm g-w
使用以下命令,您可以验证文件对组或其他文件没有写权限。
find $file_path -perm go-w