mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 07:01:13 +02:00
scripts: bind ~/.ssh over the chroot's ~/.ssh.
This also mounts the path to our ssh-agent socket (usually in /tmp) inside the chroot so we can use our external agent. TEST=None BUG=None Change-Id: I543e8b2527be9958c1158234f39ecc34fc9dd0df Signed-Off-By: Elly Jones <ellyjones@chromium.org> Signed-Off-By: sosa <sosa@chromium.org> Review URL: http://codereview.chromium.org/3277006
This commit is contained in:
parent
c8cb33699e
commit
7990a0673c
@ -31,6 +31,7 @@ DEFINE_boolean official_build $FLAGS_FALSE \
|
||||
"Set CHROMEOS_OFFICIAL=1 for release builds."
|
||||
DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts."
|
||||
DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts."
|
||||
DEFINE_boolean ssh_agent $FLAGS_TRUE "Import ssh agent."
|
||||
|
||||
# More useful help
|
||||
FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"]
|
||||
@ -104,6 +105,20 @@ function setup_env {
|
||||
die "Could not mount $MOUNTED_PATH"
|
||||
fi
|
||||
|
||||
if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then
|
||||
TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")"
|
||||
if [ -n "${SSH_AUTH_SOCK}" \
|
||||
-a -d "${HOME}/.ssh" ]
|
||||
then
|
||||
mkdir -p "${TARGET_DIR}"
|
||||
cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}"
|
||||
ASOCK="$(dirname "${SSH_AUTH_SOCK}")"
|
||||
mkdir -p "${FLAGS_chroot}/${ASOCK}"
|
||||
sudo mount --bind "${ASOCK}" "${FLAGS_chroot}/${ASOCK}" || \
|
||||
die "Count not mount ${ASOCK}"
|
||||
fi
|
||||
fi
|
||||
|
||||
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")"
|
||||
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
|
||||
then
|
||||
@ -274,7 +289,8 @@ fi
|
||||
# the source trunk for scripts that may need to print it (e.g.
|
||||
# build_image.sh).
|
||||
sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \
|
||||
EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C -- "$@"
|
||||
EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \
|
||||
SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" -- "$@"
|
||||
|
||||
# Remove trap and explicitly unmount
|
||||
trap - EXIT
|
||||
|
Loading…
x
Reference in New Issue
Block a user