Created
August 10, 2020 22:24
-
-
Save PeterWhittaker/7ddb2da9a8638dbc5a402a8153518558 to your computer and use it in GitHub Desktop.
BASH script to find SELinux macro definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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