fix(dracut-functions): avoid calling grep with PCRE (-P)

Invoking grep in Perl mode requires JIT'ing the Perl regex.
This can run into issues with SELinix policy which will generally try to
limit use of execmem in general purpose scripts. This occurs since the
JIT'd code will live in executable  memory.

The PCRE only '\K' command in the Perl REGEX can be replaced by a call
to awk instead.
This commit is contained in:
Daniel McIlvaney 2023-04-28 14:02:05 -07:00 committed by Laszlo Gombos
parent 260883d96f
commit 67591e8855

View File

@ -244,7 +244,7 @@ get_maj_min() {
local _out
if [[ $get_maj_min_cache_file ]]; then
_out="$(grep -m1 -oP "^$1 \K\S+$" "$get_maj_min_cache_file")"
_out="$(grep -m1 -oE "^$1 \S+$" "$get_maj_min_cache_file" | awk '{print $NF}')"
fi
if ! [[ "$_out" ]]; then