mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-15 07:54:17 +01:00
build: make the complain mode faster to enable.
This commit is contained in:
parent
a432d656c8
commit
cc7dd22244
33
configure
vendored
33
configure
vendored
@ -112,18 +112,39 @@ flags() {
|
||||
done
|
||||
}
|
||||
|
||||
# Set complain flag on all profile (Dev only)
|
||||
complain() {
|
||||
_msg "Set complain flag on all profiles"
|
||||
for path in "${ROOT:?}/apparmor.d/"*; do
|
||||
[[ -d "$path" ]] && continue
|
||||
# Internal complain process
|
||||
_complain() {
|
||||
local start="$1" end="$2"; shift 2
|
||||
files=("$@")
|
||||
ii="$start"
|
||||
while [[ $ii -le $end && $ii -lt $len ]]; do
|
||||
path="${files[$ii]}"
|
||||
(( ii = ii + 1 ))
|
||||
[[ -f "$path" ]] || continue
|
||||
flags="$(grep -o -m 1 'flags=(.*)' "$path" | cut -d '(' -f2 | cut -d ')' -f1)"
|
||||
[[ "$flags" =~ complain ]] && continue
|
||||
echo -n .
|
||||
sed -e "s/flags=(.*)//" \
|
||||
-e "s/ {$/ flags=(complain $flags) {/" \
|
||||
-i "$path"
|
||||
done
|
||||
}
|
||||
|
||||
# Set complain flag on all profile (Dev only)
|
||||
complain() {
|
||||
local len nprof nproc
|
||||
_msg "Set complain flag on all profiles"
|
||||
mapfile -t files < <(find "${ROOT:?}/apparmor.d" -type f)
|
||||
len="${#files[@]}"
|
||||
nproc=$(nproc)
|
||||
(( nprof = len/nproc + 1 ))
|
||||
start=0
|
||||
end=$nprof
|
||||
for ((ii = 0 ; ii < nproc ; ii++)); do
|
||||
_complain $start $end "${files[@]}" &
|
||||
(( start = end + 1 ))
|
||||
(( end = end + nprof ))
|
||||
done
|
||||
wait
|
||||
echo
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user