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>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index 58cb0f5..8e76444 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -470,11 +470,15 @@
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