mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-21 21:51:57 +02:00
Force our umount w/in the chroot.
Do this via ensuring that any common.sh invoker of raw umount (say a root script) sees our umount path. Additionally, inject into default profiles our override, and via an upgrade scriptlet. BUG=chromium-os:23443 TEST=manual validation, trybot. Change-Id: Ie2514f6e8d2e10a19ab8d11c8056177bc1a2fb4d Reviewed-on: https://gerrit.chromium.org/gerrit/32088 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Ready: Brian Harring <ferringb@chromium.org> Tested-by: Brian Harring <ferringb@chromium.org>
This commit is contained in:
parent
ece65e0633
commit
23da619f13
12
chroot_version_hooks.d/47_path_overrides
Normal file
12
chroot_version_hooks.d/47_path_overrides
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.
|
||||
|
||||
# Ensure that crosutils path overrides are in use; note that chroot
|
||||
# creation also invokes this, thus why we check for CROS_CHROOT; for
|
||||
# the normal upgrade pathway, it's non existant. For chroot creation,
|
||||
# It points to the chroot base.
|
||||
echo 'export PATH="/usr/local/path-overrides${PATH:+:${PATH}}"' | \
|
||||
sudo tee "${CROS_CHROOT}"/etc/profile.d/crosutils-path-overrides.sh \
|
||||
> /dev/null
|
||||
sudo chmod 644 "${CROS_CHROOT}"/etc/profile.d/crosutils-path-overrides.sh
|
23
common.sh
23
common.sh
@ -466,12 +466,12 @@ assert_not_root_user() {
|
||||
# Usage: check_flags_only_and_allow_null_arg "$@" && set --
|
||||
check_flags_only_and_allow_null_arg() {
|
||||
do_shift=1
|
||||
if [[ $# == 1 && -z "$@" ]]; then
|
||||
if [ $# = 1 -a -z "$1" ]; then
|
||||
echo "$0: warning: ignoring null argument" >&2
|
||||
shift
|
||||
do_shift=0
|
||||
fi
|
||||
if [[ $# -gt 0 ]]; then
|
||||
if [ $# -gt 0 ]; then
|
||||
echo "error: invalid arguments: \"$@\"" >&2
|
||||
flags_help
|
||||
exit 1
|
||||
@ -1071,3 +1071,22 @@ switch_to_strict_mode() {
|
||||
|
||||
# TODO: Re-enable this once shflags is set -e safe.
|
||||
#switch_to_strict_mode
|
||||
|
||||
# The following code is used to ensure our umount wrapper is in use.
|
||||
# Shouldn't be invoked by anything other than common.sh
|
||||
_enable_path_overrides(){
|
||||
# Ensure that our PATH overrides are in use.
|
||||
local override_dir=$(readlink -f "${SCRIPT_ROOT}/path-overrides")
|
||||
local IFS=:
|
||||
local x
|
||||
for x in ${PATH}; do
|
||||
x=$(readlink -f "${x}")
|
||||
if [ "${x}" = "${override_dir}" ]; then
|
||||
# Already is in path; nothing more to do.
|
||||
return
|
||||
fi
|
||||
done
|
||||
export PATH="${override_dir}${PATH:+:${PATH}}"
|
||||
}
|
||||
|
||||
_enable_path_overrides
|
||||
|
@ -274,8 +274,12 @@ setup_env() {
|
||||
queue_mount /run/shm "--bind" /run/shm
|
||||
fi
|
||||
fi
|
||||
queue_mount "${FLAGS_trunk}" "--bind" "${CHROOT_TRUNK_DIR}"
|
||||
# Get path overrides for the chroot in place now- it's possible
|
||||
# that they may be needed for early teardown.
|
||||
queue_mount "${FLAGS_trunk}/src/scripts/path-overrides" "--bind" \
|
||||
"/usr/local/path-overrides"
|
||||
|
||||
queue_mount "${FLAGS_trunk}" "--bind" "${CHROOT_TRUNK_DIR}"
|
||||
|
||||
debug "Setting up referenced repositories if required."
|
||||
REFERENCE_DIR=$(git config --file \
|
||||
|
@ -177,6 +177,11 @@ init_setup () {
|
||||
sudo bash -e "${SCRIPT_ROOT}/chroot_version_hooks.d/45_rewrite_sudoers.d" \
|
||||
"${FLAGS_chroot}" "${USER}" "${ENVIRONMENT_WHITELIST[@]}"
|
||||
|
||||
# Turn on the path overrides; subshelled to protect our env from whatever
|
||||
# vars the scriptlet may bleed.
|
||||
( CROS_CHROOT="${FLAGS_chroot}"
|
||||
. "${SCRIPT_ROOT}/chroot_version_hooks.d/47_path_overrides" )
|
||||
|
||||
sudo find "${FLAGS_chroot}/etc/"sudoers* -type f -exec chmod 0440 {} +
|
||||
# Fix bad group for some.
|
||||
sudo chown -R root:root "${FLAGS_chroot}/etc/"sudoers*
|
||||
|
Loading…
x
Reference in New Issue
Block a user