Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / scripts / modsign / modsign.sh
1 #!/bin/bash
2 ###############################################################################
3 #
4 # Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
5 # Written by David Howells (dhowells@redhat.com)
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version
10 # 2 of the License, or (at your option) any later version.
11 #
12 ###############################################################################
13
14 verbose=
15
16 if [ $# -gt 1 -a "x$1" = "x-v" ]
17     then
18     verbose=-v
19     shift
20 fi
21
22 if [ $# = 0 ]
23     then
24         echo
25         echo "usage: $0 [-v] <module_to_sign> [<key_name>]"
26         echo
27         exit 1
28 fi
29
30 module=$1
31
32 if [ -z "$KEYFLAGS" ]
33     then
34     KEYFLAGS="--no-default-keyring --secret-keyring ../kernel.sec --keyring ../kernel.pub"
35 fi
36
37 if [ $# -eq 2 ]
38     then
39     KEYFLAGS="$KEYFLAGS --default-key $2"
40 fi
41
42 # strip out only the sections that we care about
43 scripts/modsign/mod-extract $verbose $module $module.out || exit $?
44
45 # sign the sections
46 gpg --no-greeting $KEYFLAGS -b $module.out || exit $?
47
48 # check the signature
49 #gpg --verify rxrpc.ko.out.sig rxrpc.ko.out
50
51 ## sha1 the sections
52 #sha1sum $module.out | awk "{print \$1}" > $module.sha1
53
54 # add the encrypted data to the module
55 objcopy --add-section .module_sig=$module.out.sig $module $module.signed || exit $?
56 objcopy --set-section-flags .module_sig=alloc $module.signed || exit $?
57 rm -f $module.out*