Skip to content

Instantly share code, notes, and snippets.

@PeterWhittaker
Created August 10, 2020 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeterWhittaker/7ddb2da9a8638dbc5a402a8153518558 to your computer and use it in GitHub Desktop.
Save PeterWhittaker/7ddb2da9a8638dbc5a402a8153518558 to your computer and use it in GitHub Desktop.
BASH script to find SELinux macro definitions
#!/bin/bash
# Searches the current directory for either all SELinux macro definitions or
# the SELinux macro definition specified by $1
#
# if $2 exists, there is a quoting error and we quit
if [[ ! -z ${2} ]]; then
echo "ERROR: invoked with too many parameters, probably a quoting error."
echo "USAGE: $0 [pattern]"
exit 1
fi
pattern='define(`'
if [[ -z $1 ]]; then
find . -type f -exec grep -i -H "${pattern}" {} \; | cut -d: -f1 |sort -u
else
pattern="${pattern}${1}"
find . -type f -exec grep -i -H "${pattern}" {} \;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment