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. This is round two; originally appeared as CL:32088, was reverted due to: https://uberchromegw.corp.google.com/i/chromiumos/builders/chromiumos%20sdk/builds/2314/steps/BuildBoard/logs/stdio The fix however is just adding a single sudo mkdir. :/ BUG=chromium-os:23443 TEST=cros_sdk --replace --bootstrap TEST=cros_sdk --replace Change-Id: I0dc7522a9c623f40081d4f138cea0c2c45171fea Reviewed-on: https://gerrit.chromium.org/gerrit/32365 Commit-Ready: Brian Harring <ferringb@chromium.org> Tested-by: Brian Harring <ferringb@chromium.org> Reviewed-by: Chris Sosa <sosa@chromium.org>
This commit is contained in:
parent
d5e3c01c08
commit
f264b82dd2
13
chroot_version_hooks.d/47_path_overrides
Normal file
13
chroot_version_hooks.d/47_path_overrides
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# 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.
|
||||||
|
sudo mkdir -p "${CROS_CHROOT}/etc/profile.d/"
|
||||||
|
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 --
|
# Usage: check_flags_only_and_allow_null_arg "$@" && set --
|
||||||
check_flags_only_and_allow_null_arg() {
|
check_flags_only_and_allow_null_arg() {
|
||||||
do_shift=1
|
do_shift=1
|
||||||
if [[ $# == 1 && -z "$@" ]]; then
|
if [ $# = 1 -a -z "$1" ]; then
|
||||||
echo "$0: warning: ignoring null argument" >&2
|
echo "$0: warning: ignoring null argument" >&2
|
||||||
shift
|
shift
|
||||||
do_shift=0
|
do_shift=0
|
||||||
fi
|
fi
|
||||||
if [[ $# -gt 0 ]]; then
|
if [ $# -gt 0 ]; then
|
||||||
echo "error: invalid arguments: \"$@\"" >&2
|
echo "error: invalid arguments: \"$@\"" >&2
|
||||||
flags_help
|
flags_help
|
||||||
exit 1
|
exit 1
|
||||||
@ -1071,3 +1071,22 @@ switch_to_strict_mode() {
|
|||||||
|
|
||||||
# TODO: Re-enable this once shflags is set -e safe.
|
# TODO: Re-enable this once shflags is set -e safe.
|
||||||
#switch_to_strict_mode
|
#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
|
queue_mount /run/shm "--bind" /run/shm
|
||||||
fi
|
fi
|
||||||
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."
|
debug "Setting up referenced repositories if required."
|
||||||
REFERENCE_DIR=$(git config --file \
|
REFERENCE_DIR=$(git config --file \
|
||||||
|
@ -177,6 +177,11 @@ init_setup () {
|
|||||||
sudo bash -e "${SCRIPT_ROOT}/chroot_version_hooks.d/45_rewrite_sudoers.d" \
|
sudo bash -e "${SCRIPT_ROOT}/chroot_version_hooks.d/45_rewrite_sudoers.d" \
|
||||||
"${FLAGS_chroot}" "${USER}" "${ENVIRONMENT_WHITELIST[@]}"
|
"${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 {} +
|
sudo find "${FLAGS_chroot}/etc/"sudoers* -type f -exec chmod 0440 {} +
|
||||||
# Fix bad group for some.
|
# Fix bad group for some.
|
||||||
sudo chown -R root:root "${FLAGS_chroot}/etc/"sudoers*
|
sudo chown -R root:root "${FLAGS_chroot}/etc/"sudoers*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user