mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-08 02:41:55 +01:00
Add script which can instrument a test system for dbusspy at boot time
BUG=chromium-os:23229 TEST=ran this against a ToT alex img, image_to_usb, boots, installs, works Change-Id: Ia1e589a8b920332c1a247986e6bbc3cad17ed751 Reviewed-on: https://gerrit.chromium.org/gerrit/14650 Commit-Ready: Jim Hebert <jimhebert@chromium.org> Tested-by: Jim Hebert <jimhebert@chromium.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Chris Sosa <sosa@chromium.org>
This commit is contained in:
parent
3ae2b4b5d1
commit
4eb59d19a4
12
mod_for_dbusspy/dbus.conf
Normal file
12
mod_for_dbusspy/dbus.conf
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Drop this in as dbus.conf after renaming the normal dbus.conf to
|
||||
# "realdbus.conf". That will ensure this attaches to dbus first.
|
||||
|
||||
start on started realdbus
|
||||
|
||||
respawn
|
||||
|
||||
exec dbus-spy -w /var/log/dbusspy.log
|
||||
70
mod_test_image_for_dbusspy.sh
Executable file
70
mod_test_image_for_dbusspy.sh
Executable file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Script to modify a keyfob-based chromeos test image to log all dbus
|
||||
# activity from boot-time forward in a machine-readable replay format.
|
||||
# This is not part of the main "mod-for-test" for several reasons:
|
||||
# * it is overly invasive to the boot sequence,
|
||||
# * it has major run-time performance downsides,
|
||||
# * it consumes potentially huge amounts of disk space over time.
|
||||
# Any one of these are too-great of a depature from "normal" Chrome OS
|
||||
# to be appropriate for a "faithful" test-system. Note that dbus-monitor(1)
|
||||
# is available for casual/interactive use in normal mod-for-test systems.
|
||||
# Dbusspy-instrumented systems are only intended for narrow use cases, like
|
||||
# corpus collection for fuzzing, where the above trade-offs are acceptable.
|
||||
|
||||
. "/usr/lib/crosutils/common.sh" || { echo "Unable to load common.sh"; exit 1; }
|
||||
|
||||
assert_inside_chroot
|
||||
|
||||
DEFINE_string image "$FLAGS_image" "Location of the test image file" i
|
||||
|
||||
# Parse command line
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "$FLAGS_ARGV"
|
||||
|
||||
FLAGS_image=$(eval readlink -f "${FLAGS_image}")
|
||||
|
||||
IMAGE_DIR=$(dirname "${FLAGS_image}")
|
||||
IMAGE_NAME=$(basename "${FLAGS_image}")
|
||||
ROOT_FS_DIR="${IMAGE_DIR}/rootfs"
|
||||
DBUS_CONF="$(dirname "$0")/mod_for_dbusspy/dbus.conf"
|
||||
DEVKEYS_DIR="/usr/share/vboot/devkeys"
|
||||
VBOOT_DIR="${CHROOT_TRUNK_DIR}/src/platform/vboot_reference/scripts/"\
|
||||
"image_signing"
|
||||
|
||||
cleanup() {
|
||||
"${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$ROOT_FS_DIR"
|
||||
}
|
||||
|
||||
if [ ! -d "$VBOOT_DIR" ]; then
|
||||
die "The required path: $VBOOT_DIR does not exist. This directory needs"\
|
||||
"to be sync'd into your chroot.\n $ cros_workon start vboot_reference"
|
||||
fi
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
# Mounts gpt image and sets up var, /usr/local and symlinks.
|
||||
"$SCRIPTS_DIR/mount_gpt_image.sh" --image="$IMAGE_NAME" --from="$IMAGE_DIR" \
|
||||
--rootfs_mountpt="$ROOT_FS_DIR"
|
||||
|
||||
# A bunch of existing stuff is set to start up as soon as dbus is considered
|
||||
# to have started. Instead of modifying all of those things to instead
|
||||
# wait for dbus-spy to be started, drop dbus-spy in as "dbus" which,
|
||||
# in turn, waits on "realdbus." This way we don't race other services
|
||||
# and are guaranteed to capture all dbus events from boot onward.
|
||||
sudo cp -a "${ROOT_FS_DIR}/etc/init/dbus.conf" \
|
||||
"${ROOT_FS_DIR}/etc/init/realdbus.conf"
|
||||
sudo cp "${DBUS_CONF}" "${ROOT_FS_DIR}/etc/init/dbus.conf"
|
||||
|
||||
# Unmount and re-sign. See crosbug.com/18709 for why this isn't using
|
||||
# cros_make_image_bootable.
|
||||
cleanup
|
||||
TMP_BIN_PATH="${FLAGS_image}.new"
|
||||
"${VBOOT_DIR}/sign_official_build.sh" usb "${FLAGS_image}" \
|
||||
"${DEVKEYS_DIR}" \
|
||||
"${TMP_BIN_PATH}"
|
||||
mv "${TMP_BIN_PATH}" "${FLAGS_image}"
|
||||
Loading…
x
Reference in New Issue
Block a user