8016 cron(1M): Strange sentence in the man page
[unleashed.git] / usr / src / tools / elfsign / elfsigncmp.sh
blob97f046a166e2ec1b50c6ece6414e60d0ac50c551
1 #! /usr/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # ident "%Z%%M% %I% %E% SMI"
26 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
30 prog=$0
31 pd=`dirname $prog`
32 MACH=`uname -p`
33 elfcmp=$pd/elfcmp
34 elfsign=$pd/$MACH/elfsign
36 aopt=
37 copt=
38 eopt=
39 Fopt=
40 kopt=
41 vopt=
43 Usage() {
44 echo "Usage: $prog {sign|verify} [-v] [-a]" \
45 "[-c <cert>] [-k <key>] [-F <format>] -e <elf>" 1>&2
46 exit 1
49 if [ $# -lt 1 ]; then
50 Usage
52 cmd=$1
53 shift
55 while getopts "ac:e:F:k:v" opt ; do
56 case $opt in
57 a) aopt=-a;;
58 c) copt="$OPTARG";;
59 e) eopt="$OPTARG";;
60 F) Fopt="$OPTARG";;
61 k) kopt="$OPTARG";;
62 v) vopt=-v;;
63 \?) Usage;;
64 esac
65 done
67 case X$eopt in X) Usage;; esac
69 tmpe=$eopt.e$$
70 tmpo=$eopt.o$$
72 cpq() {
73 cp -p $1 $2 > /dev/null 2>&1
76 restore() {
77 cpq $tmpe $eopt
80 cleanup() {
81 restore
82 rm -f $tmpe $tmpo
85 trap cleanup 1 2 3 13 15
87 cpq $eopt $tmpe
89 eval $elfsign $cmd $aopt $vopt ${copt:+-c} ${copt} ${kopt:+-k} ${kopt} \
90 ${Fopt:+-F} ${Fopt} -e ${eopt}
91 rv=$?
93 case $cmd:$rv in
94 sign:0)
95 if $elfcmp -v -S $tmpe $eopt > $tmpo 2>&1
96 then
97 : # all's fine
98 else
99 rv=$?
100 echo "Warning: elfcmp failed: $eopt" 1>&2
101 cat ${tmpo} 1>&2
102 echo "current directory: `pwd`" 1>&2
103 restore
104 cpq ${eopt} ${eopt}.elfcmp.failed.$$
107 sign:*)
108 restore
109 cpq ${eopt} ${eopt}.elfsign.failed.$$
111 esac
113 rm -f $tmpe $tmpo
114 exit $rv