]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-functions): avoid calling grep with PCRE (-P)
authorDaniel McIlvaney <damcilva@microsoft.com>
Fri, 28 Apr 2023 21:02:05 +0000 (14:02 -0700)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Mon, 8 May 2023 04:58:09 +0000 (00:58 -0400)
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.

dracut-functions.sh

index f55d5dd4de95cfc171e85e67e511835b259b1590..b48c4b1894a365b309d12bed584f71a80c10df37 100755 (executable)
@@ -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