Skip to content

Commit f84377e

Browse files
committed
linuxkm/linuxkm-fips-hash-wrapper.sh: make sure awk is gawk.
1 parent 70aa3dc commit f84377e

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

linuxkm/linuxkm-fips-hash-wrapper.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,27 @@ set -o noclobber -o nounset -o pipefail -o errexit
2626
mod_path=$1
2727
shift
2828

29-
readarray -t fenceposts < <(readelf --wide --sections --symbols "$mod_path" | awk '
29+
# require Gnu Awk, for strtonum().
30+
31+
if [[ -v AWK ]] && ! "$AWK" --version 2>&1 | grep -F -q 'GNU Awk'; then
32+
unset AWK
33+
fi
34+
35+
if [[ ! -v AWK ]]; then
36+
if command -v gawk >/dev/null; then
37+
AWK='gawk'
38+
else
39+
AWK='awk'
40+
fi
41+
fi
42+
43+
if ! "$AWK" --version 2>&1 | grep -F -q 'GNU Awk'; then
44+
echo "Couldn't find required GNU Awk executable." >&2
45+
exit 1
46+
fi
47+
48+
# shellcheck disable=SC2016 # using $AWK instead of awk confuses shellcheck.
49+
readarray -t fenceposts < <(readelf --wide --sections --symbols "$mod_path" | "$AWK" '
3050
BEGIN {
3151
fips_fenceposts["wc_linuxkm_pie_reloc_tab"] = "reloc_tab_start";
3252
fips_fenceposts["wc_linuxkm_pie_reloc_tab_length"] = "reloc_tab_len_start";

0 commit comments

Comments
 (0)