rudimentary java library beginning. cleaned up scripts quite
[feisty_meow.git] / scripts / files / find_bad_protection.sh
1 #!/bin/bash
2
3 bad_file="$HOME/bad_protections.txt"
4 if [ $# = 0 ]; then dirname=$HOME; export dirname;
5 else dirname=$1; export dirname; fi
6
7 echo "Searching for bad file protections in $dirname..."
8 echo "This includes any files that are writable by other or that have the"
9 echo "SetUID or SetGID bits turned on."
10
11 echo "Bad file modes and owners report for $(date_stringer)." >$bad_file
12 echo "" >>$bad_file
13
14 export outfile="$(mktemp "$TMP/zz_badprot.XXXXXX")"
15
16 echo "These files have bad modes:" >>$bad_file
17 find "$dirname" -type f -exec ls -AlF {} ';'  >$outfile
18 cat $outfile | 
19   sed -n -e '/^.....w/p
20     /^........w/p
21     /^..s.../p
22     /^.....s/p' |
23   grep '^[^l]' >>$bad_file
24 rm $outfile
25 echo "" >>$bad_file
26
27 echo "These directories have bad modes:" >>$bad_file
28 find "$dirname" -type d -exec ls -Ald {} ';' >$outfile
29
30 #this is same as above block.  make it a function.
31 cat $outfile | 
32   sed -n -e '/^.....w/p
33     /^........w/p
34     /^..s.../p
35     /^.....s/p' |
36   grep '^[^l]' >>$bad_file
37 rm $outfile
38 #
39
40 echo "Searching for Files Not Owned by the User in $HOME...."
41 echo "" >>$bad_file
42 bash $FEISTY_MEOW_SCRIPTS/find_non_owned.sh $HOME >>$bad_file
43
44 echo "" >>$bad_file
45 echo "" >>$bad_file
46
47 echo $(basename $0) " is finished.  Showing report from $bad_file"
48
49 less $bad_file
50
51 #optional: rm $bad_file
52