Mercurial > pkg
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/bash2 # 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" ]; then7 echo 1>&28 echo 1>&2 'USAGE: '"${0##*/}"' <user_or_group>'9 echo 1>&210 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>&216 exit 117 fi19 ugname="$1"21 ugmatcher=(-false)22 #test if find accepts ugname as a user, and append to ugmatcher if it does23 if find / -maxdepth 0 -user "$ugname" >/dev/null 2>&1 ; then24 ugmatcher[${#ugmatcher[@]}]="-or"25 ugmatcher[${#ugmatcher[@]}]="-user"26 ugmatcher[${#ugmatcher[@]}]="$ugname"27 fi28 #test if find accepts ugname as a group, and append to ugmatcher if it does29 if find / -maxdepth 0 -group "$ugname" >/dev/null 2>&1 ; then30 ugmatcher[${#ugmatcher[@]}]="-or"31 ugmatcher[${#ugmatcher[@]}]="-group"32 ugmatcher[${#ugmatcher[@]}]="$ugname"33 fi35 #if find accepted ugname as neither user nor group, then exit36 if [ "${#ugmatcher[@]}" = 1 ]; then37 echo 1>&2 'find does not accept `'"$ugname'"' as group or user name'38 exit 139 fi41 "${0%_*}" "${ugmatcher[@]}"