enter_chroot: force sane PATH with locale-gen

If the host distro has a default PATH setup that doesn't match what
we use inside the SDK, locale-gen might not be found, or programs it
expects to be in $PATH won't be.  Force the setting to match the SDK
so the host distro doesn't matter.

BUG=None
TEST=running cros_sdk with a reduced PATH used to fail but now works

Change-Id: I136bf9f7244d9c644c90ce939516a33b6c16436f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/2208936
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index 543c8f9..77d384a 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -298,8 +298,10 @@
     # Force jobs=1 to work around locale-gen weirdness where it simultaneously
     # wants to and doesn't want to run multiple jobs (and complains about it).
     # crbug.com/761153
-    chroot "${FLAGS_chroot}" env LC_ALL=C locale-gen -q -u \
-      -j 1 -G "$(printf '%s\n' "${gen_locales[@]}")"
+    # Force PATH to the right value inside the SDK in case the host distro has
+    # its own incompatible setup.
+    chroot "${FLAGS_chroot}" env LC_ALL=C PATH='/bin:/sbin:/usr/bin:/usr/sbin' \
+      locale-gen -q -u -j 1 -G "$(printf '%s\n' "${gen_locales[@]}")"
   fi
 }