l30013671 / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
Blob Blame History Raw
#! /bin/bash

MODSECKEY="./signing_key.priv"
MODPUBKEY="./signing_key.x509"
moddir=$1

modules=`find $moddir -type f -name '*.ko'`

NPROC=`nproc`
[ -z "$NPROC" ] && NPROC=1

# NB: this loop runs 2000+ iterations. Try to be fast.
echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
for mod; do
    ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
    rm -f \$mod.sig \$mod.dig
done
" DUMMYARG0   # xargs appends ARG1 ARG2..., which go into $mod in for loop.

RANDOMMOD=$(echo "$modules" | sort -R | tail -n 1)
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
	echo "*** Modules are unsigned! ***"
	exit 1
fi

exit 0