Skip to content

Commit 43d4ce1

Browse files
committed
mkswu show: print signature information if found
make 'mkswu show' print signature common name (and serial if -v): ``` $ mkswu --show initial_setup.swu # initial_setup.swu # Built with mkswu 6.5-13-g1105c8bca349 # signed by "Armadillo swupdate public one-time key" [...] $ mkswu -v --show initial_setup.swu | grep signed # signed by "Armadillo swupdate public one-time key", serial: 26AD60D893F09C775E7B3698E26C9F2428F54898 $ mkswu -v --show baseos*.swu | grep signed # signed by "Armadillo swupdate key" <-- old releases # signed by "Armadillo swupdate key #2" <-- new releases ``` Change-Id: I05f275fb6588683251719fac6f7f9610dd6ef685
1 parent bb9bf63 commit 43d4ce1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

mkswu

+17-2
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,7 @@ mkswu_update_version() {
26012601
}
26022602

26032603
mkswu_show() {
2604-
local swu desc order awk=""
2604+
local swu desc sig order awk=""
26052605

26062606
if command -v gawk >/dev/null; then
26072607
awk="gawk"
@@ -2639,10 +2639,23 @@ mkswu_show() {
26392639

26402640
[ -n "$awk" ] || error "mkswu --show requires a compatible awk (e.g. gawk)"
26412641

2642+
sig=$(cpio -i --quiet --to-stdout sw-description.sig < "$swu" \
2643+
| openssl asn1parse -inform DER \
2644+
| "$awk" -F: -v "verbose=$VERBOSE" '
2645+
$3 == "commonName" { in_cn=1 }
2646+
in_cn=1 && /UTF8STRING/ { cn=$4 }
2647+
in_cn=1 && /INTEGER/ { serial=$4 }
2648+
{ in_cn=0 }
2649+
END {
2650+
if (!cn) { exit }
2651+
printf("# signed by \"%s\"", cn)
2652+
if (verbose > 2 && serial) { print ", serial:", serial }
2653+
}')
2654+
26422655
order=$(cpio -t --quiet < "$swu") \
26432656
|| error "Could not get SWU file list from %s" "$swu"
26442657

2645-
printf "%s\n" "$desc" | "$awk" -v "order_string=$order" '
2658+
printf "%s\n" "$desc" | "$awk" -v "sig=$sig" -v "order_string=$order" '
26462659
function dequote() {
26472660
# undo "conf_quote"
26482661
sub(/";$/, "")
@@ -2654,11 +2667,13 @@ mkswu_show() {
26542667
# pre mkswu-5.0
26552668
/^ *# Built with mkswu/ {
26562669
print "# Built with mkswu", $NF
2670+
if (sig) print sig;
26572671
}
26582672
NR == 2 && /version = "/ {
26592673
sub(/.*version = "/, "")
26602674
dequote()
26612675
print "# Built with mkswu", $1
2676+
if (sig) print sig;
26622677
}
26632678
# pre mkswu-4.11
26642679
/^ *# swdesc/ {

tests/cmd_description.show

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# out/cmd_description.swu
22

33
# Built with mkswu
4+
# signed by "test"
45
swdesc_option FORCE_VERSION
56

67
swdesc_command_nochroot 'echo ran default command >&2'

0 commit comments

Comments
 (0)