diff --git a/configure b/configure index 913517bf9..7f0d971a0 100755 --- a/configure +++ b/configure @@ -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 }