7
APPARMOR_PARSER="/sbin/apparmor_parser"
10
echo 'stress.sh [-klh] [-c count] [-s seed] [-p parser]'
11
echo ' -c count generate _count_ number of profiles'
12
echo ' -h usage (this message)'
13
echo ' -k keep files after completion'
14
echo ' -l attempt to load profiles into kernel'
15
echo ' -p parser use _parser_ instead of /sbin/apparmor_parser'
16
echo ' -s seed use _seed_ as random seed value'
21
while getopts 'klc:s:p:h' OPTION ; do
27
c) PROFILE_COUNT=$OPTARG
29
s) STRESS_ARGS="${STRESS_ARGS} -s ${OPTARG}"
31
p) APPARMOR_PARSER=$OPTARG
38
# stress.rb exports the profile locations it generatees in PROFILEDIR
40
echo "Generating ${PROFILE_COUNT} profiles..."
41
eval $(./stress.rb ${STRESS_ARGS} ${PROFILE_COUNT})
43
if [ ! -d "${PROFILEDIR}" -o ! -f "${PROFILESINGLE}" ] ; then
44
echo "Generated profiles don't exist! Aborting...."
49
if [ ${KEEP_FILES} == 0 ] ; then
50
rm -rf "${PROFILEDIR}"
53
echo "Files kept in ${PROFILEDIR} and ${PROFILESINGLE}"
61
time for profile in ${PROFILEDIR}/* ; do
62
${COMMAND} ${profile} > /dev/null
70
time ${COMMAND} ${PROFILESINGLE} > /dev/null
74
echo "Unloading profiles..."
75
(for profile in $(grep "^/does/not/exist" /sys/kernel/security/apparmor/profiles | cut -d " " -f 1); do
77
done) | apparmor_parser -K -R > /dev/null
80
# load files into buffer cache
81
timedir "cat" "Loading directory of profiles into buffer cache"
82
timedir "apparmor_parser -dd" "Running preprocess only parser on directory of profiles"
83
timedir "apparmor_parser -S" "Running full parser on directory of profiles"
84
if [ "${LOAD_PROFILES}" == 1 ] ; then
85
if [ "$(whoami)" == 'root' ] ; then
86
timedir "apparmor_parser" "Parsing/loading directory of profiles"
89
echo "Not root, skipping load test..."
93
timesingle "cat" "Loading equivalent profile into buffer cache"
94
timesingle "apparmor_parser -dd" "Running preprocess only parser on single equiv profile"
95
timesingle "apparmor_parser -S" "Running full parser on single equivalent profile"
96
if [ "${LOAD_PROFILES}" == 1 ] ; then
97
if [ "$(whoami)" == 'root' ] ; then
98
timesingle "apparmor_parser" "Parsing/loading single file of profiles"
101
echo "Not root, skipping load test..."