您好我尝试编写脚本以使其“如果文件存在必须由系统用户和组拥有。其他的权限必须是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 === "
我建议使用find
命令和-perm
选项。请参阅文档here。
使用以下命令可以验证文件是否对其他人没有写入权限。
find $file_path -perm o-w
使用以下命令可以验证文件是否没有写入组的写入权限。
find $file_path -perm g-w
使用以下命令可以验证文件是否对组或其他组件没有写入权限。
find $file_path -perm go-w