A small script hacked up to monitor directories.

This is something I knocked up a while ago just to keep an eye on a directory structure for permissions changes, excluding upload directories and other things:


#!/bin/bash

ignore[0]="./public_html/blog/wp-content/uploads"
ignore[1]="./bb-attachments"

cd 

unset unsecure i
i=0
while IFS= read -r -d $'\0' file; do
    unsecure[i++]="$file"        # or however you want to process each file
done < <(find . -perm /go+w -print0 2>/dev/null)

for dodgy in ${unsecure[@]}; do
	guilty=1
	for entry in ${ignore[@]}; do
		if [[ "$dodgy" =~ $entry ]]; then
			unset guilty
		fi
	done
	if [ $guilty ]; then 
		echo "Unknown unsecure directory : $dodgy"
	fi
done
This entry was posted in Programming and tagged , . Bookmark the permalink.