Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: enter_chroot.sh

Issue 3277006: scripts: bind ~/.ssh over the chroot's ~/.ssh. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Rename MOUNTED_PATH; don't test for mount of plain directory. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: enter_chroot.sh
diff --git a/enter_chroot.sh b/enter_chroot.sh
index 663b76c9e3905e1e54fe6d32c640d8e50ca93c20..00aca4ca2d49c0ace89454fe4f127ae63609de25 100755
--- a/enter_chroot.sh
+++ b/enter_chroot.sh
@@ -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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698