enter_chroot.sh: install /root/.boto symlink for sudoed invocations

Since sudo changes $HOME to /root, sudoed invocations of gsutil/boto
won't find the necessary credentials. This solves the problem by
installing a symlink at /root/.boto to the correct credentials file,
similar to how it's done for /home/$USER/.boto.

BUG=None
TEST=/root/.boto symlink created upon entering the chroot

Change-Id: I541556f836fa5d0b9708e5604218058401563fb3
Reviewed-on: https://gerrit.chromium.org/gerrit/32430
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Ryan Cui <rcui@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
This commit is contained in:
Gilad Arnold 2012-09-06 14:01:45 -07:00 committed by Gerrit
parent bd0ba0c9da
commit 264f64d70b

View File

@ -470,11 +470,15 @@ setup_env() {
fi
# If the private overlays are installed, gsutil can use those credentials.
if [ ! -e "${FLAGS_chroot}/home/${USER}/.boto" ]; then
boto='src/private-overlays/chromeos-overlay/googlestorage_account.boto'
if [ -s "${FLAGS_trunk}/${boto}" ]; then
# We're also installing credentials for use by sudoed invocations.
boto='src/private-overlays/chromeos-overlay/googlestorage_account.boto'
if [ -s "${FLAGS_trunk}/${boto}" ]; then
if [ ! -e "${FLAGS_chroot}/home/${USER}/.boto" ]; then
ln -s "trunk/${boto}" "${FLAGS_chroot}/home/${USER}/.boto"
fi
if [ ! -e "${FLAGS_chroot}/root/.boto" ]; then
sudo ln -s "../home/${USER}/trunk/${boto}" "${FLAGS_chroot}/root/.boto"
fi
fi
# Have found a few chroots where ~/.gsutil is owned by root:root, probably