enter_chroot: also check SUDO_USER

Start with SUDO_USER before falling back to USER in case we're being
run through sudo.

BUG=chromium:1025578
TEST=CQ passes

Change-Id: Ic33aef2e870c98e4450aa9eb0c9eb6e43d647a51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/1967191
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index 9394eee..8ecc575 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -83,7 +83,7 @@
   .gdata_token                # Auth token for Google Docs on chromium.org
   .inputrc                    # Preserve command line customizations
 )
-if [[ "${USER}" == "chrome-bot" ]]; then
+if [[ "${SUDO_USER:-${USER}}" == "chrome-bot" ]]; then
   # Builders still haven't migrated fully to gitcookies.
   # https://crbug.com/1032944
   FILES_TO_COPY_TO_CHROOT+=( .netrc )
@@ -210,7 +210,7 @@
   # $1 is file path outside of chroot to copy to path $2 inside chroot.
   if [[ -e "$1" ]]; then
     local verbose
-    if [[ "${USER}" == "chrome-bot" ]]; then
+    if [[ "${SUDO_USER:-${USER}}" == "chrome-bot" ]]; then
       verbose="-v"
     fi
     user_cp ${verbose} "$1" "${FLAGS_chroot}/$2"