view previous-work/more_control_helpers/bin/list_suspicious_files_from @ 1:d6bef198ae71

add work by Matthias S. Benkmann which is the inspiration for this project.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 Jan 2013 11:45:01 +0000
parents
children
line wrap: on
line source
1 #!/bin/bash
2 # Copyright (c) 2004 Matthias S. Benkmann <article AT winterdrache DOT de>
3 # You may do everything with this code except misrepresent its origin.
4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
6 if [ $# != 1 -o "$1" = "--help" ]; then
7 echo 1>&2
8 echo 1>&2 'USAGE: '"${0##*/}"' <user_or_group>'
9 echo 1>&2
10 echo 1>&2 ' Outputs a categorized list of files and directories with properties'
11 echo 1>&2 ' that could mean trouble and should be investigated.'
12 echo 1>&2 ' Suspicious objects will be reported only if group and/or user equals'
13 echo 1>&2 ' <user_or_group> (numeric UID/GID allowed).'
14 echo 1>&2 ' This script calls `'"${0%_*}'"' for the real work.'
15 echo 1>&2
16 exit 1
17 fi
19 ugname="$1"
21 ugmatcher=(-false)
22 #test if find accepts ugname as a user, and append to ugmatcher if it does
23 if find / -maxdepth 0 -user "$ugname" >/dev/null 2>&1 ; then
24 ugmatcher[${#ugmatcher[@]}]="-or"
25 ugmatcher[${#ugmatcher[@]}]="-user"
26 ugmatcher[${#ugmatcher[@]}]="$ugname"
27 fi
28 #test if find accepts ugname as a group, and append to ugmatcher if it does
29 if find / -maxdepth 0 -group "$ugname" >/dev/null 2>&1 ; then
30 ugmatcher[${#ugmatcher[@]}]="-or"
31 ugmatcher[${#ugmatcher[@]}]="-group"
32 ugmatcher[${#ugmatcher[@]}]="$ugname"
33 fi
35 #if find accepted ugname as neither user nor group, then exit
36 if [ "${#ugmatcher[@]}" = 1 ]; then
37 echo 1>&2 'find does not accept `'"$ugname'"' as group or user name'
38 exit 1
39 fi
41 "${0%_*}" "${ugmatcher[@]}"