f0f4ff2
#! /bin/bash
f0f4ff2
f0f4ff2
# We need to sign modules we've moved from <path>/kernel/ to <path>/extra/
f0f4ff2
# during mod-extra processing by hand.  The 'modules_sign' Kbuild target can
f0f4ff2
# "handle" out-of-tree modules, but it does that by not signing them.  Plus,
f0f4ff2
# the modules we've moved aren't actually out-of-tree.  We've just shifted
f0f4ff2
# them to a different location behind Kbuild's back because we are mean.
f0f4ff2
f0f4ff2
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
f0f4ff2
# same commands for those modules.
f0f4ff2
f0f4ff2
moddir=$1
f0f4ff2
f0f4ff2
modules=`find $moddir -name *.ko`
f0f4ff2
f0f4ff2
MODSECKEY="./signing_key.priv"
f0f4ff2
MODPUBKEY="./signing_key.x509"
f0f4ff2
f0f4ff2
for mod in $modules
f0f4ff2
do
f0f4ff2
    dir=`dirname $mod`
f0f4ff2
    file=`basename $mod`
f0f4ff2
f0f4ff2
    sh ./scripts/sign-file ${MODSECKEY} ${MODPUBKEY} ${dir}/${file} \
f0f4ff2
       ${dir}/${file}.signed
f0f4ff2
    mv ${dir}/${file}.signed ${dir}/${file}
f0f4ff2
    rm -f ${dir}/${file}.{sig,dig}
f0f4ff2
done