By using stat and awk, you can gather some information for passing or failing a permissions check. Below is a bash script snippet I used for checking all the home directories in /etc/passwd to make sure they are at permissions level of 755 or less. I am sure there is a better way of doing this and this might not work for people who have the sticky bit set, but for now it gets the job done:

stat -c "%a %n" `awk -F":" '{print $6}' /etc/passwd` | awk '{
if ($1 <= 755 )
print "--- pass","=>",$0;
else
print "+++ Fail","=>",$0;
}'


      
comments powered by Disqus