Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh -u | 1 #!/bin/sh -u |
| 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 # Usage: dev_debug_vboot [ --cleanup | DIRECTORY ] | 6 # Usage: dev_debug_vboot [ --cleanup | DIRECTORY ] |
| 7 # | 7 # |
| 8 # This extracts some useful debugging information about verified boot. A short | 8 # This extracts some useful debugging information about verified boot. A short |
| 9 # summary is printed on stdout, more detailed information and working files are | 9 # summary is printed on stdout, more detailed information and working files are |
| 10 # left in a log directory. | 10 # left in a log directory. |
| 11 # | 11 # |
| 12 | 12 |
| 13 PATH=/bin:/sbin:/usr/bin:/usr/sbin | 13 PATH=/bin:/sbin:/usr/bin:/usr/sbin |
| 14 | 14 |
| 15 TMPDIR=$(mktemp -d /tmp/debug_vboot_XXXXXXXXX) | 15 TMPDIR=$(mktemp -d /tmp/debug_vboot_XXXXXXXXX) |
| 16 LOGFILE=noisy.log | 16 LOGFILE=noisy.log |
| 17 # The public file must live directly in /tmp, not in a subdirectory. | 17 PUBLOGFILE=/var/log/debug_vboot_noisy.log |
| 18 # See http://crosbug.com/8947 | |
| 19 PUBLOGFILE=/tmp/debug_vboot_noisy.log | |
| 20 | 18 |
| 21 # TODO(wfrichar): Need to support ARM. The hard disk path is likely different. | 19 # TODO(wfrichar): Need to support ARM. The hard disk path is likely different. |
| 22 # We can use 'crossystem arch' to distinguish between x86 and ARM. | 20 # We can use 'crossystem arch' to distinguish between x86 and ARM. |
| 23 HD=/dev/sda | 21 HD=/dev/sda |
| 24 | 22 |
| 25 cleanup() { | 23 cleanup() { |
| 26 if [ -z "${USE_EXISTING:-}" ]; then | 24 if [ -z "${USE_EXISTING:-}" ]; then |
| 27 # See http://crosbug.com/8947 | 25 cp -f "${LOGFILE}" "${PUBLOGFILE}" |
| 28 cp --no-target-directory --remove-destination "${LOGFILE}" "${PUBLOGFILE}" | |
| 29 info "exporting log file as ${PUBLOGFILE}" | 26 info "exporting log file as ${PUBLOGFILE}" |
| 30 fi | 27 fi |
| 31 if [ -n "${CLEANUP:-}" ]; then | 28 if [ -n "${CLEANUP:-}" ]; then |
| 32 cd / | 29 cd / |
| 33 rm -rf "${TMPDIR}" | 30 rm -rf "${TMPDIR}" |
| 34 fi | 31 fi |
| 35 } | 32 } |
| 36 | 33 |
| 37 die() { | 34 die() { |
| 38 echo "$*" 1>&2 | 35 echo "$*" 1>&2 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 if [ "$1" = "--cleanup" ]; then | 99 if [ "$1" = "--cleanup" ]; then |
| 103 CLEANUP=1 | 100 CLEANUP=1 |
| 104 else | 101 else |
| 105 TMPDIR="$1" | 102 TMPDIR="$1" |
| 106 [ -d ${TMPDIR} ] || die "${TMPDIR} doesn't exist" | 103 [ -d ${TMPDIR} ] || die "${TMPDIR} doesn't exist" |
| 107 USE_EXISTING=yes | 104 USE_EXISTING=yes |
| 108 fi | 105 fi |
| 109 fi | 106 fi |
| 110 | 107 |
| 111 [ -d ${TMPDIR} ] || mkdir -p ${TMPDIR} || exit 1 | 108 [ -d ${TMPDIR} ] || mkdir -p ${TMPDIR} || exit 1 |
| 112 cd ${TMPDIR} | 109 cd ${TMPDIR} |
|
gauravsh
2011/04/13 02:41:28
one suggestion: I feel it be much cleaner if you m
| |
| 113 echo "$0 $*" > "$LOGFILE" | 110 echo "$0 $*" > "$LOGFILE" |
| 114 log date | 111 log date |
| 115 echo "Saving verbose log as $(pwd)/$LOGFILE" | 112 echo "Saving verbose log as $(pwd)/$LOGFILE" |
| 116 | 113 |
| 117 BIOS=bios.rom | 114 BIOS=bios.rom |
| 118 | 115 |
| 119 # Find BIOS and kernel images | 116 # Find BIOS and kernel images |
| 120 if [ -n "${USE_EXISTING:-}" ]; then | 117 if [ -n "${USE_EXISTING:-}" ]; then |
| 121 info "Using images in $(pwd)/" | 118 info "Using images in $(pwd)/" |
| 122 else | 119 else |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 loghead od -Ax -tx1 $keyblock | 181 loghead od -Ax -tx1 $keyblock |
| 185 done | 182 done |
| 186 | 183 |
| 187 # Test each kernel with each key | 184 # Test each kernel with each key |
| 188 for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk recoverykey.vbpubk; do | 185 for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk recoverykey.vbpubk; do |
| 189 for kern in *kern*.blob; do | 186 for kern in *kern*.blob; do |
| 190 infon "Verify $kern with $key... " | 187 infon "Verify $kern with $key... " |
| 191 log vbutil_kernel --verify $kern --signpubkey $key ; result | 188 log vbutil_kernel --verify $kern --signpubkey $key ; result |
| 192 done | 189 done |
| 193 done | 190 done |
| OLD | NEW |