Pass more proxy vars into the chroot, rework sudoers.d maintenance.

In particular, put the sudoers.d setup into one script (making
updates to it easier in the future if necessary), and
centralize the proxied vars into a const in common.sh.

Thanks to Kevin McCray/Josh Triplett/Alexander Kanevsky for
pointing out the missing proxy variables, and fixes/cleanup.

BUG=None
TEST=https_proxy=blah cros_sdk -- bash -c 'echo $https_proxy'
TEST=build_packages behind a proxy.
TEST=cros_sdk --replace && \
     RSYNC_PROXY=blah cros_sdk -- bash -c 'echo $RSYNC_PROXY'

Change-Id: I3165882dfd9c8b52d25c2b26d7ff9242c84c91bd
Reviewed-on: https://gerrit.chromium.org/gerrit/31185
Tested-by: Brian Harring <ferringb@chromium.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Josh Triplett <josh@joshtriplett.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index 0b25cdb..77a25d4 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -570,30 +570,20 @@
 
 CHROOT_PASSTHRU=(
   "BUILDBOT_BUILD=$FLAGS_build_number"
-  "CHROMEOS_OFFICIAL=$CHROMEOS_OFFICIAL"
   "CHROMEOS_RELEASE_APPID=${CHROMEOS_RELEASE_APPID:-{DEV-BUILD}}"
-
-  # Set CHROMEOS_VERSION_TRACK, CHROMEOS_VERSION_AUSERVER,
-  # CHROMEOS_VERSION_DEVSERVER as environment variables to override the default
-  # assumptions (local AU server). These are used in cros_set_lsb_release, and
-  # are used by external Chromium OS builders.
-
-  "CHROMEOS_VERSION_TRACK=${CHROMEOS_VERSION_TRACK}"
-  "CHROMEOS_VERSION_AUSERVER=${CHROMEOS_VERSION_AUSERVER}"
-  "CHROMEOS_VERSION_DEVSERVER=${CHROMEOS_VERSION_DEVSERVER}"
   "EXTERNAL_TRUNK_PATH=${FLAGS_trunk}"
-  "SSH_AGENT_PID=${SSH_AGENT_PID}"
-  "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}"
 )
 
-# Some vars we want to keep.
-KEEP_VARS="USE GCC_GITHASH"
-# Pass proxy variables into the environment.
-PROXY_VARS="http_proxy ftp_proxy all_proxy GIT_PROXY_COMMAND GIT_SSH"
-for type in ${KEEP_VARS} ${PROXY_VARS}; do
-  if [ -n "${!type}" ]; then
-    CHROOT_PASSTHRU+=( "${type}=${!type}" )
-  fi
+# Add the standard proxied variables, and a few we specifically
+# export for script usage; USE/GCC_GITHASH are for ebuilds/portage,
+# CHROMEOS_VERSION_* is for cros_set_lsb_release and local AU server
+# (builders export this for marking reasons).
+KEEP_VARS=(
+  CHROMEOS_VERSION_{TRACK,AUSERVER,DEVSERVER}
+  USE GCC_GITHASH
+)
+for var in "${ENVIRONMENT_WHITELIST[@]}" "${KEEP_VARS[@]}"; do
+  [ "${!var+set}" = "set" ] && CHROOT_PASSTHRU+=( "${var}=${!var}" )
 done
 
 # Run command or interactive shell.  Also include the non-chrooted path to